|
1 | 1 | import Block from require "moonscript.compile"
|
2 |
| -import ref from require "spec.factory" |
| 2 | + |
| 3 | +import ref, str from require "spec.factory" |
3 | 4 |
|
4 | 5 | -- no transform step
|
5 | 6 | class SimpleBlock extends Block
|
@@ -28,6 +29,76 @@ describe "moonscript.compile", ->
|
28 | 29 | -> {"ref", "hello_world"}
|
29 | 30 | "hello_world"
|
30 | 31 | }
|
| 32 | + |
| 33 | + { |
| 34 | + "explist" |
| 35 | + -> { "explist", ref("a"), ref("b"), ref("c")} |
| 36 | + "a, b, c" |
| 37 | + } |
| 38 | + |
| 39 | + { |
| 40 | + "parens" |
| 41 | + -> { "parens", ref! } |
| 42 | + "(val)" |
| 43 | + } |
| 44 | + |
| 45 | + { |
| 46 | + "string (single quote)" |
| 47 | + -> {"string", "'", "Hello\\'s world"} |
| 48 | + "'Hello\\'s world'" |
| 49 | + } |
| 50 | + |
| 51 | + { |
| 52 | + "string (double quote)" |
| 53 | + -> {"string", '"', "Hello's world"} |
| 54 | + [["Hello's world"]] |
| 55 | + |
| 56 | + } |
| 57 | + |
| 58 | + { |
| 59 | + "string (lua)" |
| 60 | + -> {"string", '[==[', "Hello's world"} |
| 61 | + "[==[Hello's world]==]" |
| 62 | + } |
| 63 | + |
| 64 | + { |
| 65 | + "chain (single)" |
| 66 | + -> {"chain", ref!} |
| 67 | + "val" |
| 68 | + } |
| 69 | + |
| 70 | + { |
| 71 | + "chain (dot)" |
| 72 | + -> {"chain", ref!, {"dot", "zone"} } |
| 73 | + "val.zone" |
| 74 | + } |
| 75 | + |
| 76 | + { |
| 77 | + "chain (index)" |
| 78 | + -> {"chain", ref!, {"index", ref("x") } } |
| 79 | + "val[x]" |
| 80 | + } |
| 81 | + |
| 82 | + |
| 83 | + { |
| 84 | + "chain (call)" |
| 85 | + -> {"chain", ref!, {"call", { ref("arg") }} } |
| 86 | + "val(arg)" |
| 87 | + } |
| 88 | + |
| 89 | + { |
| 90 | + "chain" |
| 91 | + -> { |
| 92 | + "chain" |
| 93 | + ref! |
| 94 | + {"dot", "one"} |
| 95 | + {"index", str!} |
| 96 | + {"colon", "two"} |
| 97 | + {"call", { ref("arg") }} |
| 98 | + } |
| 99 | + 'val.one["dogzone"]:two(arg)' |
| 100 | + } |
| 101 | + |
31 | 102 | }
|
32 | 103 | it "compiles #{name}", ->
|
33 | 104 | node = node!
|
|
0 commit comments