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 @@ -1301,6 +1301,13 @@ cdef class BooleanTrue(BooleanAtom):
1301
1301
def _sage_ (self ):
1302
1302
return True
1303
1303
1304
+ def __nonzero__ (self ):
1305
+ return True
1306
+
1307
+ def __bool__ (self ):
1308
+ return True
1309
+
1310
+
1304
1311
true = BooleanTrue()
1305
1312
1306
1313
@@ -1316,6 +1323,12 @@ cdef class BooleanFalse(BooleanAtom):
1316
1323
def _sage_ (self ):
1317
1324
return False
1318
1325
1326
+ def __nonzero__ (self ):
1327
+ return False
1328
+
1329
+ def __bool__ (self ):
1330
+ return False
1331
+
1319
1332
false = BooleanFalse()
1320
1333
1321
1334
Original file line number Diff line number Diff line change @@ -216,3 +216,11 @@ def test_special_constants():
216
216
assert One () == Integer (1 )
217
217
assert NegativeOne () == Integer (- 1 )
218
218
assert Half () == Rational (1 , 2 )
219
+
220
+
221
+ def test_bool ():
222
+ x = Symbol ('x' )
223
+ if (x ** 2 ).args [1 ] > 0 :
224
+ assert True
225
+ if (x ** 2 ).args [1 ] < 0 :
226
+ assert False
You can’t perform that action at this time.
0 commit comments