diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/00_syntax/11_misc_literals | 2 | ||||
-rw-r--r-- | tests/00_syntax/16_for_loop | 32 | ||||
-rw-r--r-- | tests/00_syntax/19_arrow_functions | 6 | ||||
-rw-r--r-- | tests/02_runtime/00_scoping | 30 | ||||
-rw-r--r-- | tests/02_runtime/01_break_continue | 2 | ||||
-rw-r--r-- | tests/02_runtime/02_this | 6 | ||||
-rw-r--r-- | tests/02_runtime/05_closure_scope | 10 |
7 files changed, 44 insertions, 44 deletions
diff --git a/tests/00_syntax/11_misc_literals b/tests/00_syntax/11_misc_literals index 4b33a78..372741c 100644 --- a/tests/00_syntax/11_misc_literals +++ b/tests/00_syntax/11_misc_literals @@ -9,7 +9,7 @@ The "false" keyword represents a false boolean value: false -- End -- -- Testcase -- -{% local t = { f: function() { return this; } } %} +{% let t = { f: function() { return this; } } %} The "this" keyword refers to the current function context: {{ type(t.f()) }} The "null" keyword represents the null value: {{ "" + null }} The "true" keyword represents a true boolean value: {{ true }} diff --git a/tests/00_syntax/16_for_loop b/tests/00_syntax/16_for_loop index a16e0cc..090f87b 100644 --- a/tests/00_syntax/16_for_loop +++ b/tests/00_syntax/16_for_loop @@ -156,11 +156,11 @@ Item {{ n }} {% endfor %} For-in and counting for loops may declare variables: -{% for (local i = 0; i < 3; i++): %} +{% for (let i = 0; i < 3; i++): %} Iteration {{ i }} {% endfor %} -{% for (local n in [123, 456, 789]): %} +{% for (let n in [123, 456, 789]): %} Item {{ n }} {% endfor %} -- End -- @@ -190,25 +190,25 @@ qrx -- Testcase -- {% - local arr = [ true, false, 123, 456 ]; - local obj = { foo: true, bar: false, baz: 123, qrx: 456 }; + let arr = [ true, false, 123, 456 ]; + let obj = { foo: true, bar: false, baz: 123, qrx: 456 }; // iterating arrays with one loop variable yields the array values - for (local x in arr) + for (let x in arr) print(x, "\n"); // iterating arrays with two loop variables yields the array indexes // and their corresponding values - for (local x, y in arr) + for (let x, y in arr) print([x, y], "\n"); // iterating objects with one loop variable yields the object keys - for (local x in obj) + for (let x in obj) print(x, "\n"); // iterating objects with two loop variables yields the object keys // and their corresponding values - for (local x, y in obj) + for (let x, y in obj) print([x, y], "\n"); %} -- End -- @@ -221,7 +221,7 @@ rejected. Syntax error: Invalid for-in expression In line 2, byte 16: - ` for (local x, y, z in {})` + ` for (let x, y, z in {})` Near here --------^ @@ -229,7 +229,7 @@ In line 2, byte 16: -- Testcase -- {% - for (local x, y, z in {}) + for (let x, y, z in {}) ; %} -- End -- @@ -241,7 +241,7 @@ Ensure that assignments in for-in loop expressions are rejected. Syntax error: Invalid for-in expression In line 2, byte 15: - ` for (local x = 1, y in {})` + ` for (let x = 1, y in {})` Near here -------^ @@ -249,7 +249,7 @@ In line 2, byte 15: -- Testcase -- {% - for (local x = 1, y in {}) + for (let x = 1, y in {}) ; %} -- End -- @@ -262,7 +262,7 @@ Syntax error: Unexpected token Expecting ',' or 'in' In line 2, byte 14: - ` for (local x)` + ` for (let x)` Near here ------^ @@ -270,7 +270,7 @@ In line 2, byte 14: -- Testcase -- {% - for (local x) + for (let x) ; %} -- End -- @@ -282,7 +282,7 @@ Ensure that too short for-in loop expressions are rejected (2/2). Syntax error: Invalid for-in expression In line 2, byte 16: - ` for (local x, y)` + ` for (let x, y)` Near here --------^ @@ -290,7 +290,7 @@ In line 2, byte 16: -- Testcase -- {% - for (local x, y) + for (let x, y) ; %} -- End -- diff --git a/tests/00_syntax/19_arrow_functions b/tests/00_syntax/19_arrow_functions index 0d7aa7a..4847d8a 100644 --- a/tests/00_syntax/19_arrow_functions +++ b/tests/00_syntax/19_arrow_functions @@ -76,11 +76,11 @@ arrow function as method has no this: true {% obj = { method: function() { - local that = this; - local arr = () => { + let that = this; + let arr = () => { print("arrow function uses outher this: ", that == this, "\n"); }; - local fn = function() { + let fn = function() { print("normal function has own this: ", that != this, "\n"); }; diff --git a/tests/02_runtime/00_scoping b/tests/02_runtime/00_scoping index 5b8c040..0ac399b 100644 --- a/tests/02_runtime/00_scoping +++ b/tests/02_runtime/00_scoping @@ -1,4 +1,4 @@ -Utpl implements function scoping, make sure that local variables are +Utpl implements function scoping, make sure that let variables are invisible outside of the function scope. -- Expect stdout -- @@ -12,7 +12,7 @@ c_global=true c_local=false -When seting a nonlocal variable, it is set in the nearest parent +When seting a nonlet variable, it is set in the nearest parent scope containing the variable or in the root scope if the variable was not found. @@ -46,15 +46,15 @@ outer f_e=3 -- Testcase -- {% a_global = true; - local a_local = true; + let a_let = true; function test() { b_global = true; - local b_local = true; + let b_let = true; function test2() { c_global = true; - local c_local = true; + let c_let = true; } test2(); @@ -64,16 +64,16 @@ outer f_e=3 -%} a_global={{ !!a_global }} -a_local={{ !!a_local }} +a_local={{ !!a_let }} b_global={{ !!b_global }} -b_local={{ !!b_local }} +b_local={{ !!b_let }} c_global={{ !!c_global }} -c_local={{ !!c_local }} +c_local={{ !!c_let }} -When seting a nonlocal variable, it is set in the nearest parent +When seting a nonlet variable, it is set in the nearest parent scope containing the variable or in the root scope if the variable was not found. @@ -82,7 +82,7 @@ was not found. function scope1() { x = 2; - local y; + let y; function scope2() { // this does not set "y" in the root scope but overwrites the @@ -110,22 +110,22 @@ scoping rules. {% function scope3() { - // f_a is not declared local and be set i nthe root scope + // f_a is not declared let and be set i nthe root scope for (f_a = 1; f_a < 3; f_a++) ; - for (local f_b = 1; f_b < 3; f_b++) + for (let f_b = 1; f_b < 3; f_b++) ; - local f_c; + let f_c; function scope4() { - // f_c is not declared local but declared in the parent scope, it + // f_c is not declared let but declared in the parent scope, it // will be set there for (f_c in [1, 2, 3]) ; - for (local f_d in [1, 2, 3]) + for (let f_d in [1, 2, 3]) ; // f_e is not declared, it will be set in the root scope diff --git a/tests/02_runtime/01_break_continue b/tests/02_runtime/01_break_continue index 4616052..a27d072 100644 --- a/tests/02_runtime/01_break_continue +++ b/tests/02_runtime/01_break_continue @@ -26,7 +26,7 @@ Testing continue: -- Testcase -- Testing break: {% - local i = 0; + let i = 0; while (true) { print(" - Iteration ", i, "\n"); diff --git a/tests/02_runtime/02_this b/tests/02_runtime/02_this index e1efd80..e629853 100644 --- a/tests/02_runtime/02_this +++ b/tests/02_runtime/02_this @@ -13,7 +13,7 @@ true } // When invoked, "this" will point to the object containing the function - local o = { + let o = { test: function() { return (this === o); } @@ -34,13 +34,13 @@ true -- Testcase -- {% - local o = { + let o = { test: function() { return (this === o); } }; - local dummy = { foo: true, bar: false }; + let dummy = { foo: true, bar: false }; print(o.test(dummy.foo, dummy.bar), "\n"); print(o.test(dummy.foo, o.test(dummy.foo, dummy.bar)), "\n"); diff --git a/tests/02_runtime/05_closure_scope b/tests/02_runtime/05_closure_scope index 40f9245..c59a433 100644 --- a/tests/02_runtime/05_closure_scope +++ b/tests/02_runtime/05_closure_scope @@ -14,19 +14,19 @@ x is 3 -- Testcase -- {% - local count=0; + let count=0; function a() { - local x = ++count; + let x = ++count; print("Make function with x=", x, "\n"); return function() { print("x is ", x, "\n"); }; } - local fn1 = a(); - local fn2 = a(); - local fn3 = a(); + let fn1 = a(); + let fn2 = a(); + let fn3 = a(); fn1(); fn2(); |