| 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: subtraction operator ToNumeric with BigInt operands |
| 5 |
esid: sec-subtraction-operator-minus-runtime-semantics-evaluation |
| 6 |
features: [BigInt, Symbol.toPrimitive, computed-property-names] |
| 7 |
---*/ |
| 8 |
|
| 9 |
assert.sameValue(Object(2n) - 1n, 1n, "ToPrimitive: unbox object with internal slot"); |
| 10 |
assert.sameValue(3n - Object(2n), 1n, "ToPrimitive: unbox object with internal slot"); |
| 11 |
assert.sameValue(({ |
| 12 |
[Symbol.toPrimitive]: function() { |
| 13 |
return 2n; |
| 14 |
} |
| 15 |
}) - 1n, 1n, "ToPrimitive: @@toPrimitive"); |
| 16 |
assert.sameValue(3n - { |
| 17 |
[Symbol.toPrimitive]: function() { |
| 18 |
return 2n; |
| 19 |
} |
| 20 |
}, 1n, "ToPrimitive: @@toPrimitive"); |
| 21 |
assert.sameValue(({ |
| 22 |
valueOf: function() { |
| 23 |
return 2n; |
| 24 |
} |
| 25 |
}) - 1n, 1n, "ToPrimitive: valueOf"); |
| 26 |
assert.sameValue(3n - { |
| 27 |
valueOf: function() { |
| 28 |
return 2n; |
| 29 |
} |
| 30 |
}, 1n, "ToPrimitive: valueOf"); |
| 31 |
assert.sameValue(({ |
| 32 |
toString: function() { |
| 33 |
return 2n; |
| 34 |
} |
| 35 |
}) - 1n, 1n, "ToPrimitive: toString"); |
| 36 |
assert.sameValue(3n - { |
| 37 |
toString: function() { |
| 38 |
return 2n; |
| 39 |
} |
| 40 |
}, 1n, "ToPrimitive: toString"); |