joe-greenawalt / skulpt

Automatically exported from code.google.com/p/skulpt
Other
0 stars 0 forks source link

Boolean Type Coercion Not Working Correctly #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Code you're trying to run:
print False == 0
print True == 1
print True == 2

What does "real" Python output?
True
True
False

What browser are you using? On what operating system?
Firefox 3.6.12

Please provide any additional information.
When this is fixed, `print (not 3) in range(-2,5)` should yield True.

Original issue reported on code.google.com by carnioja...@gmail.com on 29 Nov 2010 at 5:05

GoogleCodeExporter commented 9 years ago
In CPython:
print (2 < 3 < 9)
# yields True

print (2 < (3 < 9))
# yields False, because 2 is not < True (which "equals" 1)

The latter statement just fails in skulpt, for reasons unknown but probably 
having to do with this issue.

Original comment by carnioja...@gmail.com on 29 Nov 2010 at 5:11

GoogleCodeExporter commented 9 years ago
Also, when this has been implemented, test ~True and ~False (should yield -2 
and -1)

Original comment by carnioja...@gmail.com on 29 Nov 2010 at 5:28

GoogleCodeExporter commented 9 years ago
print False == 0
print True == 1
print True == 2
and ~True and ~False work now.

Multi-condition compares are going to take a bit more work.

Original comment by sgraham on 30 Nov 2010 at 5:49

GoogleCodeExporter commented 9 years ago
Multi-condition fixed now (t268, t273).

Original comment by sgraham on 3 Dec 2010 at 1:43

GoogleCodeExporter commented 9 years ago
You should already know that, but AFAIK, Boolean values are a special case of 
integers. That kind of explains while False and True are equal to 0 and 1.

Original comment by denilsonsa on 5 Dec 2010 at 3:38