bigint-wrapped-values.js (1440B)
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: right-shift operator ToNumeric with BigInt operands 5 esid: sec-signed-right-shift-operator-runtime-semantics-evaluation 6 features: [BigInt, Symbol.toPrimitive, computed-property-names] 7 ---*/ 8 assert.sameValue(Object(2n) >> 1n, 1n, 'The result of (Object(2n) >> 1n) is 1n'); 9 assert.sameValue(4n >> Object(2n), 1n, 'The result of (4n >> Object(2n)) is 1n'); 10 11 assert.sameValue({ 12 [Symbol.toPrimitive]: function() { 13 return 2n; 14 } 15 } >> 1n, 1n, 'The result of (({[Symbol.toPrimitive]: function() {return 2n;}}) >> 1n) is 1n'); 16 17 assert.sameValue(4n >> { 18 [Symbol.toPrimitive]: function() { 19 return 2n; 20 } 21 }, 1n, 'The result of (4n >> {[Symbol.toPrimitive]: function() {return 2n;}}) is 1n'); 22 23 assert.sameValue({ 24 valueOf: function() { 25 return 2n; 26 } 27 } >> 1n, 1n, 'The result of (({valueOf: function() {return 2n;}}) >> 1n) is 1n'); 28 29 assert.sameValue(4n >> { 30 valueOf: function() { 31 return 2n; 32 } 33 }, 1n, 'The result of (4n >> {valueOf: function() {return 2n;}}) is 1n'); 34 35 assert.sameValue({ 36 toString: function() { 37 return 2n; 38 } 39 } >> 1n, 1n, 'The result of (({toString: function() {return 2n;}}) >> 1n) is 1n'); 40 41 assert.sameValue(4n >> { 42 toString: function() { 43 return 2n; 44 } 45 }, 1n, 'The result of (4n >> {toString: function() {return 2n;}}) is 1n'); 46 47 reportCompare(0, 0);