fixed class 'set' so that if None is an element, it is treated properly. #770

Merged
merged 2 commits into from Aug 2, 2012
View
8 examples/libtest/Syntax27Test.py
@@ -6,18 +6,13 @@ def testSetLiteral(self):
s = {1,2,3,1,2,3,1,2,3}
self.assertEqual(s, set([1,2,3]))
- self.fail("Bug #XXX - None not supported in sets")
- return
s = {1, 2, None, True, False, 2, 2, ('a',)}
- self.assertEqual(s, set([False, True, 2, ('a',), None]))
+ self.assertEqual(s, set([False, True, 1, 2, ('a',), None]))
def testSetComprehensions(self):
s = sum({i*i for i in range(100) if i&1 == 1})
self.assertEqual(s, 166650)
- self.fail("Bug #XXX - Set equality fails")
- return
-
s = {2*y + x + 1 for x in (0,) for y in (1,)}
self.assertEqual(s, set([3]))
@@ -89,4 +84,3 @@ def testDictComprehensions(self):
g = "outer"
d = { k: g for k in range(3) }
self.assertEqual(d, {0: 'outer', 1: 'outer', 2: 'outer'})
-
View
2 examples/libtest/pyv8test.sh
@@ -1,2 +1,2 @@
#!/bin/sh
-python ../../pyv8/pyv8run.py --dynamic '^I18N[.].*.._..' $@ LibTest `find I18N -name ??_??.py`
+python ../../pyv8/pyv8run.py --dynamic-load '^I18N[.].*.._..' $@ LibTest `find I18N -name ??_??.py`
View
6 pyjs/src/pyjs/builtin/pyjslib.py
@@ -144,7 +144,9 @@ def __repr__(cls):
return "<type '%s'>" % cls.__name__
class NoneType(TypeClass):
- pass
+ def __hash__(self, value):
+ return 0 # always return 0 since value should always be None
+
class ModuleType(TypeClass):
pass
class FunctionType(TypeClass):
@@ -6416,6 +6418,7 @@ def __add__(self, b):
# IE has problems with setting obj.$H on certain DOM objects
#def __hash(obj):
JS("""@{{__hash}} = function(obj) {
+ if (obj === null) return null;
switch (obj['constructor']) {
case String:
case Number:
@@ -6480,6 +6483,7 @@ def __add__(self, b):
else:
#def __hash(obj):
JS("""@{{__hash}} = function(obj) {
+ if (obj === null) return null;
switch (obj['constructor']) {
case String:
case Number: