diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-26 06:38:38 +0000 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-26 06:38:38 +0000 |
| commit | 5d5b657f606b5939062983b1f90c3359d542672e (patch) | |
| tree | 32132fd8908d6a8920d59362c572815a949f1a1f /spec/inputs/test/backcall_spec.yue | |
| parent | f5006f449a7be1a2f655f1b178ecf1d2f0569dd5 (diff) | |
| download | yuescript-5d5b657f606b5939062983b1f90c3359d542672e.tar.gz yuescript-5d5b657f606b5939062983b1f90c3359d542672e.tar.bz2 yuescript-5d5b657f606b5939062983b1f90c3359d542672e.zip | |
Fixed compiler improvements and added comprehensive test suite
- Fixed makefile preprocessor macro definitions (removed spaces in -D flags)
- Added null pointer check in compiler class declaration handling
- Added comprehensive test specifications for various language features:
- attrib, backcall, cond, config, existential, export, goto
- import, literals, macro, metatable, operators, return
- string, switch, vararg, with
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'spec/inputs/test/backcall_spec.yue')
| -rw-r--r-- | spec/inputs/test/backcall_spec.yue | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/inputs/test/backcall_spec.yue b/spec/inputs/test/backcall_spec.yue new file mode 100644 index 0000000..9534e7c --- /dev/null +++ b/spec/inputs/test/backcall_spec.yue | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | describe "backcall", -> | ||
| 2 | it "should support basic backcall with <-", -> | ||
| 3 | results = {} | ||
| 4 | mock_map = (list, fn) -> | ||
| 5 | for item in *list | ||
| 6 | table.insert results, fn(item) | ||
| 7 | (x) <- mock_map {1, 2, 3} | ||
| 8 | x * 2 | ||
| 9 | assert.same results, {2, 4, 6} | ||
| 10 | |||
| 11 | it "should support nested backcalls", -> | ||
| 12 | results = {} | ||
| 13 | mock_map = (list, fn) -> | ||
| 14 | for item in *list | ||
| 15 | fn(item) | ||
| 16 | mock_map {1, 2, 3, 4}, (x) -> | ||
| 17 | if x > 2 | ||
| 18 | table.insert results, x | ||
| 19 | assert.same results, {3, 4} | ||
| 20 | |||
| 21 | it "should work with method call backcall", -> | ||
| 22 | results = {} | ||
| 23 | obj = { | ||
| 24 | process: (self, fn) -> | ||
| 25 | fn 42 | ||
| 26 | } | ||
| 27 | (value) <- obj\process | ||
| 28 | table.insert results, value | ||
| 29 | assert.same results, {42} | ||
