Permalink
Browse files

Merge pull request #770 from earney/setlibtest

fixed class 'set' so that if None is an element, it is treated properly.
  • Loading branch information...
2 parents 81a19ae + 7ef1b42 commit 2af5f6808c7dfe6bc431e3ffa497d7b035906abc @keesbos keesbos committed Aug 2, 2012
Showing with 7 additions and 9 deletions.
  1. +1 −7 examples/libtest/Syntax27Test.py
  2. +1 −1 examples/libtest/pyv8test.sh
  3. +5 −1 pyjs/src/pyjs/builtin/pyjslib.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'})
-
@@ -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`
@@ -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):
@@ -6411,6 +6413,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:
@@ -6475,6 +6478,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:

0 comments on commit 2af5f68

Please sign in to comment.