mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 22:40:28 +02:00
* [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)
56 lines
1012 B
JavaScript
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");
|
|
|