summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/bound-construct-hook.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/cacheir/bound-construct-hook.js')
-rw-r--r--js/src/jit-test/tests/cacheir/bound-construct-hook.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/cacheir/bound-construct-hook.js b/js/src/jit-test/tests/cacheir/bound-construct-hook.js
new file mode 100644
index 0000000000..6d31db4192
--- /dev/null
+++ b/js/src/jit-test/tests/cacheir/bound-construct-hook.js
@@ -0,0 +1,18 @@
+function test() {
+ // Some bound callables that we're unlikely to optimize better in CacheIR.
+ var boundCtor = (new Proxy(Array, {})).bind(null, 1, 2, 3);
+ var boundNonCtor = (new Proxy(x => x + 1, {})).bind(null, 1, 2, 3);
+
+ for (var i = 0; i < 60; i++) {
+ var fun = i < 40 ? boundCtor : boundNonCtor;
+ var ex = null;
+ try {
+ var res = new fun(100, 101);
+ assertEq(JSON.stringify(res), "[1,2,3,100,101]");
+ } catch (e) {
+ ex = e;
+ }
+ assertEq(ex === null, i < 40);
+ }
+}
+test();