diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/basic/constant-folding-1.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/basic/constant-folding-1.js')
-rw-r--r-- | js/src/jit-test/tests/basic/constant-folding-1.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/constant-folding-1.js b/js/src/jit-test/tests/basic/constant-folding-1.js new file mode 100644 index 000000000..5bcb73b13 --- /dev/null +++ b/js/src/jit-test/tests/basic/constant-folding-1.js @@ -0,0 +1,43 @@ +function bytecode(f) { + if (typeof disassemble !== "function") + return "unavailable"; + var d = disassemble(f); + return d.slice(d.indexOf("main:"), d.indexOf("\n\n")); +} +assertEq(bytecode(() => "hello" + "world"), + bytecode(() => "helloworld")); +assertEq(bytecode(() => 2 + "2" + "2"), + bytecode(() => "222")); +assertEq(bytecode(() => "x" + "3"), + bytecode(() => "x3")); + +var s = "hoge"; +assertEq(bytecode(() => "fo" + "o" + s + "ba" + "r"), + bytecode(() => "foo" + s + "bar")); +assertEq(bytecode(() => "fo" + "o" + 1 + s + 1 + "ba" + "r"), + bytecode(() => "foo1" + s + "1bar")); +assertEq(bytecode(() => 1 + (2 * 2) + "x"), + bytecode(() => 5 + "x")); +assertEq(s + 1 + 2, "hoge12"); +assertEq((() => s + 1 + 2)(), "hoge12"); + +// SpiderMonkey knows that 1 + 1 == "11". +assertEq(bytecode(() => "x" + s + 1 + 1), + bytecode(() => "x" + s + "11")); + +var n = 5; +assertEq(1 + n + 1 + "ba" + "r", "7bar"); +assertEq(1 + 2 + {valueOf: () => 3, toString: () => 'x'} + 4 + 5,15); +assertEq(1+2+n,8); +assertEq(bytecode(() => 1 + 2 + n + 1 + 2), + bytecode(() => 3 + n + 1 + 2)); +assertEq(1 + 2 + n + 1 + 2, 11); +assertEq(bytecode(() => 1 + 2 + s + 1 + 2), + bytecode(() => 3 + s + 1 + 2)); +assertEq(1 + 2 + s + 1 + 2, "3hoge12"); + +assertEq(bytecode(() => ["a" + "b" + n]), + bytecode(() => ["ab" + n])); +var a = ["a" + "b" + n]; +assertEq(a[0], "ab5"); + |