diff options
| author | Li Jin <dragon-fly@qq.com> | 2024-02-05 10:27:47 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2024-02-05 10:27:47 +0800 |
| commit | ef0ff9c4c523980d71e49d65e8db57d670daf85c (patch) | |
| tree | bfe36110dbb6a11b15464168bc8f872c1678eac3 /spec | |
| parent | 5dcfab2ee3bd686ec78de360a09987d916c02b36 (diff) | |
| download | yuescript-ef0ff9c4c523980d71e49d65e8db57d670daf85c.tar.gz yuescript-ef0ff9c4c523980d71e49d65e8db57d670daf85c.tar.bz2 yuescript-ef0ff9c4c523980d71e49d65e8db57d670daf85c.zip | |
fix more invalid in-expression use cases.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/inputs/in_expression.yue | 39 | ||||
| -rw-r--r-- | spec/outputs/in_expression.lua | 49 |
2 files changed, 88 insertions, 0 deletions
diff --git a/spec/inputs/in_expression.yue b/spec/inputs/in_expression.yue index 6faff4e..7ee0816 100644 --- a/spec/inputs/in_expression.yue +++ b/spec/inputs/in_expression.yue | |||
| @@ -35,5 +35,44 @@ do | |||
| 35 | check -> return x in tb | 35 | check -> return x in tb |
| 36 | check -> x not in tb | 36 | check -> x not in tb |
| 37 | 37 | ||
| 38 | do | ||
| 39 | f1 = -> | ||
| 40 | a = 2 | ||
| 41 | a in [ | ||
| 42 | 1 | ||
| 43 | 2 | ||
| 44 | 3 | ||
| 45 | 4 | ||
| 46 | ] | ||
| 47 | f2 = -> | ||
| 48 | a not in [ | ||
| 49 | 1 | ||
| 50 | 2 | ||
| 51 | 3 | ||
| 52 | 4 | ||
| 53 | ] | ||
| 54 | f3 = -> | ||
| 55 | a = 2 | ||
| 56 | a in { b, c, d | ||
| 57 | e, f | ||
| 58 | g | ||
| 59 | } | ||
| 60 | f4 = -> | ||
| 61 | a = 2 | ||
| 62 | b = a in [ 1, 2 | ||
| 63 | 3, 4 | ||
| 64 | ] | ||
| 65 | f5 = -> | ||
| 66 | a = 2 | ||
| 67 | return a in [ 1, 2 | ||
| 68 | 3, 4 | ||
| 69 | ] | ||
| 70 | f6 = -> | ||
| 71 | b = a not in { | ||
| 72 | 1 | ||
| 73 | 2 | ||
| 74 | x: 3 | ||
| 75 | } | ||
| 76 | |||
| 38 | nil | 77 | nil |
| 39 | 78 | ||
diff --git a/spec/outputs/in_expression.lua b/spec/outputs/in_expression.lua index 04c08e7..afcc030 100644 --- a/spec/outputs/in_expression.lua +++ b/spec/outputs/in_expression.lua | |||
| @@ -162,4 +162,53 @@ do | |||
| 162 | return true | 162 | return true |
| 163 | end) | 163 | end) |
| 164 | end | 164 | end |
| 165 | do | ||
| 166 | local f1 | ||
| 167 | f1 = function() | ||
| 168 | local a = 2 | ||
| 169 | return (1 == a or 2 == a or 3 == a or 4 == a) | ||
| 170 | end | ||
| 171 | local f2 | ||
| 172 | f2 = function() | ||
| 173 | local _val_0 = a | ||
| 174 | return not (1 == _val_0 or 2 == _val_0 or 3 == _val_0 or 4 == _val_0) | ||
| 175 | end | ||
| 176 | local f3 | ||
| 177 | f3 = function() | ||
| 178 | local a = 2 | ||
| 179 | return (b == a or c == a or d == a or e == a or f == a or g == a) | ||
| 180 | end | ||
| 181 | local f4 | ||
| 182 | f4 = function() | ||
| 183 | local a = 2 | ||
| 184 | local b | ||
| 185 | b = (1 == a or 2 == a or 3 == a or 4 == a) | ||
| 186 | end | ||
| 187 | local f5 | ||
| 188 | f5 = function() | ||
| 189 | local a = 2 | ||
| 190 | return (1 == a or 2 == a or 3 == a or 4 == a) | ||
| 191 | end | ||
| 192 | local f6 | ||
| 193 | f6 = function() | ||
| 194 | local b | ||
| 195 | do | ||
| 196 | local _check_0 = { | ||
| 197 | 1, | ||
| 198 | 2, | ||
| 199 | x = 3 | ||
| 200 | } | ||
| 201 | local _val_0 = a | ||
| 202 | local _find_0 = false | ||
| 203 | for _index_0 = 1, #_check_0 do | ||
| 204 | local _item_0 = _check_0[_index_0] | ||
| 205 | if _item_0 == _val_0 then | ||
| 206 | _find_0 = true | ||
| 207 | break | ||
| 208 | end | ||
| 209 | end | ||
| 210 | b = not _find_0 | ||
| 211 | end | ||
| 212 | end | ||
| 213 | end | ||
| 165 | return nil | 214 | return nil |
