1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
describe "implicit object", ->
it "should create list with asterisk", ->
list =
* 1
* 2
* 3
assert.same list, {1, 2, 3}
it "should create list with dash", ->
items =
- "a"
- "b"
- "c"
assert.same items, {"a", "b", "c"}
it "should work with function call", ->
results = []
fn =
* 1
* 2
* 3
for item in *fn
table.insert results, item
assert.same results, {1, 2, 3}
it "should support nested implicit objects", ->
tb =
name: "test"
values:
- "a"
- "b"
- "c"
objects:
- name: "first"
value: 1
- name: "second"
value: 2
assert.same tb.values, {"a", "b", "c"}
assert.same tb.objects[1].name, "first"
assert.same tb.objects[2].value, 2
it "should work with return statement", ->
fn = ->
return
* 1
* 2
* 3
assert.same fn!, {1, 2, 3}
it "should handle mixed content", ->
tb =
key: "value"
items:
- 1
- 2
other: "data"
assert.same tb.key, "value"
assert.same tb.items, {1, 2}
assert.same tb.other, "data"
it "should work in assignment", ->
list =
* "x"
* "y"
* "z"
assert.same list, {"x", "y", "z"}
it "should support nested structures with asterisk", ->
tb =
* 1
* 2
nested:
* 3
* 4
assert.same tb[1], 1
assert.same tb[2], 2
assert.same tb.nested, {3, 4}
it "should handle implicit object in tables", ->
tb = {
name: "test"
list:
- 1
- 2
value: 42
}
assert.same tb.list, {1, 2}
it "should work with expressions", ->
x = 10
list =
* x + 1
* x + 2
* x + 3
assert.same list, {11, 12, 13}
it "should support method calls in implicit object", ->
tb =
name: "test"
items:
- name: "item1"
getName: => @name
- name: "item2"
getName: => @name
assert.same tb.items[1]\getName!, "item1"
assert.same tb.items[2]\getName!, "item2"
it "should work with complex nested structures", ->
config =
database:
host: "localhost"
ports:
- 8080
- 8081
- 8082
servers:
- name: "server1"
port: 8080
- name: "server2"
port: 8081
assert.same config.database.ports, {8080, 8081, 8082}
assert.same config.servers[1].name, "server1"
it "should handle empty implicit object", ->
tb =
items:
-
assert.same tb.items, {nil}
it "should work in function arguments", ->
fn = (items) -> #items
result = fn
* 1
* 2
* 3
assert.same result, 3
it "should support mixed asterisk and dash", ->
tb =
values:
* 1
- 2
* 3
assert.same tb.values, {1, 2, 3}
|