test262/implementation-contributed/javascriptcore/stress/big-int-less-than-order-of-evaluation.js
test262-automation e9a5a7f918 [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time) (#1620)
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
2018-07-03 15:59:58 -04:00

56 lines
1012 B
JavaScript

//@ runBigIntEnabled
function assert(v, e, m) {
if (v !== e)
throw new Error(m);
}
let o = {
[Symbol.toPrimitive]: function() {
throw new Error("Calling @toPrimitive");
}
}
try {
o < Symbol(2);
assert(true, false, "")
} catch(e) {
assert(e.message, "Calling @toPrimitive", "Bad Exception when object is left operand");
}
try {
Symbol(2) < o;
assert(true, false, "")
} catch(e) {
assert(e instanceof TypeError, true, "Bad Exception when Symbol is left operand");
}
o = {
[Symbol.toPrimitive]: function() {
return 2n;
},
toString: function() {
throw new Error("Should never call toString");
},
valueOf: function() {
throw new Error("Should never call valueOf");
}
}
assert(o < 3n, true, "ToPrimitive(2n) < 3n");
o = {
toString: function() {
throw new Error("Should never call toString");
},
valueOf: function() {
return 2n;
}
}
assert(o < 3n, true, "valueOf(2n) < 3n");