class Test def main is shared # test that nilable primitives are checked for their values b = true to ? assert b assert not b == false assert not not b assert if(b, true, false) b = false assert not b assert if(b, false, true) b = nil assert not b assert if(b, false, true) i = 1 to ? assert i assert (not i) == false assert not not i assert if(i, true, false) i = 0 assert not i assert if(i, false, true) i = nil assert not i assert if(i, false, true) c = c'x' to ? assert c assert (not c) == false assert not not c assert if(c, true, false) c = c'\0' assert not c assert if(c, false, true) c = nil assert not c assert if(c, false, true) f = 1.1f to ? assert f assert (not f) == false assert not not f assert if(f, true, false) f = 0.0f assert not f assert if(f, false, true) f = nil assert not f assert if(f, false, true) d = 1.0 to ? assert d assert (not d) == false assert not not d assert if(d, true, false) d = 0.0 assert not d assert if(d, false, true) d = nil assert not d assert if(d, false, true) # non-primitive nilable types are true if non-nil o = Object() to ? assert o assert (not o) == false assert not not o assert if(o, true, false) o = nil assert not o assert if(o, false, true)