Update the VM interpreter to treat null as falsey alongside false in if, while, for, and logical AND/OR operations. Remove the TODO comment and adjust short-circuit logic in OP_JUMP_IF and OP_JUMP_IF_NOT branches. Refactor existing test files into subdirectories (if/, logical_operator/, while/) and add dedicated truthiness tests for each construct. Remove old test/if.wren and update and/or tests to exclude null/0/"" truthiness checks now that null is falsey.
15 lines
356 B
Plaintext
15 lines
356 B
Plaintext
// Evaluate the 'then' expression if the condition is true.
|
|
if (true) IO.print("good") // expect: good
|
|
if (false) IO.print("bad")
|
|
|
|
// Allow block body.
|
|
if (true) { IO.print("block") } // expect: block
|
|
|
|
// Assignment in if condition.
|
|
var a = false
|
|
if (a = true) IO.print(a) // expect: true
|
|
|
|
// Newline after "if".
|
|
if
|
|
(true) IO.print("good") // expect: good
|