diff options
author | Li Jin <dragon-fly@qq.com> | 2022-07-24 22:13:08 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-07-24 22:13:08 +0800 |
commit | 303834e1b1e6cd9cae64b66c2ae44dcd7185238f (patch) | |
tree | 519f6a1debcc5791d35e06dc5cbb1ce22f9cfd31 /spec/inputs | |
parent | eb367126bf3a4f5b0e51ccef93b7c7136bea170e (diff) | |
download | yuescript-303834e1b1e6cd9cae64b66c2ae44dcd7185238f.tar.gz yuescript-303834e1b1e6cd9cae64b66c2ae44dcd7185238f.tar.bz2 yuescript-303834e1b1e6cd9cae64b66c2ae44dcd7185238f.zip |
add option --target=5.1 to generate Lua 5.1 compatible codes. add const destructure. make import item const by default.
Diffstat (limited to 'spec/inputs')
-rw-r--r-- | spec/inputs/destructure.yue | 5 | ||||
-rw-r--r-- | spec/inputs/export.yue | 4 | ||||
-rw-r--r-- | spec/inputs/import.yue | 2 | ||||
-rw-r--r-- | spec/inputs/macro.yue | 2 | ||||
-rw-r--r-- | spec/inputs/metatable.yue | 2 | ||||
-rw-r--r-- | spec/inputs/syntax.yue | 10 | ||||
-rw-r--r-- | spec/inputs/tables.yue | 8 | ||||
-rw-r--r-- | spec/inputs/with.yue | 2 |
8 files changed, 19 insertions, 16 deletions
diff --git a/spec/inputs/destructure.yue b/spec/inputs/destructure.yue index 3007adf..24282c0 100644 --- a/spec/inputs/destructure.yue +++ b/spec/inputs/destructure.yue | |||
@@ -11,7 +11,7 @@ do | |||
11 | 11 | ||
12 | {:a,:b,:c,:d} = yeah | 12 | {:a,:b,:c,:d} = yeah |
13 | 13 | ||
14 | {a} = one, two | 14 | {a}, b = one, two |
15 | {b}, c = one | 15 | {b}, c = one |
16 | {d}, e = one, two | 16 | {d}, e = one, two |
17 | 17 | ||
@@ -184,3 +184,6 @@ do | |||
184 | do | 184 | do |
185 | {x: a.b = 1, y: a.c = 2} = x.x.x | 185 | {x: a.b = 1, y: a.c = 2} = x.x.x |
186 | 186 | ||
187 | do | ||
188 | const :width, :height = View.size | ||
189 | const {:x = 0.0, :y = 0.0} = point | ||
diff --git a/spec/inputs/export.yue b/spec/inputs/export.yue index 9113508..15ffbcb 100644 --- a/spec/inputs/export.yue +++ b/spec/inputs/export.yue | |||
@@ -55,7 +55,7 @@ f switch a | |||
55 | f [i for i = 1,10] | 55 | f [i for i = 1,10] |
56 | f for i = 1,10 do i | 56 | f for i = 1,10 do i |
57 | f {k,v for k,v in pairs tb} | 57 | f {k,v for k,v in pairs tb} |
58 | f for k,v in pairs tb do k,v | 58 | f for k,v in pairs tb do {k,v} |
59 | f while a do true | 59 | f while a do true |
60 | f with a | 60 | f with a |
61 | .b = 123 | 61 | .b = 123 |
@@ -70,7 +70,7 @@ _ = "#{switch a | |||
70 | _ = "#{[i for i = 1,10]}" | 70 | _ = "#{[i for i = 1,10]}" |
71 | _ = "#{for i = 1,10 do i}" | 71 | _ = "#{for i = 1,10 do i}" |
72 | _ = "#{{k,v for k,v in pairs tb}}" | 72 | _ = "#{{k,v for k,v in pairs tb}}" |
73 | _ = "#{for k,v in pairs tb do k,v}" | 73 | _ = "#{for k,v in pairs tb do {k,v}}" |
74 | _ = "#{while a do true}" | 74 | _ = "#{while a do true}" |
75 | _ = "#{with a | 75 | _ = "#{with a |
76 | .b = 123}" | 76 | .b = 123}" |
diff --git a/spec/inputs/import.yue b/spec/inputs/import.yue index 8e82a01..e206d04 100644 --- a/spec/inputs/import.yue +++ b/spec/inputs/import.yue | |||
@@ -70,7 +70,7 @@ do | |||
70 | 70 | ||
71 | do | 71 | do |
72 | import "m" as {a#: b} | 72 | import "m" as {a#: b} |
73 | import "m" as {e: f, a#: b} | 73 | import "m" as {e: f, a#: c} |
74 | import "m" as {c: d} | 74 | import "m" as {c: d} |
75 | import "m" as {g, {h#: i}} | 75 | import "m" as {g, {h#: i}} |
76 | 76 | ||
diff --git a/spec/inputs/macro.yue b/spec/inputs/macro.yue index 7bbb06d..3c89c1c 100644 --- a/spec/inputs/macro.yue +++ b/spec/inputs/macro.yue | |||
@@ -279,7 +279,7 @@ do | |||
279 | 279 | ||
280 | macro skip = -> "while false do break" | 280 | macro skip = -> "while false do break" |
281 | 281 | ||
282 | _ = -> | 282 | _1 = -> |
283 | print 1 | 283 | print 1 |
284 | <- $skip | 284 | <- $skip |
285 | print 2 | 285 | print 2 |
diff --git a/spec/inputs/metatable.yue b/spec/inputs/metatable.yue index ed68a17..7e9b4f2 100644 --- a/spec/inputs/metatable.yue +++ b/spec/inputs/metatable.yue | |||
@@ -23,7 +23,7 @@ do | |||
23 | = 123, a.b.c, func! | 23 | = 123, a.b.c, func! |
24 | 24 | ||
25 | x.abc, a.b.# = 123, {} | 25 | x.abc, a.b.# = 123, {} |
26 | func!.# = mt, extra | 26 | func!.# = mt --, extra |
27 | a, b.c.#, d, e = 1, mt, "abc" | 27 | a, b.c.#, d, e = 1, mt, "abc" |
28 | 28 | ||
29 | is_same = a.#.__index == a.index# | 29 | is_same = a.#.__index == a.index# |
diff --git a/spec/inputs/syntax.yue b/spec/inputs/syntax.yue index f212bec..d18bd0e 100644 --- a/spec/inputs/syntax.yue +++ b/spec/inputs/syntax.yue | |||
@@ -71,10 +71,10 @@ _ = something[======[hey]======] * 2 | |||
71 | _ = something[ [======[hey]======] ] * 2 | 71 | _ = something[ [======[hey]======] ] * 2 |
72 | 72 | ||
73 | 73 | ||
74 | _ = something'else', 2 | 74 | _, _ = something'else', 2 |
75 | _ = something"else", 2 | 75 | _, _ = something"else", 2 |
76 | _ = something[[else]], 2 | 76 | _, _ = something[[else]], 2 |
77 | _ = something[ [[else]] ], 2 | 77 | _, _ = something[ [[else]] ], 2 |
78 | 78 | ||
79 | something 'else', 2 | 79 | something 'else', 2 |
80 | something "else", 2 | 80 | something "else", 2 |
@@ -157,7 +157,7 @@ y = #"hello" | |||
157 | 157 | ||
158 | x = #{#{},#{1},#{1,2}} | 158 | x = #{#{},#{1},#{1,2}} |
159 | 159 | ||
160 | _ = hello, world | 160 | _, _ = hello, world |
161 | 161 | ||
162 | something\hello(what) a,b | 162 | something\hello(what) a,b |
163 | something\hello what | 163 | something\hello what |
diff --git a/spec/inputs/tables.yue b/spec/inputs/tables.yue index e1b9e1d..0b5af46 100644 --- a/spec/inputs/tables.yue +++ b/spec/inputs/tables.yue | |||
@@ -152,12 +152,12 @@ k = { "hello": 'world', "hat": "zat" } | |||
152 | please "hello": "world" | 152 | please "hello": "world" |
153 | k = "hello": "world", "one": "zone" | 153 | k = "hello": "world", "one": "zone" |
154 | 154 | ||
155 | f = "one", "two": three, "four" | 155 | f1, f2, f3 = "one", "two": three, "four" |
156 | f = "two": three, "four" | 156 | f1, f2 = "two": three, "four" |
157 | f = { "one", "two": three, "four" } | 157 | f1 = { "one", "two": three, "four" } |
158 | 158 | ||
159 | 159 | ||
160 | j = "one", "two": three, "four": five, 6, 7 | 160 | j1, j2, j3, j4 = "one", "two": three, "four": five, 6, 7 |
161 | 161 | ||
162 | heroine = | 162 | heroine = |
163 | name: "Christina" | 163 | name: "Christina" |
diff --git a/spec/inputs/with.yue b/spec/inputs/with.yue index 6f3e3ba..5da0980 100644 --- a/spec/inputs/with.yue +++ b/spec/inputs/with.yue | |||
@@ -45,7 +45,7 @@ do | |||
45 | -- | 45 | -- |
46 | 46 | ||
47 | do | 47 | do |
48 | with a, b -- b is lost | 48 | with a -- only one value allowed |
49 | print .world | 49 | print .world |
50 | 50 | ||
51 | mod = with _M = {} | 51 | mod = with _M = {} |