bigint-wrapped-values.js (1444B)
1 // Copyright (C) 2017 Josh Wolfe. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 description: exponentiation operator ToNumeric with BigInt operands 5 esid: sec-exp-operator-runtime-semantics-evaluation 6 features: [BigInt, Symbol.toPrimitive, computed-property-names, exponentiation] 7 ---*/ 8 assert.sameValue(Object(2n) ** 1n, 2n, 'The result of (Object(2n) ** 1n) is 2n'); 9 assert.sameValue(1n ** Object(2n), 1n, 'The result of (1n ** Object(2n)) is 1n'); 10 11 assert.sameValue({ 12 [Symbol.toPrimitive]: function() { 13 return 2n; 14 } 15 } ** 1n, 2n, 'The result of (({[Symbol.toPrimitive]: function() {return 2n;}}) ** 1n) is 2n'); 16 17 assert.sameValue(1n ** { 18 [Symbol.toPrimitive]: function() { 19 return 2n; 20 } 21 }, 1n, 'The result of (1n ** {[Symbol.toPrimitive]: function() {return 2n;}}) is 1n'); 22 23 assert.sameValue({ 24 valueOf: function() { 25 return 2n; 26 } 27 } ** 1n, 2n, 'The result of (({valueOf: function() {return 2n;}}) ** 1n) is 2n'); 28 29 assert.sameValue(1n ** { 30 valueOf: function() { 31 return 2n; 32 } 33 }, 1n, 'The result of (1n ** {valueOf: function() {return 2n;}}) is 1n'); 34 35 assert.sameValue({ 36 toString: function() { 37 return 2n; 38 } 39 } ** 1n, 2n, 'The result of (({toString: function() {return 2n;}}) ** 1n) is 2n'); 40 41 assert.sameValue(1n ** { 42 toString: function() { 43 return 2n; 44 } 45 }, 1n, 'The result of (1n ** {toString: function() {return 2n;}}) is 1n'); 46 47 reportCompare(0, 0);