aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-07-24 22:13:08 +0800
committerLi Jin <dragon-fly@qq.com>2022-07-24 22:13:08 +0800
commit303834e1b1e6cd9cae64b66c2ae44dcd7185238f (patch)
tree519f6a1debcc5791d35e06dc5cbb1ce22f9cfd31 /spec/inputs
parenteb367126bf3a4f5b0e51ccef93b7c7136bea170e (diff)
downloadyuescript-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.yue5
-rw-r--r--spec/inputs/export.yue4
-rw-r--r--spec/inputs/import.yue2
-rw-r--r--spec/inputs/macro.yue2
-rw-r--r--spec/inputs/metatable.yue2
-rw-r--r--spec/inputs/syntax.yue10
-rw-r--r--spec/inputs/tables.yue8
-rw-r--r--spec/inputs/with.yue2
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
184do 184do
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
187do
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
55f [i for i = 1,10] 55f [i for i = 1,10]
56f for i = 1,10 do i 56f for i = 1,10 do i
57f {k,v for k,v in pairs tb} 57f {k,v for k,v in pairs tb}
58f for k,v in pairs tb do k,v 58f for k,v in pairs tb do {k,v}
59f while a do true 59f while a do true
60f with a 60f 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
71do 71do
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
280macro skip = -> "while false do break" 280macro 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
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"
28 28
29is_same = a.#.__index == a.index# 29is_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
79something 'else', 2 79something 'else', 2
80something "else", 2 80something "else", 2
@@ -157,7 +157,7 @@ y = #"hello"
157 157
158x = #{#{},#{1},#{1,2}} 158x = #{#{},#{1},#{1,2}}
159 159
160_ = hello, world 160_, _ = hello, world
161 161
162something\hello(what) a,b 162something\hello(what) a,b
163something\hello what 163something\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" }
152please "hello": "world" 152please "hello": "world"
153k = "hello": "world", "one": "zone" 153k = "hello": "world", "one": "zone"
154 154
155f = "one", "two": three, "four" 155f1, f2, f3 = "one", "two": three, "four"
156f = "two": three, "four" 156f1, f2 = "two": three, "four"
157f = { "one", "two": three, "four" } 157f1 = { "one", "two": three, "four" }
158 158
159 159
160j = "one", "two": three, "four": five, 6, 7 160j1, j2, j3, j4 = "one", "two": three, "four": five, 6, 7
161 161
162heroine = 162heroine =
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
47do 47do
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 = {}