vm unit tests
This commit is contained in:
1
vm_test/arrow_block.txt
Normal file
1
vm_test/arrow_block.txt
Normal file
@@ -0,0 +1 @@
|
||||
var f = x => { return x }; f(1)
|
||||
1
vm_test/arrow_expr.txt
Normal file
1
vm_test/arrow_expr.txt
Normal file
@@ -0,0 +1 @@
|
||||
var f = x => x * 2; f(5)
|
||||
1
vm_test/arrow_multi.txt
Normal file
1
vm_test/arrow_multi.txt
Normal file
@@ -0,0 +1 @@
|
||||
var f = (a, b) => a + b; f(2, 3)
|
||||
1
vm_test/closure_basic.txt
Normal file
1
vm_test/closure_basic.txt
Normal file
@@ -0,0 +1 @@
|
||||
var f = function(x) { return function() { return x } }; f(5)()
|
||||
11
vm_test/closure_mutate.txt
Normal file
11
vm_test/closure_mutate.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
var counter = function() {
|
||||
var n = 0
|
||||
return function() {
|
||||
n = n + 1
|
||||
return n
|
||||
}
|
||||
}
|
||||
var c = counter()
|
||||
c()
|
||||
c()
|
||||
c()
|
||||
1
vm_test/def_basic.txt
Normal file
1
vm_test/def_basic.txt
Normal file
@@ -0,0 +1 @@
|
||||
def x = 5; x
|
||||
1
vm_test/for_basic.txt
Normal file
1
vm_test/for_basic.txt
Normal file
@@ -0,0 +1 @@
|
||||
var s = 0; for (var i = 0; i < 3; i++) s = s + i; s
|
||||
2
vm_test/go_basic.txt
Normal file
2
vm_test/go_basic.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
function a() { go b() }
|
||||
function b() { 1 }
|
||||
2
vm_test/go_method.txt
Normal file
2
vm_test/go_method.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
var o = {m: function() { 1 }}
|
||||
function f() { go o.m() }
|
||||
1
vm_test/if_basic.txt
Normal file
1
vm_test/if_basic.txt
Normal file
@@ -0,0 +1 @@
|
||||
var x = 0; if (true) x = 1; x
|
||||
1
vm_test/if_else.txt
Normal file
1
vm_test/if_else.txt
Normal file
@@ -0,0 +1 @@
|
||||
if (false) 1 else 2
|
||||
1
vm_test/op_arith.txt
Normal file
1
vm_test/op_arith.txt
Normal file
@@ -0,0 +1 @@
|
||||
1 + 2 * 3
|
||||
1
vm_test/op_bitwise.txt
Normal file
1
vm_test/op_bitwise.txt
Normal file
@@ -0,0 +1 @@
|
||||
5 & 3
|
||||
1
vm_test/op_compare.txt
Normal file
1
vm_test/op_compare.txt
Normal file
@@ -0,0 +1 @@
|
||||
5 > 3
|
||||
1
vm_test/op_logical.txt
Normal file
1
vm_test/op_logical.txt
Normal file
@@ -0,0 +1 @@
|
||||
true && false
|
||||
1
vm_test/op_ternary.txt
Normal file
1
vm_test/op_ternary.txt
Normal file
@@ -0,0 +1 @@
|
||||
true ? 1 : 2
|
||||
1
vm_test/record_bracket.txt
Normal file
1
vm_test/record_bracket.txt
Normal file
@@ -0,0 +1 @@
|
||||
var a = {x: 1}; a["x"]
|
||||
1
vm_test/record_computed.txt
Normal file
1
vm_test/record_computed.txt
Normal file
@@ -0,0 +1 @@
|
||||
var k = "x"; var a = {x: 1}; a[k]
|
||||
1
vm_test/record_dot.txt
Normal file
1
vm_test/record_dot.txt
Normal file
@@ -0,0 +1 @@
|
||||
var a = {x: 1}; a.x
|
||||
1
vm_test/record_object_key.txt
Normal file
1
vm_test/record_object_key.txt
Normal file
@@ -0,0 +1 @@
|
||||
var k = {}; var a = {}; a[k] = 1; a[k]
|
||||
1
vm_test/record_this.txt
Normal file
1
vm_test/record_this.txt
Normal file
@@ -0,0 +1 @@
|
||||
var o = {v: 1, f: function() { return this.v }}; o.f()
|
||||
1
vm_test/regex_flags.txt
Normal file
1
vm_test/regex_flags.txt
Normal file
@@ -0,0 +1 @@
|
||||
/hello/i
|
||||
1
vm_test/regex_literal.txt
Normal file
1
vm_test/regex_literal.txt
Normal file
@@ -0,0 +1 @@
|
||||
/hello/
|
||||
1
vm_test/shorthand_method.txt
Normal file
1
vm_test/shorthand_method.txt
Normal file
@@ -0,0 +1 @@
|
||||
{double(x) { return x + x }}
|
||||
1
vm_test/shorthand_prop.txt
Normal file
1
vm_test/shorthand_prop.txt
Normal file
@@ -0,0 +1 @@
|
||||
var x = 1; var y = 2; {x, y}
|
||||
1
vm_test/switch_basic.txt
Normal file
1
vm_test/switch_basic.txt
Normal file
@@ -0,0 +1 @@
|
||||
var r; switch(2) { case 1: r = 1; break; case 2: r = 2; break }; r
|
||||
1
vm_test/template_basic.txt
Normal file
1
vm_test/template_basic.txt
Normal file
@@ -0,0 +1 @@
|
||||
var x = 5; `value: ${x}`
|
||||
1
vm_test/try_catch.txt
Normal file
1
vm_test/try_catch.txt
Normal file
@@ -0,0 +1 @@
|
||||
try { 1 } catch(e) { 2 }
|
||||
1
vm_test/try_throw.txt
Normal file
1
vm_test/try_throw.txt
Normal file
@@ -0,0 +1 @@
|
||||
try { throw "err" } catch(e) { e }
|
||||
1
vm_test/var_basic.txt
Normal file
1
vm_test/var_basic.txt
Normal file
@@ -0,0 +1 @@
|
||||
var x = 5; x
|
||||
1
vm_test/var_block.txt
Normal file
1
vm_test/var_block.txt
Normal file
@@ -0,0 +1 @@
|
||||
var x = 1; { var x = 2 }; x
|
||||
1
vm_test/var_reassign.txt
Normal file
1
vm_test/var_reassign.txt
Normal file
@@ -0,0 +1 @@
|
||||
var x = 5; x = 10; x
|
||||
1
vm_test/while_basic.txt
Normal file
1
vm_test/while_basic.txt
Normal file
@@ -0,0 +1 @@
|
||||
var i = 0; while (i < 3) i = i + 1; i
|
||||
Reference in New Issue
Block a user