File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1321,6 +1321,13 @@ cdef class BooleanTrue(BooleanAtom):
1321
1321
def _sage_ (self ):
1322
1322
return True
1323
1323
1324
+ def __nonzero__ (self ):
1325
+ return True
1326
+
1327
+ def __bool__ (self ):
1328
+ return True
1329
+
1330
+
1324
1331
true = BooleanTrue()
1325
1332
1326
1333
@@ -1336,6 +1343,12 @@ cdef class BooleanFalse(BooleanAtom):
1336
1343
def _sage_ (self ):
1337
1344
return False
1338
1345
1346
+ def __nonzero__ (self ):
1347
+ return False
1348
+
1349
+ def __bool__ (self ):
1350
+ return False
1351
+
1339
1352
false = BooleanFalse()
1340
1353
1341
1354
Original file line number Diff line number Diff line change @@ -220,3 +220,11 @@ def test_special_constants():
220
220
assert One () == Integer (1 )
221
221
assert NegativeOne () == Integer (- 1 )
222
222
assert Half () == Rational (1 , 2 )
223
+
224
+
225
+ def test_bool ():
226
+ x = Symbol ('x' )
227
+ if (x ** 2 ).args [1 ] > 0 :
228
+ assert True
229
+ if (x ** 2 ).args [1 ] < 0 :
230
+ assert False
You can’t perform that action at this time.
0 commit comments