diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/ion/testIsCallable.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/jit-test/tests/ion/testIsCallable.js | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/testIsCallable.js b/js/src/jit-test/tests/ion/testIsCallable.js new file mode 100644 index 0000000000..ace8cffa14 --- /dev/null +++ b/js/src/jit-test/tests/ion/testIsCallable.js @@ -0,0 +1,134 @@ +// |jit-test| --ion-warmup-threshold=50 + +var IsCallable = getSelfHostedValue("IsCallable"); + +function testSinglePrimitive() { + var f1 = function() { assertEq(IsCallable(undefined), false); }; + do { f1(); } while (!inIon()); + + var f2 = function() { assertEq(IsCallable(null), false); }; + do { f2(); } while (!inIon()); + + var f3 = function() { assertEq(IsCallable(true), false); }; + do { f3(); } while (!inIon()); + + var f4 = function() { assertEq(IsCallable(1), false); }; + do { f4(); } while (!inIon()); + + var f5 = function() { assertEq(IsCallable(1.2), false); }; + do { f5(); } while (!inIon()); + + var f6 = function() { assertEq(IsCallable("foo"), false); }; + do { f6(); } while (!inIon()); + + var f7 = function() { assertEq(IsCallable(Symbol.iterator), false); }; + do { f7(); } while (!inIon()); +} +testSinglePrimitive(); + +function testMixedPrimitive() { + var list = [ + undefined, + null, + true, + 1, + 1.2, + "foo", + Symbol.iterator, + ]; + + var f1 = function() { + for (let x of list) { + assertEq(IsCallable(x), false); + } + }; + do { f1(); } while (!inIon()); +} +testMixedPrimitive(); + +function testSingleObject() { + var obj = []; + var arr = []; + + var f1 = function() { assertEq(IsCallable(obj), false); }; + do { f1(); } while (!inIon()); + + var f2 = function() { assertEq(IsCallable(arr), false); }; + do { f2(); } while (!inIon()); +} +testSingleObject(); + +function testMixedPrimitiveAndObject() { + var list = [ + undefined, + null, + true, + 1, + 1.2, + "foo", + Symbol.iterator, + + {}, + [], + ]; + + var f1 = function() { + for (let x of list) { + assertEq(IsCallable(x), false); + } + }; + do { f1(); } while (!inIon()); +} +testMixedPrimitiveAndObject(); + +function testFunction() { + var f1 = function() { assertEq(IsCallable(Function), true); }; + do { f1(); } while (!inIon()); + + var f2 = function() { assertEq(IsCallable(parseInt), true); }; + do { f2(); } while (!inIon()); +} +testFunction(); + +function testProxy() { + var p1 = new Proxy({}, {}); + var f1 = function() { assertEq(IsCallable(p1), false); }; + do { f1(); } while (!inIon()); + + var p2 = new Proxy(function() {}, {}); + var f2 = function() { assertEq(IsCallable(p2), true); }; + do { f2(); } while (!inIon()); +} +testProxy(); + +function testMixed() { + var p1 = new Proxy({}, {}); + var p2 = new Proxy(function() {}, {}); + + var list = [ + [undefined, false], + [null, false], + [true, false], + [1, false], + [1.2, false], + ["foo", false], + [Symbol.iterator, false], + + [{}, false], + [[], false], + + [Function, true], + [parseInt, true], + + [p1, false], + [p2, true], + ]; + + var f1 = function() { + for (let [x, expected] of list) { + assertEq(IsCallable(x), expected); + } + }; + do { f1(); } while (!inIon()); +} +testMixed(); |