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.
33 lines
515 B
Plaintext
33 lines
515 B
Plaintext
class Iter {
|
|
new(value) { _value = value }
|
|
iterate(iterator) { return _value }
|
|
iteratorValue(iterator) { return "value" }
|
|
}
|
|
|
|
// False and null are false.
|
|
for (n in new Iter(false)) {
|
|
IO.print("bad")
|
|
break
|
|
}
|
|
|
|
for (n in new Iter(null)) {
|
|
IO.print("bad")
|
|
break
|
|
}
|
|
|
|
// Everything else is true.
|
|
for (n in new Iter(true)) {
|
|
IO.print("true") // expect: true
|
|
break
|
|
}
|
|
|
|
for (n in new Iter(0)) {
|
|
IO.print(0) // expect: 0
|
|
break
|
|
}
|
|
|
|
for (n in new Iter("")) {
|
|
IO.print("string") // expect: string
|
|
break
|
|
}
|