diff --git a/implementation-contributed/javascriptcore/stress/bit-not-must-generate.js b/implementation-contributed/javascriptcore/stress/bit-not-must-generate.js new file mode 100644 index 0000000000000000000000000000000000000000..83fa63b6d951a112e98d380a5e380150f148acc3 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/bit-not-must-generate.js @@ -0,0 +1,26 @@ +function assert(a, e) { + if (a !== e) { + throw new Error("Bad!"); + } +} + +function foo(a) { + let loc = ~a; + return a + 2; +} +noInline(foo); + +let b = 0; +let o = { + valueOf: function () { + b++; + return 2; + } +}; + +for (let i = 0; i < 100000; i++) { + assert(foo(o), 4); +} + +assert(b, 200000) + diff --git a/implementation-contributed/javascriptcore/stress/bitwise-not-no-int32.js b/implementation-contributed/javascriptcore/stress/bitwise-not-no-int32.js new file mode 100644 index 0000000000000000000000000000000000000000..3a298133443ae47cffd3321e89c7443636ca7187 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/bitwise-not-no-int32.js @@ -0,0 +1,30 @@ +function assert(a, e, m) { + if (a !== e) + throw new Error("Expected to be: " + e + " but got: " + a); +} + +function bitNot(a) { + return ~a; +} +noInline(bitNot); + +for (let i = 0; i < 10000; i++) { + let r = bitNot("0"); + assert(r, -1); + r = bitNot("1"); + assert(r, -2); + r = bitNot("-1"); + assert(r, 0); + r = bitNot("-2"); + assert(r, 1); + + r = bitNot({ valueOf: () => 0 }); + assert(r, -1); + r = bitNot({ valueOf: () => 1 }); + assert(r, -2); + r = bitNot({ valueOf: () => -1 }); + assert(r, 0); + r = bitNot({ valueOf: () => -2 }); + assert(r, 1); +} + diff --git a/implementation-contributed/javascriptcore/stress/r238510-bad-loop.js b/implementation-contributed/javascriptcore/stress/r238510-bad-loop.js new file mode 100644 index 0000000000000000000000000000000000000000..be899b7d3e0b5d8ee0e6d70bd122339581a23086 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/r238510-bad-loop.js @@ -0,0 +1,10 @@ +function foo() { + return function () { + eval(); + } +} +noInline(foo); + +for (let i = 0; i < 100000; ++i) { + foo(); +}