Skip to content

Commit f446791

Browse files
sbinetncw
authored andcommitted
builtin,vm: fix builtin-hex test
1 parent 93edaf3 commit f446791

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

builtin/tests/builtin.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
44

5+
from libtest import assertRaises
6+
57
doc="abs"
68
assert abs(0) == 0
79
assert abs(10) == 10
@@ -151,6 +153,20 @@ def func(p):
151153
ok = True
152154
assert ok, "ValueError not raised"
153155

156+
doc="hex"
157+
assert hex( 0)=="0x0", "hex(0)"
158+
assert hex( 1)=="0x1", "hex(1)"
159+
assert hex(42)=="0x2a", "hex(42)"
160+
assert hex( -0)=="0x0", "hex(-0)"
161+
assert hex( -1)=="-0x1", "hex(-1)"
162+
assert hex(-42)=="-0x2a", "hex(-42)"
163+
assert hex( 1<<64) == "0x10000000000000000", "hex(1<<64)"
164+
assert hex(-1<<64) == "-0x10000000000000000", "hex(-1<<64)"
165+
assert hex( 1<<128) == "0x100000000000000000000000000000000", "hex(1<<128)"
166+
assert hex(-1<<128) == "-0x100000000000000000000000000000000", "hex(-1<<128)"
167+
assertRaises(TypeError, hex, 10.0) ## TypeError: 'float' object cannot be interpreted as an integer
168+
assertRaises(TypeError, hex, float(0)) ## TypeError: 'float' object cannot be interpreted as an integer
169+
154170
doc="iter"
155171
cnt = 0
156172
def f():
File renamed without changes.

vm/tests/builtin.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,6 @@
6666
else:
6767
assert False, "SyntaxError not raised"
6868

69-
doc="hex"
70-
assert True, hex( 0)=="0x0"
71-
assert True, hex( 1)=="0x1"
72-
assert True, hex(42)=="0x2a"
73-
assert True, hex( -0)=="0x0"
74-
assert True, hex( -1)=="-0x1"
75-
assert True, hex(-42)=="-0x2a"
76-
assert True, hex( 1<<64) == "0x10000000000000000"
77-
assert True, hex(-1<<64) == "-0x10000000000000000"
78-
assert True, hex( 1<<128) == "0x100000000000000000000000000000000"
79-
assert True, hex(-1<<128) == "-0x100000000000000000000000000000000"
80-
assertRaises(TypeError, hex, 10.0) ## TypeError: 'float' object cannot be interpreted as an integer
81-
assertRaises(TypeError, hex, float(0)) ## TypeError: 'float' object cannot be interpreted as an integer
82-
8369
doc="isinstance"
8470
class A:
8571
pass

0 commit comments

Comments
 (0)