diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-01-25 17:48:03 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-01-25 17:48:03 +0800 |
| commit | ed317e62eb1cf98fde4461fc90c6cb1045ebc7e8 (patch) | |
| tree | 427e365939da39f31dbfa755675fb60bb141583d /spec/inputs/destructure.moon | |
| parent | 4827d200604a086e2ad94edb4257c3abc7a3c4fc (diff) | |
| download | yuescript-ed317e62eb1cf98fde4461fc90c6cb1045ebc7e8.tar.gz yuescript-ed317e62eb1cf98fde4461fc90c6cb1045ebc7e8.tar.bz2 yuescript-ed317e62eb1cf98fde4461fc90c6cb1045ebc7e8.zip | |
fix Moonscript issue 375.
Diffstat (limited to 'spec/inputs/destructure.moon')
| -rw-r--r-- | spec/inputs/destructure.moon | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/spec/inputs/destructure.moon b/spec/inputs/destructure.moon index 5bc7810..e0f2198 100644 --- a/spec/inputs/destructure.moon +++ b/spec/inputs/destructure.moon | |||
| @@ -1,105 +1,105 @@ | |||
| 1 | 1 | ||
| 2 | do | 2 | do |
| 3 | {a, b} = hello | 3 | {a, b} = hello |
| 4 | 4 | ||
| 5 | {{a}, b, {c}} = hello | 5 | {{a}, b, {c}} = hello |
| 6 | 6 | ||
| 7 | { :hello, :world } = value | 7 | { :hello, :world } = value |
| 8 | 8 | ||
| 9 | do | 9 | do |
| 10 | { yes: no, thing } = world | 10 | { yes: no, thing } = world |
| 11 | 11 | ||
| 12 | {:a,:b,:c,:d} = yeah | 12 | {:a,:b,:c,:d} = yeah |
| 13 | 13 | ||
| 14 | {a} = one, two | 14 | {a} = one, two |
| 15 | {b}, c = one | 15 | {b}, c = one |
| 16 | {d}, e = one, two | 16 | {d}, e = one, two |
| 17 | 17 | ||
| 18 | x, {y} = one, two | 18 | x, {y} = one, two |
| 19 | 19 | ||
| 20 | xx, yy = 1, 2 | 20 | xx, yy = 1, 2 |
| 21 | {yy, xx} = {xx, yy} | 21 | {yy, xx} = {xx, yy} |
| 22 | 22 | ||
| 23 | {a, :b, c, :d, e, :f, g} = tbl | 23 | {a, :b, c, :d, e, :f, g} = tbl |
| 24 | 24 | ||
| 25 | --- | 25 | --- |
| 26 | 26 | ||
| 27 | do | 27 | do |
| 28 | futurists = | 28 | futurists = |
| 29 | sculptor: "Umberto Boccioni" | 29 | sculptor: "Umberto Boccioni" |
| 30 | painter: "Vladimir Burliuk" | 30 | painter: "Vladimir Burliuk" |
| 31 | poet: | 31 | poet: |
| 32 | name: "F.T. Marinetti" | 32 | name: "F.T. Marinetti" |
| 33 | address: { | 33 | address: { |
| 34 | "Via Roma 42R" | 34 | "Via Roma 42R" |
| 35 | "Bellagio, Italy 22021" | 35 | "Bellagio, Italy 22021" |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | {poet: {:name, address: {street, city}}} = futurists | 38 | {poet: {:name, address: {street, city}}} = futurists |
| 39 | 39 | ||
| 40 | -- | 40 | -- |
| 41 | 41 | ||
| 42 | do | 42 | do |
| 43 | { @world } = x | 43 | { @world } = x |
| 44 | { a.b, c.y, func!.z } = x | 44 | { a.b, c.y, func!.z } = x |
| 45 | 45 | ||
| 46 | { world: @world } = x | 46 | { world: @world } = x |
| 47 | 47 | ||
| 48 | -- | 48 | -- |
| 49 | 49 | ||
| 50 | do | 50 | do |
| 51 | thing = {{1,2}, {3,4}} | 51 | thing = {{1,2}, {3,4}} |
| 52 | 52 | ||
| 53 | for {x,y} in *thing | 53 | for {x,y} in *thing |
| 54 | print x,y | 54 | print x,y |
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | -- | 57 | -- |
| 58 | 58 | ||
| 59 | do | 59 | do |
| 60 | with {a,b} = thing | 60 | with {a,b} = thing |
| 61 | print a, b | 61 | print a, b |
| 62 | 62 | ||
| 63 | 63 | ||
| 64 | -- | 64 | -- |
| 65 | 65 | ||
| 66 | do | 66 | do |
| 67 | thing = nil | 67 | thing = nil |
| 68 | if {a} = thing | 68 | if {a} = thing |
| 69 | print a | 69 | print a |
| 70 | else | 70 | else |
| 71 | print "nothing" | 71 | print "nothing" |
| 72 | 72 | ||
| 73 | thang = {1,2} | 73 | thang = {1,2} |
| 74 | if {a,b} = thang | 74 | if {a,b} = thang |
| 75 | print a,b | 75 | print a,b |
| 76 | 76 | ||
| 77 | if {a,b} = thing | 77 | if {a,b} = thing |
| 78 | print a,b | 78 | print a,b |
| 79 | elseif {c,d} = thang | 79 | elseif {c,d} = thang |
| 80 | print c,d | 80 | print c,d |
| 81 | else | 81 | else |
| 82 | print "NO" | 82 | print "NO" |
| 83 | 83 | ||
| 84 | -- | 84 | -- |
| 85 | 85 | ||
| 86 | do | 86 | do |
| 87 | z = "yeah" | 87 | z = "yeah" |
| 88 | {a,b,c} = z | 88 | {a,b,c} = z |
| 89 | 89 | ||
| 90 | do | 90 | do |
| 91 | {a,b,c} = z | 91 | {a,b,c} = z |
| 92 | 92 | ||
| 93 | _ = (z) -> | 93 | _ = (z) -> |
| 94 | {a,b,c} = z | 94 | {a,b,c} = z |
| 95 | 95 | ||
| 96 | do | 96 | do |
| 97 | z = "oo" | 97 | z = "oo" |
| 98 | _ = (k) -> | 98 | _ = (k) -> |
| 99 | {a,b,c} = z | 99 | {a,b,c} = z |
| 100 | 100 | ||
| 101 | do | 101 | do |
| 102 | {function:{end:endVar}} = thing | 102 | {function:{end:endVar}} = thing |
| 103 | 103 | ||
| 104 | do | 104 | do |
| 105 | {if:{a,b,c}} = thing | 105 | {if:{a,b,c}} = thing |
