summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/asm.js/testBug1147144-2.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/asm.js/testBug1147144-2.js')
-rw-r--r--js/src/jit-test/tests/asm.js/testBug1147144-2.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/asm.js/testBug1147144-2.js b/js/src/jit-test/tests/asm.js/testBug1147144-2.js
new file mode 100644
index 0000000000..b5b6a45958
--- /dev/null
+++ b/js/src/jit-test/tests/asm.js/testBug1147144-2.js
@@ -0,0 +1,17 @@
+// |jit-test| skip-if: !isAsmJSCompilationAvailable()||!Function.prototype.toSource
+
+function test() {
+load(libdir + 'asm.js');
+load(libdir + 'asserts.js');
+
+assertEq(eval(`(function asmModule() { "use asm"; function asmFun() {} return asmFun })`).toSource(), "(function asmModule() {\n [native code]\n})");
+assertEq(eval(`(function asmModule() { "use asm"; function asmFun() {} return asmFun })`)().toSource(), "function asmFun() {\n [native code]\n}");
+assertEq((evaluate(`function asmModule2() { "use asm"; function asmFun() {} return asmFun }`), asmModule2).toSource(), "function asmModule2() {\n [native code]\n}");
+assertEq((evaluate(`function asmModule4() { "use asm"; function asmFun() {} return asmFun }`), asmModule4)().toSource(), "function asmFun() {\n [native code]\n}");
+assertEq(asmCompile(USE_ASM + `function asmFun() {} return asmFun`).toSource(), "(function anonymous() {\n [native code]\n})");
+assertEq(asmCompile(USE_ASM + `function asmFun() {} return asmFun`)().toSource(), "function asmFun() {\n [native code]\n}");
+}
+
+var g = newGlobal({ discardSource: true });
+g.libdir = libdir;
+g.evaluate(test.toString() + "test()");