[pypy-svn] r36529 - in pypy/dist/pypy/lang/js: . test
santagada at codespeak.net
santagada at codespeak.net
Thu Jan 11 19:56:11 CET 2007
Author: santagada
Date: Thu Jan 11 19:56:10 2007
New Revision: 36529
Modified:
pypy/dist/pypy/lang/js/interpreter.py
pypy/dist/pypy/lang/js/test/test_interp.py
Log:
NOT unary operator
Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py (original)
+++ pypy/dist/pypy/lang/js/interpreter.py Thu Jan 11 19:56:10 2007
@@ -527,6 +527,13 @@
def eval(self, ctx):
return W_Boolean(self.bool)
+class Not(Expression):
+ def __init__(self, op):
+ self.op = op
+
+ def eval(self, ctx):
+ return W_Boolean(not self.op.eval(ctx).GetValue().ToBoolean())
+
def getlist(t):
item = gettreeitem(t, 'length')
if item is None:
@@ -689,5 +696,7 @@
return Boolean(True)
elif tp == 'FALSE':
return Boolean(False)
+ elif tp == 'NOT':
+ return Not(from_tree(gettreeitem(t, '0')))
else:
raise NotImplementedError("Dont know how to handler %s" % tp)
Modified: pypy/dist/pypy/lang/js/test/test_interp.py
==============================================================================
--- pypy/dist/pypy/lang/js/test/test_interp.py (original)
+++ pypy/dist/pypy/lang/js/test/test_interp.py Thu Jan 11 19:56:10 2007
@@ -356,6 +356,12 @@
print(y)
print(x)""", ["true", "false"])
+ def test_unarynot(self):
+ self.assert_prints("""
+ var x = false;
+ print(!x)
+ print(!!x)""", ["true", "false"])
+
def test_smallthings(self):
py.test.skip(" TODO: needed for mozilla test suite")
x = """
More information about the Pypy-commit
mailing list