diff options
| author | Li Jin <dragon-fly@qq.com> | 2022-07-07 16:22:17 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2022-07-07 16:22:17 +0800 |
| commit | 1eb9ed57de854aa996614b7016bac04a68105389 (patch) | |
| tree | 27b46d4a5482ac0ab542d18548c0691aa8115d93 /spec/inputs | |
| parent | b26b0c3e7061cd629500994e26fa162ac2668373 (diff) | |
| download | yuescript-1eb9ed57de854aa996614b7016bac04a68105389.tar.gz yuescript-1eb9ed57de854aa996614b7016bac04a68105389.tar.bz2 yuescript-1eb9ed57de854aa996614b7016bac04a68105389.zip | |
add spec.
Diffstat (limited to 'spec/inputs')
| -rw-r--r-- | spec/inputs/macro-export.yue | 14 | ||||
| -rw-r--r-- | spec/inputs/macro.yue | 10 |
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 | ||
| 35 | export 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 | " | ||
| 41 | do | ||
| 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! | |||
| 24 | if $and f1!, f2!, f3! | 24 | if $and f1!, f2!, f3! |
| 25 | print "OK" | 25 | print "OK" |
| 26 | 26 | ||
| 27 | item = $copy( | ||
| 28 | @ | ||
| 29 | {pos: {}, flags: flags::tonumber!} | ||
| 30 | id | ||
| 31 | connections | ||
| 32 | pos.x | ||
| 33 | pos.y | ||
| 34 | pos.z | ||
| 35 | ) | ||
| 36 | |||
| 27 | macro in = (target, ...)-> | 37 | macro 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 " |
