diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-30 18:16:45 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-30 18:16:45 +0800 |
| commit | 8c3d786157ec7fef3072feac55c2d5450800568b (patch) | |
| tree | 6c44a85e02abe74e6c3ccc4d7393ba8784c49ce7 /spec/inputs/test/constructor_promotion_spec.yue | |
| parent | 220a10d0df3341b2bbb0beaee4f90d6480e7ae38 (diff) | |
| download | yuescript-main.tar.gz yuescript-main.tar.bz2 yuescript-main.zip | |
Diffstat (limited to 'spec/inputs/test/constructor_promotion_spec.yue')
| -rw-r--r-- | spec/inputs/test/constructor_promotion_spec.yue | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/inputs/test/constructor_promotion_spec.yue b/spec/inputs/test/constructor_promotion_spec.yue new file mode 100644 index 0000000..83c9d15 --- /dev/null +++ b/spec/inputs/test/constructor_promotion_spec.yue | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | describe "constructor promotion", -> | ||
| 2 | it "should promote simple arguments to assignment", -> | ||
| 3 | class Thing | ||
| 4 | new: (@name, @age) => | ||
| 5 | |||
| 6 | instance = Thing "Alice", 30 | ||
| 7 | assert.same instance.name, "Alice" | ||
| 8 | assert.same instance.age, 30 | ||
| 9 | |||
| 10 | it "should promote multiple arguments", -> | ||
| 11 | class Point | ||
| 12 | new: (@x, @y, @z) => | ||
| 13 | |||
| 14 | p = Point 1, 2, 3 | ||
| 15 | assert.same p.x, 1 | ||
| 16 | assert.same p.y, 2 | ||
| 17 | assert.same p.z, 3 | ||
| 18 | |||
| 19 | it "should work with multiple parameters", -> | ||
| 20 | class Container | ||
| 21 | new: (@a, @b, @c) => | ||
| 22 | |||
| 23 | c = Container! | ||
| 24 | assert.same c.a, nil | ||
| 25 | assert.same c.b, nil | ||
| 26 | assert.same c.c, nil | ||
