more vm tests

This commit is contained in:
2026-02-05 10:44:53 -06:00
parent b38aec95b6
commit aacb0b48bf
72 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1 @@
var f = (x = 10) => x; f()

View File

@@ -0,0 +1 @@
var f = () => 42; f()

1
vm_test/assign_add.txt Normal file
View File

@@ -0,0 +1 @@
var x = 5; x += 3; x

1
vm_test/assign_and.txt Normal file
View File

@@ -0,0 +1 @@
var x = 7; x &= 3; x

1
vm_test/assign_div.txt Normal file
View File

@@ -0,0 +1 @@
var x = 6; x /= 2; x

1
vm_test/assign_land.txt Normal file
View File

@@ -0,0 +1 @@
var x = 5; x &&= 10; x

1
vm_test/assign_lor.txt Normal file
View File

@@ -0,0 +1 @@
var x = 0; x ||= 10; x

1
vm_test/assign_mod.txt Normal file
View File

@@ -0,0 +1 @@
var x = 7; x %= 3; x

1
vm_test/assign_mul.txt Normal file
View File

@@ -0,0 +1 @@
var x = 5; x *= 3; x

View File

@@ -0,0 +1 @@
var x = null; x ??= 10; x

1
vm_test/assign_or.txt Normal file
View File

@@ -0,0 +1 @@
var x = 5; x |= 2; x

1
vm_test/assign_power.txt Normal file
View File

@@ -0,0 +1 @@
var x = 2; x **= 3; x

1
vm_test/assign_shl.txt Normal file
View File

@@ -0,0 +1 @@
var x = 2; x <<= 3; x

1
vm_test/assign_shr.txt Normal file
View File

@@ -0,0 +1 @@
var x = 8; x >>= 2; x

1
vm_test/assign_shru.txt Normal file
View File

@@ -0,0 +1 @@
var x = -8; x >>>= 2; x

1
vm_test/assign_sub.txt Normal file
View File

@@ -0,0 +1 @@
var x = 5; x -= 3; x

1
vm_test/assign_xor.txt Normal file
View File

@@ -0,0 +1 @@
var x = 5; x ^= 3; x

View File

@@ -0,0 +1 @@
var x, y; x = y = 5; x + y

View File

@@ -0,0 +1 @@
/* comment */ 5

View File

@@ -0,0 +1 @@
1 /* a */ + /* b */ 2

View File

@@ -0,0 +1 @@
;;; 5

1
vm_test/func_expr.txt Normal file
View File

@@ -0,0 +1 @@
var f = function(x) { return x * 2 }; f(3)

1
vm_test/func_iife.txt Normal file
View File

@@ -0,0 +1 @@
(function(x) { return x * 2 })(5)

View File

@@ -0,0 +1 @@
function fac(n) { if (n <= 1) return 1; return n * fac(n - 1) }; fac(5)

1
vm_test/label_break.txt Normal file
View File

@@ -0,0 +1 @@
var x = 0; outer: { x = 1; break outer; x = 2 }; x

View File

@@ -0,0 +1 @@
var s = 0; outer: for (var i = 0; i < 3; i++) { for (var j = 0; j < 3; j++) { if (j == 1) continue outer; s = s + 1 } }; s

1
vm_test/multi_var.txt Normal file
View File

@@ -0,0 +1 @@
var x = 1, y = 2; x + y

1
vm_test/nested_block.txt Normal file
View File

@@ -0,0 +1 @@
var x = 1; { var y = 2; { var z = 3; x = x + y + z } }; x

1
vm_test/num_binary.txt Normal file
View File

@@ -0,0 +1 @@
0b1010

1
vm_test/num_exp.txt Normal file
View File

@@ -0,0 +1 @@
1e3

1
vm_test/num_float.txt Normal file
View File

@@ -0,0 +1 @@
3.14

1
vm_test/num_hex.txt Normal file
View File

@@ -0,0 +1 @@
0xff

1
vm_test/num_octal.txt Normal file
View File

@@ -0,0 +1 @@
0o17

View File

@@ -0,0 +1 @@
1_000_000

View File

@@ -0,0 +1 @@
~5

View File

@@ -0,0 +1 @@
5 | 2

View File

@@ -0,0 +1 @@
5 ^ 3

1
vm_test/op_comma.txt Normal file
View File

@@ -0,0 +1 @@
(1, 2, 3)

View File

@@ -0,0 +1 @@
3 == 3

View File

@@ -0,0 +1 @@
5 >= 5

View File

@@ -0,0 +1 @@
3 < 5

View File

@@ -0,0 +1 @@
3 <= 3

View File

@@ -0,0 +1 @@
3 != 4

View File

@@ -0,0 +1 @@
var x = 5; x--; x

View File

@@ -0,0 +1 @@
var x = 5; --x

1
vm_test/op_delete.txt Normal file
View File

@@ -0,0 +1 @@
var o = {x: 1}; delete o.x; o.x

1
vm_test/op_in.txt Normal file
View File

@@ -0,0 +1 @@
var o = {x: 1}; "x" in o

View File

@@ -0,0 +1 @@
var x = 5; x++; x

View File

@@ -0,0 +1 @@
var x = 5; ++x

View File

@@ -0,0 +1 @@
!false

View File

@@ -0,0 +1 @@
false || true

1
vm_test/op_nullish.txt Normal file
View File

@@ -0,0 +1 @@
null ?? 5

1
vm_test/op_power.txt Normal file
View File

@@ -0,0 +1 @@
2 ** 3

View File

@@ -0,0 +1 @@
2 << 3

View File

@@ -0,0 +1 @@
8 >> 2

View File

@@ -0,0 +1 @@
-8 >>> 2

1
vm_test/op_typeof.txt Normal file
View File

@@ -0,0 +1 @@
typeof 5

View File

@@ -0,0 +1 @@
-5

View File

@@ -0,0 +1 @@
+"5"

1
vm_test/op_void.txt Normal file
View File

@@ -0,0 +1 @@
void 0

View File

@@ -0,0 +1 @@
var o = {a: 1}; o?.["a"]

View File

@@ -0,0 +1 @@
var o = {f: () => 1}; o.f?.()

View File

@@ -0,0 +1 @@
var o = null; o?.a

View File

@@ -0,0 +1 @@
var o = {a: 1}; o?.a

View File

@@ -0,0 +1 @@
(1 + 2) * 3

1
vm_test/record_chain.txt Normal file
View File

@@ -0,0 +1 @@
var o = {a: {b: {c: 1}}}; o.a.b.c

View File

@@ -0,0 +1 @@
var o = {a: {b: 1}}; o.a.b

View File

@@ -0,0 +1 @@
var o = {1: "one"}; o[1]

View File

@@ -0,0 +1 @@
"hello\nworld"

View File

@@ -0,0 +1 @@
"\u0041"

View File

@@ -0,0 +1 @@
var x = 1; try { throw 0 } catch(e) { x = 2 } finally { x = x + 1 }; x

1
vm_test/try_finally.txt Normal file
View File

@@ -0,0 +1 @@
var x = 1; try { x = 2 } finally { x = 3 }; x