summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/testIsCallable.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/jit-test/tests/ion/testIsCallable.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/ion/testIsCallable.js')
-rw-r--r--js/src/jit-test/tests/ion/testIsCallable.js134
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..ad2c54c390
--- /dev/null
+++ b/js/src/jit-test/tests/ion/testIsCallable.js
@@ -0,0 +1,134 @@
+var IsCallable = getSelfHostedValue("IsCallable");
+
+setJitCompilerOption("ion.warmup.trigger", 50);
+
+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();