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
|
describe "constructor promotion", ->
it "should promote simple arguments to assignment", ->
class Thing
new: (@name, @age) =>
instance = Thing "Alice", 30
assert.same instance.name, "Alice"
assert.same instance.age, 30
it "should promote multiple arguments", ->
class Point
new: (@x, @y, @z) =>
p = Point 1, 2, 3
assert.same p.x, 1
assert.same p.y, 2
assert.same p.z, 3
it "should work with multiple parameters", ->
class Container
new: (@a, @b, @c) =>
c = Container!
assert.same c.a, nil
assert.same c.b, nil
assert.same c.c, nil
|