feat: replace block syntax with fn keyword for function literals across compiler and tests
Rename `block` parsing rule to `fn` by adding TOKEN_FN token and function prefix rule, removing the old block prefix from TOKEN_LEFT_BRACE. Update compiler.c to replace `block()` with `function()` and add fn equality primitives (fn_eqeq, fn_bangeq) in primitives.c. Migrate test files: rename block_call.wren to fn_call.wren, block_syntax.wren to fn_syntax.wren, and replace `{ ... }` with `fn { ... }` or `fn expr` syntax. Remove obsolete bool_equality.wren test.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// Not structurally equal.
|
||||
io.write((fn 123) == (fn 123)) // expect: false
|
||||
io.write((fn 123) != (fn 123)) // expect: true
|
||||
|
||||
// Not equal to other types.
|
||||
io.write((fn 123) == 1) // expect: false
|
||||
io.write((fn 123) == false) // expect: false
|
||||
io.write((fn 123) == "fn 123") // expect: false
|
||||
io.write((fn 123) != 1) // expect: true
|
||||
io.write((fn 123) != false) // expect: true
|
||||
io.write((fn 123) != "fn 123") // expect: true
|
||||
|
||||
// Equal by identity.
|
||||
var f = fn 123
|
||||
io.write(f == f) // expect: true
|
||||
io.write(f != f) // expect: false
|
||||
Reference in New Issue
Block a user