summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/hasnativemethodpure-optimization.js
blob: 2f5e99186466555474073786f1e4f94cbbcde308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
load(libdir + "asserts.js");

let string = Object.defineProperty(new String("123"), "valueOf", {
    get: function() { throw "get-valueOf"; }
});
assertThrowsValue(() => "" + string, "get-valueOf");

string = Object.defineProperty(new String("123"), "toString", {
    get: function() { throw "get-toString"; }
});
assertThrowsValue(() => string.toLowerCase(), "get-toString");

string = Object.defineProperty(new String("123"), Symbol.toPrimitive, {
    get: function() { throw "get-toPrimitive"; }
});
assertThrowsValue(() => string.toLowerCase(), "get-toPrimitive");

let number = Object.defineProperty(new Number(123), "valueOf", {
    get: function() { throw "get-valueOf"; }
});
assertThrowsValue(() => +number, "get-valueOf");