class Test var _on as bool get isOn as bool return _on get isOff as bool return not _on def turnOn ensure .isOn not .isOff body _on = true def turnOff ensure .isOff not .isOn body _on = false def badTurnOff ensure .isOff not .isOn body _on = true def useForExprInEnsure(i as int) as List ensure i > 0 implies all for s in result get s == 'foo' body if i, return ['foo', 'foo'] else, return List() def main .turnOn assert .isOn .turnOff assert .isOff expect EnsureException .badTurnOff assert .useForExprInEnsure(0) == List() assert .useForExprInEnsure(1) == ['foo', 'foo'] EnsureWithStructResult().run struct Thing pro value from var as int class EnsureWithStructResult def run assert .foo == 1 assert .bar.value == 0 def foo as int ensure result == 1 body return 1 def bar as Thing ensure result.value == 0 # used to generate false error. ticket:219 body return Thing()