Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 2 commits into from

3 participants

@earney

modified pyjslib.py by adding a hash function for NoneType, added check to hash functions to return null if passed argument obj is null.

modified SyntaxTest27.py, removed self.fail/return statements to show that changes to pyjslib.py works. Added 1 to correct a assertEqual test.

modified pyv8test.py, changed --dynamic to --dynamic-load to get rid of a depreated warning about --dynamic

@keesbos keesbos was assigned
@xtfxme
Owner

this LGTM, but i want @keesbos to just verify the pyjslib bits because it's been a little while since i've rummaged thru there.

@xtfxme
Owner

@earney btw, thanks a bunch for fixing up these sorts of things -- much appreciated.

@keesbos keesbos merged commit 2af5f68 into pyjs:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 2, 2012
  1. @earney
  2. @earney

    modified pyjslib.py sets, so that None is handled properly, modified

    earney authored
    Syntax27Test.py so that all unit tests are executed (removed return statements).
This page is out of date. Refresh to see the latest.
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:
Something went wrong with that request. Please try again.