aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-06-30 18:48:20 +0800
committerLi Jin <dragon-fly@qq.com>2023-06-30 18:48:20 +0800
commit85a2da5cbbbbfb27f3b65ac67d083dd2443d223d (patch)
tree25ab99912ebf9a26f5c11f09518b47509d750b36 /spec
parentef64f6d54bfc25c35e9d3044e324c9a3da7c2b94 (diff)
downloadyuescript-85a2da5cbbbbfb27f3b65ac67d083dd2443d223d.tar.gz
yuescript-85a2da5cbbbbfb27f3b65ac67d083dd2443d223d.tar.bz2
yuescript-85a2da5cbbbbfb27f3b65ac67d083dd2443d223d.zip
support list table checking to in-expression for issue #140
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/in_expression.yue17
-rw-r--r--spec/outputs/in_expression.lua85
2 files changed, 102 insertions, 0 deletions
diff --git a/spec/inputs/in_expression.yue b/spec/inputs/in_expression.yue
index dacf820..66a8215 100644
--- a/spec/inputs/in_expression.yue
+++ b/spec/inputs/in_expression.yue
@@ -24,5 +24,22 @@ switch val
24 24
25do return y not in (a, b) 25do return y not in (a, b)
26 26
27do
28 exist = item in list
29 check item in list
30
31do
32 item = get!
33 exist = item in list
34 check item in list
35
36do
37 item = get!
38 list = {1, 2, 3}
39 exist = item in list
40 check item in list
41 check item in {1, 2, 3}
42 check item in {[1]: 1, [2]: 2, [3]: 3}
43
27nil 44nil
28 45
diff --git a/spec/outputs/in_expression.lua b/spec/outputs/in_expression.lua
index 8b37a72..41ae87e 100644
--- a/spec/outputs/in_expression.lua
+++ b/spec/outputs/in_expression.lua
@@ -38,4 +38,89 @@ do
38 local _val_0 = y 38 local _val_0 = y
39 return not (a < _val_0 and _val_0 < b) 39 return not (a < _val_0 and _val_0 < b)
40end 40end
41do
42 local exist
43 do
44 local _check_0 = list
45 local _val_0 = item
46 local _find_0 = false
47 for _index_0 = 1, #_check_0 do
48 local _item_0 = _check_0[_index_0]
49 if _item_0 == _val_0 then
50 _find_0 = true
51 break
52 end
53 end
54 exist = _find_0
55 end
56 check((function()
57 local _check_0 = list
58 local _val_0 = item
59 for _index_0 = 1, #_check_0 do
60 if _check_0[_index_0] == _val_0 then
61 return true
62 end
63 end
64 return false
65 end)())
66end
67do
68 local item = get()
69 local exist = (function()
70 local _check_0 = list
71 for _index_0 = 1, #_check_0 do
72 if _check_0[_index_0] == item then
73 return true
74 end
75 end
76 return false
77 end)()
78 check((function()
79 local _check_0 = list
80 for _index_0 = 1, #_check_0 do
81 if _check_0[_index_0] == item then
82 return true
83 end
84 end
85 return false
86 end)())
87end
88do
89 local item = get()
90 local list = {
91 1,
92 2,
93 3
94 }
95 local exist = (#list > 0 and (function()
96 for _index_0 = 1, #list do
97 if list[_index_0] == item then
98 return true
99 end
100 end
101 return false
102 end)())
103 check((#list > 0 and (function()
104 for _index_0 = 1, #list do
105 if list[_index_0] == item then
106 return true
107 end
108 end
109 return false
110 end)()))
111 check((1 == item or 2 == item or 3 == item))
112 check((function()
113 local _check_0 = {
114 [1] = 1,
115 [2] = 2,
116 [3] = 3
117 }
118 for _index_0 = 1, #_check_0 do
119 if _check_0[_index_0] == item then
120 return true
121 end
122 end
123 return false
124 end)())
125end
41return nil 126return nil