aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-07-26 18:05:23 +0800
committerLi Jin <dragon-fly@qq.com>2022-07-26 18:05:23 +0800
commit0f5bdeaeba0f04e49c47f4a2be55b14185a7dfdd (patch)
treeb5baa6c385ce58c60615ff0577a1e2b6850f044d /spec/inputs
parente191defb6545509a4ae0b402f2fac1fbe18551cd (diff)
downloadyuescript-0f5bdeaeba0f04e49c47f4a2be55b14185a7dfdd.tar.gz
yuescript-0f5bdeaeba0f04e49c47f4a2be55b14185a7dfdd.tar.bz2
yuescript-0f5bdeaeba0f04e49c47f4a2be55b14185a7dfdd.zip
fix missing checks and issues related to destrucuring in if branches.
Diffstat (limited to 'spec/inputs')
-rw-r--r--spec/inputs/assign.yue50
-rw-r--r--spec/inputs/cond.yue2
-rw-r--r--spec/inputs/global.yue4
-rw-r--r--spec/inputs/metatable.yue2
-rw-r--r--spec/inputs/using.yue7
5 files changed, 58 insertions, 7 deletions
diff --git a/spec/inputs/assign.yue b/spec/inputs/assign.yue
index dac2ba3..d04bcb8 100644
--- a/spec/inputs/assign.yue
+++ b/spec/inputs/assign.yue
@@ -8,20 +8,20 @@ _ = ->
8 8
9 a,b,c,d = 1,2,3,4 9 a,b,c,d = 1,2,3,4
10 10
11 hello[232], (5+5)[121], hello, x[99] = 100, 200, 300 11 hello[232], (5+5)[121], hello, x[99] = 100, 200, 300, 400
12 12
13 joop = 12 13 joop = 12
14 14
15joop = 2345 15joop = 2345
16 16
17a, b = if hello 17a, b = if hello
18 "hello" 18 "hello", nil
19else 19else
20 "nothing", "yeah" 20 "nothing", "yeah"
21 21
22 22
23a, b = if hello 23a, b = if hello
24 if yeah then "one", "two" else "mmhh" 24 if yeah then "one", "two" else "mmhh", nil
25else 25else
26 print "the other" 26 print "the other"
27 "nothing", "yeah" 27 "nothing", "yeah"
@@ -31,3 +31,47 @@ c, d = 1, 2 if true
31x = (do 31x = (do
32 f! 32 f!
33 123) if f = getHandler! 33 123) if f = getHandler!
34
35(using nil) <- _
36
37a.# = do
38 print 123
39 {}
40
41do
42 {a, b} = switch c
43 when "a"
44 tb
45 when "b"
46 f!
47
48a[] = if x
49 1
50else
51 2
52
53do
54 a, b[] = if x
55 switch y
56 when 1
57 f!
58
59do
60 a, {b} = if x
61 f!
62 else
63 123, tb
64
65do
66 a, b[], c, d.add# = if x
67 switch y
68 when 1
69 f!
70 elseif x2
71 if y2
72 f1!
73 else
74 print "hello"
75 do
76 print 123
77 1, f2!
diff --git a/spec/inputs/cond.yue b/spec/inputs/cond.yue
index 773ef91..9981e93 100644
--- a/spec/inputs/cond.yue
+++ b/spec/inputs/cond.yue
@@ -158,7 +158,7 @@ do
158---------------- 158----------------
159 159
160a = 12 160a = 12
161a,c,b = "cool" if something 161a,c,b = "cool", nil, nil if something
162 162
163 163
164 164
diff --git a/spec/inputs/global.yue b/spec/inputs/global.yue
index 7d6cfde..59cf764 100644
--- a/spec/inputs/global.yue
+++ b/spec/inputs/global.yue
@@ -1,6 +1,6 @@
1 1
2do 2do
3 global a,b,c = 223, 343 3 global a,b,c = 223, 343, nil
4 global cool = "dad" 4 global cool = "dad"
5 5
6do 6do
@@ -9,7 +9,7 @@ do
9 9
10do 10do
11 global a,b,c 11 global a,b,c
12 a,b,c,d = "hello" 12 a,b,c,d = "hello", nil, nil, nil
13 13
14 14
15do 15do
diff --git a/spec/inputs/metatable.yue b/spec/inputs/metatable.yue
index 7e9b4f2..86991c2 100644
--- a/spec/inputs/metatable.yue
+++ b/spec/inputs/metatable.yue
@@ -24,7 +24,7 @@ do
24 24
25x.abc, a.b.# = 123, {} 25x.abc, a.b.# = 123, {}
26func!.# = mt --, extra 26func!.# = mt --, extra
27a, b.c.#, d, e = 1, mt, "abc" 27a, b.c.#, d, e = 1, mt, "abc", nil
28 28
29is_same = a.#.__index == a.index# 29is_same = a.#.__index == a.index#
30 30
diff --git a/spec/inputs/using.yue b/spec/inputs/using.yue
index 9944b60..31afaab 100644
--- a/spec/inputs/using.yue
+++ b/spec/inputs/using.yue
@@ -20,3 +20,10 @@ _ = (a,e,f using a,b,c, hello) ->
20 20
21_ = (using nil) -> 21_ = (using nil) ->
22 hello or= 2 22 hello or= 2
23
24do
25 a = {}
26 (using nil) <- _
27 {x, y} = a
28
29nil