Allow "not X" expressions on non-boolean X
Change-Id: I6c41d6113fddbbd04c8d68f1a965ae924af8fa3f Closes-Bug: #1504073
This commit is contained in:
parent
c334f584c6
commit
14da1c15dd
@ -30,7 +30,6 @@ def or_(left, right):
|
||||
return left() or right()
|
||||
|
||||
|
||||
@specs.parameter('arg', bool)
|
||||
@specs.name('#unary_operator_not')
|
||||
def not_(arg):
|
||||
return not arg
|
||||
|
@ -22,6 +22,7 @@ class TestBoolean(yaql.tests.TestCase):
|
||||
self.assertFalse(self.eval('false and false'))
|
||||
self.assertFalse(self.eval('false and true'))
|
||||
self.assertEqual(12, self.eval('true and 12'))
|
||||
self.assertFalse(self.eval('null and null'))
|
||||
|
||||
def test_or(self):
|
||||
self.assertTrue(self.eval('true or true'))
|
||||
@ -29,10 +30,16 @@ class TestBoolean(yaql.tests.TestCase):
|
||||
self.assertFalse(self.eval('false or false'))
|
||||
self.assertTrue(self.eval('false or true'))
|
||||
self.assertEqual(12, self.eval('12 or true'))
|
||||
self.assertFalse(self.eval('null or null'))
|
||||
|
||||
def test_not(self):
|
||||
self.assertFalse(self.eval('not true'))
|
||||
self.assertTrue(self.eval('not false'))
|
||||
self.assertTrue(self.eval('not 0'))
|
||||
self.assertFalse(self.eval('not 123'))
|
||||
self.assertTrue(self.eval("not ''"))
|
||||
self.assertFalse(self.eval("not True"))
|
||||
self.assertTrue(self.eval('not null'))
|
||||
|
||||
def test_lazy(self):
|
||||
self.assertEqual(1, self.eval('$ or 10/($-1)', data=1))
|
||||
|
Loading…
Reference in New Issue
Block a user