Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/unary-minus/bigint-non-primitive.js

raw
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 /*---
5 description: Unary minus for BigInt object wrappers
6 esid: sec-unary-minus-operator-runtime-semantics-evaluation
7 info: |
8 Runtime Semantics: Evaluation
9 UnaryExpression : - UnaryExpression
10
11 1. Let expr be the result of evaluating UnaryExpression.
12 2. Let oldValue be ? ToNumeric(? GetValue(expr)).
13 3. Let T be Type(oldValue).
14 4. Return ? T::unaryMinus(oldValue).
15
16 features: [BigInt, Symbol.toPrimitive]
17 ---*/
18
19 assert.sameValue(-Object(1n), -1n, "-Object(1n) === -1n");
20 assert.notSameValue(-Object(1n), 1n, "-Object(1n) !== 1n");
21 assert.notSameValue(-Object(1n), Object(-1n), "-Object(1n) !== Object(-1n)");
22 assert.sameValue(-Object(-1n), 1n, "-Object(-1n) === 1n");
23 assert.notSameValue(-Object(-1n), -1n, "-Object(-1n) !== -1n");
24 assert.notSameValue(-Object(-1n), Object(1n), "-Object(-1n) !== Object(1n)");
25 assert.sameValue(
26 -{[Symbol.toPrimitive]: function() { return 1n; }, valueOf: function() { $ERROR(); }, toString: function() { $ERROR(); }}, -1n,
27 "-{[Symbol.toPrimitive]: function() { return 1n; }, valueOf: function() { $ERROR(); }, toString: function() { $ERROR(); }} === -1n");
28 assert.sameValue(
29 -{valueOf: function() { return 1n; }, toString: function() { $ERROR(); }}, -1n,
30 "-{valueOf: function() { return 1n; }, toString: function() { $ERROR(); }} === -1n");
31 assert.sameValue(
32 -{toString: function() { return 1n; }}, -1n,
33 "-{toString: function() { return 1n; }} === -1n");