aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-07-07 16:22:17 +0800
committerLi Jin <dragon-fly@qq.com>2022-07-07 16:22:17 +0800
commit1eb9ed57de854aa996614b7016bac04a68105389 (patch)
tree27b46d4a5482ac0ab542d18548c0691aa8115d93 /spec/inputs
parentb26b0c3e7061cd629500994e26fa162ac2668373 (diff)
downloadyuescript-1eb9ed57de854aa996614b7016bac04a68105389.tar.gz
yuescript-1eb9ed57de854aa996614b7016bac04a68105389.tar.bz2
yuescript-1eb9ed57de854aa996614b7016bac04a68105389.zip
add spec.
Diffstat (limited to 'spec/inputs')
-rw-r--r--spec/inputs/macro-export.yue14
-rw-r--r--spec/inputs/macro.yue10
2 files changed, 24 insertions, 0 deletions
diff --git a/spec/inputs/macro-export.yue b/spec/inputs/macro-export.yue
index 22ef424..46cc608 100644
--- a/spec/inputs/macro-export.yue
+++ b/spec/inputs/macro-export.yue
@@ -32,6 +32,20 @@ export macro assert = (cond)->
32 else 32 else
33 "#{cond}" 33 "#{cond}"
34 34
35export macro copy = (src, dst, ...)->
36 assert(
37 src != "_src_" and src != "_dst_" and dst != "_src_" and dst != "_dst_"
38 "copy targets can not be _src_ or _dst_"
39 )
40 "
41do
42 local _src_, _dst_
43 with _dst_ = #{dst}
44 with _src_ = #{src}
45#{table.concat (for field in *{...}
46 " _dst_.#{field} = _src_.#{field}"), "\n"}
47"
48
35$ -> 49$ ->
36 global debugMode = true 50 global debugMode = true
37 global debugMacro = true 51 global debugMacro = true
diff --git a/spec/inputs/macro.yue b/spec/inputs/macro.yue
index e391b9e..e4b0fc8 100644
--- a/spec/inputs/macro.yue
+++ b/spec/inputs/macro.yue
@@ -24,6 +24,16 @@ if $and f1!
24if $and f1!, f2!, f3! 24if $and f1!, f2!, f3!
25 print "OK" 25 print "OK"
26 26
27item = $copy(
28 @
29 {pos: {}, flags: flags::tonumber!}
30 id
31 connections
32 pos.x
33 pos.y
34 pos.z
35)
36
27macro in = (target, ...)-> 37macro in = (target, ...)->
28 values = [value for value in *{...}] 38 values = [value for value in *{...}]
29 $showMacro "in", table.concat ["#{target} == #{item}" for item in *values], " or " 39 $showMacro "in", table.concat ["#{target} == #{item}" for item in *values], " or "