| 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: Bitwise OR for BigInt non-primitive values |
| 5 |
esid: sec-binary-bitwise-operators-runtime-semantics-evaluation |
| 6 |
info: | |
| 7 |
5. Let lnum be ? ToNumeric(lval). |
| 8 |
6. Let rnum be ? ToNumeric(rval). |
| 9 |
... |
| 10 |
8. Let T be Type(lnum). |
| 11 |
... |
| 12 |
10. If @ is |, return T::bitwiseOR(lnum, rnum). |
| 13 |
|
| 14 |
features: [BigInt] |
| 15 |
---*/ |
| 16 |
assert.sameValue( |
| 17 |
Object(0b101n) | 0b011n, |
| 18 |
0b111n, |
| 19 |
'The result of (Object(0b101n) | 0b011n) is 0b111n' |
| 20 |
); |
| 21 |
|
| 22 |
assert.sameValue( |
| 23 |
0b011n | Object(0b101n), |
| 24 |
0b111n, |
| 25 |
'The result of (0b011n | Object(0b101n)) is 0b111n' |
| 26 |
); |
| 27 |
|
| 28 |
assert.sameValue( |
| 29 |
Object(0b101n) | Object(0b011n), |
| 30 |
0b111n, |
| 31 |
'The result of (Object(0b101n) | Object(0b011n)) is 0b111n' |
| 32 |
); |
| 33 |
|
| 34 |
function err() { |
| 35 |
throw new Test262Error(); |
| 36 |
} |
| 37 |
|
| 38 |
assert.sameValue({ |
| 39 |
[Symbol.toPrimitive]: function() { |
| 40 |
return 0b101n; |
| 41 |
}, |
| 42 |
|
| 43 |
valueOf: err, |
| 44 |
toString: err |
| 45 |
} | 0b011n, 0b111n, 'The result of (({[Symbol.toPrimitive]: function() {return 0b101n;}, valueOf: err, toString: err}) | 0b011n) is 0b111n'); |
| 46 |
|
| 47 |
assert.sameValue(0b011n | { |
| 48 |
[Symbol.toPrimitive]: function() { |
| 49 |
return 0b101n; |
| 50 |
}, |
| 51 |
|
| 52 |
valueOf: err, |
| 53 |
toString: err |
| 54 |
}, 0b111n, 'The result of (0b011n | {[Symbol.toPrimitive]: function() {return 0b101n;}, valueOf: err, toString: err}) is 0b111n'); |
| 55 |
|
| 56 |
assert.sameValue({ |
| 57 |
valueOf: function() { |
| 58 |
return 0b101n; |
| 59 |
}, |
| 60 |
|
| 61 |
toString: err |
| 62 |
} | 0b011n, 0b111n, 'The result of (({valueOf: function() {return 0b101n;}, toString: err}) | 0b011n) is 0b111n'); |
| 63 |
|
| 64 |
assert.sameValue(0b011n | { |
| 65 |
valueOf: function() { |
| 66 |
return 0b101n; |
| 67 |
}, |
| 68 |
|
| 69 |
toString: err |
| 70 |
}, 0b111n, 'The result of (0b011n | {valueOf: function() {return 0b101n;}, toString: err}) is 0b111n'); |
| 71 |
|
| 72 |
assert.sameValue({ |
| 73 |
toString: function() { |
| 74 |
return 0b101n; |
| 75 |
} |
| 76 |
} | 0b011n, 0b111n, 'The result of (({toString: function() {return 0b101n;}}) | 0b011n) is 0b111n'); |
| 77 |
|
| 78 |
assert.sameValue(0b011n | { |
| 79 |
toString: function() { |
| 80 |
return 0b101n; |
| 81 |
} |
| 82 |
}, 0b111n, 'The result of (0b011n | {toString: function() {return 0b101n;}}) is 0b111n'); |
| 83 |
|
| 84 |
reportCompare(0, 0); |