Merge pull request #28 from mstriemer/fix-triple-shift-1019729
Fix the >>>= operator (bug 1019729)
This commit is contained in:
Коммит
42504ab240
|
@ -1,3 +1,4 @@
|
||||||
|
import ctypes
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from appvalidator.constants import MAX_STR_SIZE
|
from appvalidator.constants import MAX_STR_SIZE
|
||||||
|
@ -354,7 +355,8 @@ ASSIGNMENT_OPERATORS = {
|
||||||
"%=": lambda l, r, gl, gr: 0 if gr == 0 else (gl % gr),
|
"%=": lambda l, r, gl, gr: 0 if gr == 0 else (gl % gr),
|
||||||
"<<=": lambda l, r, gl, gr: int(gl) << int(gr),
|
"<<=": lambda l, r, gl, gr: int(gl) << int(gr),
|
||||||
">>=": lambda l, r, gl, gr: int(gl) >> int(gr),
|
">>=": lambda l, r, gl, gr: int(gl) >> int(gr),
|
||||||
">>>=": lambda l, r, gl, gr: float(abs(int(gl)) >> gr),
|
">>>=": lambda l, r, gl, gr: float(
|
||||||
|
ctypes.c_uint(int(gl)).value >> int(gr)),
|
||||||
"|=": lambda l, r, gl, gr: int(gl) | int(gr),
|
"|=": lambda l, r, gl, gr: int(gl) | int(gr),
|
||||||
"^=": lambda l, r, gl, gr: int(gl) ^ int(gr),
|
"^=": lambda l, r, gl, gr: int(gl) ^ int(gr),
|
||||||
"&=": lambda l, r, gl, gr: int(gl) & int(gr),
|
"&=": lambda l, r, gl, gr: int(gl) & int(gr),
|
||||||
|
|
|
@ -66,6 +66,8 @@ class TestCase(helper.TestCase):
|
||||||
Run the standard set of JS engine tests on the script passed via
|
Run the standard set of JS engine tests on the script passed via
|
||||||
`script`.
|
`script`.
|
||||||
"""
|
"""
|
||||||
|
print "Running", script
|
||||||
|
|
||||||
if self.err is None:
|
if self.err is None:
|
||||||
self.setup_err()
|
self.setup_err()
|
||||||
|
|
||||||
|
@ -90,6 +92,7 @@ class TestCase(helper.TestCase):
|
||||||
Assert that the value of a variable from the final script context
|
Assert that the value of a variable from the final script context
|
||||||
contains the value specified.
|
contains the value specified.
|
||||||
"""
|
"""
|
||||||
|
print "Testing {var} == {val}".format(var=name, val=value)
|
||||||
val = self.get_var(name)
|
val = self.get_var(name)
|
||||||
if isinstance(val, float):
|
if isinstance(val, float):
|
||||||
val *= 100000
|
val *= 100000
|
||||||
|
|
|
@ -170,3 +170,23 @@ class TestMathFuncs(TestCase):
|
||||||
""")
|
""")
|
||||||
|
|
||||||
# We really don't care about the output here.
|
# We really don't care about the output here.
|
||||||
|
|
||||||
|
def test_bit_shifting(self):
|
||||||
|
"""Test for bit shifting operators."""
|
||||||
|
self.setUp()
|
||||||
|
self.run_script("""
|
||||||
|
var x = 1;
|
||||||
|
x >>= 0;""")
|
||||||
|
self.assert_var_eq("x", 1)
|
||||||
|
self.run_script("""
|
||||||
|
var x = 1;
|
||||||
|
x >>= 1""")
|
||||||
|
self.assert_var_eq("x", 0)
|
||||||
|
self.run_script("""
|
||||||
|
var x = -1;
|
||||||
|
x >>= 0;""")
|
||||||
|
self.assert_var_eq("x", -1)
|
||||||
|
self.run_script("""
|
||||||
|
var x = -1;
|
||||||
|
x >>>= 0.2""")
|
||||||
|
self.assert_var_eq("x", 0xFFFFFFFF)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче