From 652a8839f885b73fff57942a9db8b26e9cb5233b Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sun, 22 Oct 2023 00:55:02 +0800 Subject: fixing issues from #152. --- spec/inputs/cond.yue | 11 +++++++++++ spec/inputs/in_expression.yue | 25 ++++++------------------- spec/inputs/lists.yue | 24 +++++++++++++++++++++--- spec/inputs/tables.yue | 20 ++++++++++++++++++++ spec/inputs/unicode/cond.yue | 11 +++++++++++ spec/inputs/unicode/in_expression.yue | 21 +-------------------- 6 files changed, 70 insertions(+), 42 deletions(-) (limited to 'spec/inputs') diff --git a/spec/inputs/cond.yue b/spec/inputs/cond.yue index 638b5c3..df7d78e 100644 --- a/spec/inputs/cond.yue +++ b/spec/inputs/cond.yue @@ -226,6 +226,17 @@ do else 2 +do + condChain = 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 + + v = (x)-> + print x + x + + evaluation = v(1) < v(2) <= v(3) + + evaluation = v(1) > v(2) <= v(3) + nil diff --git a/spec/inputs/in_expression.yue b/spec/inputs/in_expression.yue index 6e923e1..6faff4e 100644 --- a/spec/inputs/in_expression.yue +++ b/spec/inputs/in_expression.yue @@ -1,28 +1,13 @@ -a^2 in {1, 2, 3} |> f - -a, b = x(...) not in [1, 3], 2 - -d = (tb.x.y ...) not in [1, 3] +-a^2 in [1, 2, 3] |> f has = "foo" in { "bar", "foo" } -if a in {1} and b in {2, 3, 4} or c in [1, 10] +if a in {1} and b in {2, 3, 4} print a, b, c -switch val - when 1, 2, 3 - print "1, 2, 3" - - when not in (0, 100] - print "not (0 < val <= 100)" - - when in [200, 300) - print "200 <= val < 300)" - - when not in {333, 444, 555} - print "not 333, 444 or 555" - -do return y not in (a, b) +if a in [1,] and b in [2, 3, 4] + print a, b, c do exist = item in list @@ -36,9 +21,11 @@ do do item = get! list = {1, 2, 3} + list = [1, 2, 3] not_exist = item not in list check item in list check item in {1, 2, 3} + check item in [1, 2, 3] check item(...) in {[1]: 1, [2]: 2, [3]: 3} do diff --git a/spec/inputs/lists.yue b/spec/inputs/lists.yue index 15eb9ab..921cae0 100644 --- a/spec/inputs/lists.yue +++ b/spec/inputs/lists.yue @@ -67,6 +67,24 @@ normal = (hello) -> test = x 1,2,3,4,5 print thing for thing in *test --> a = b for row in *rows - - +_ = -> a = b for row in *rows + +with tb + f [a] -- indexing + f [a,] -- list with one element + print v for v in *f[a,] -- table slicing in for-loop + f [] -- empty list + f[] = x -- table appending to f + [a] = x -- assign to tb[a] + [a,] = x -- list destructuring for x + [] = x -- table appending to tb + c = a in [1] -- check if a in tb[1] + c = a in [1,] -- check if a == 1 + c = a in {1} -- check if a == 1 + c = a in {1,} -- check if a == 1 + +do + [a, b] = hello + [name = "nameless", job = "jobless"] = person + +nil diff --git a/spec/inputs/tables.yue b/spec/inputs/tables.yue index 0b5af46..53a53ae 100644 --- a/spec/inputs/tables.yue +++ b/spec/inputs/tables.yue @@ -40,6 +40,8 @@ ya = { 1,2,3, key: 100, 343, "hello", umm: 232 } x = { 1,2, 4343, 343 ,343 } +x = [ 1,2, + 4343, 343 ,343 ] g, p = { 1,2, nowy: "yes", 3,4, @@ -52,6 +54,12 @@ annother = { 6,7,8 } +annother = [ + 1,2,3 + 3,4,5 + 6,7,8 +] + yeah = { [232]: 3434, "helo" ice: "cake" @@ -255,6 +263,11 @@ tbMixA = { 11 } +tbMixA = [ + ...[i for i = 1, 10] + 11 +] + tbMixB = { ... ... -- only the first item in vararg been accessed here ... {...} @@ -262,6 +275,13 @@ tbMixB = { 1, 2, 3 } +tbMixB = [ + ... ... -- only the first item in vararg been accessed here + ... {...} + ... {......} + 1, 2, 3 +] + const template = { foo: "Hello" bar: "World" diff --git a/spec/inputs/unicode/cond.yue b/spec/inputs/unicode/cond.yue index 362408c..fca6d60 100644 --- a/spec/inputs/unicode/cond.yue +++ b/spec/inputs/unicode/cond.yue @@ -226,6 +226,17 @@ do else 2 +do + 链式比较 = 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 + + 值 = (输入)-> + 打印 输入 + 输入 + + 求值 = 值(1) < 值(2) <= 值(3) + + 求值 = 值(1) > 值(2) <= 值(3) + nil diff --git a/spec/inputs/unicode/in_expression.yue b/spec/inputs/unicode/in_expression.yue index efaca47..e068cbf 100644 --- a/spec/inputs/unicode/in_expression.yue +++ b/spec/inputs/unicode/in_expression.yue @@ -1,29 +1,10 @@ -变量a^2 in {1, 2, 3} |> 函数 -变量a, 变量b = 函数x(...) not in [1, 3], 2 - -变量d = (对象.字段x.字段y ...) not in [1, 3] - 在的 = "东" in { "东", "西" } -if 变量a in {1} and 变量b in {2, 3, 4} or 变量c in [1, 10] +if 变量a in {1} and 变量b in {2, 3, 4} 打印 变量a, 变量b, 变量c -switch 值 - when 1, 2, 3 - 打印 "1, 2, 3" - - when not in (0, 100] - 打印 "非 (0 < 值 <= 100)" - - when in [200, 300) - 打印 "200 <= 值 < 300)" - - when not in {333, 444, 555} - 打印 "非 333, 444 或 555" - -do return 变量y not in (开始, 结束) - do 存在 = 元素 in 表 检查 元素 in 表 -- cgit v1.2.3-55-g6feb