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+
fromlibtestimportassertRaises
6+
57
doc="abs"
68
assertabs(0) ==0
79
assertabs(10) ==10
@@ -151,6 +153,20 @@ def func(p):
151153
ok=True
152154
assertok, "ValueError not raised"
153155

156+
doc="hex"
157+
asserthex( 0)=="0x0", "hex(0)"
158+
asserthex( 1)=="0x1", "hex(1)"
159+
asserthex(42)=="0x2a", "hex(42)"
160+
asserthex( -0)=="0x0", "hex(-0)"
161+
asserthex( -1)=="-0x1", "hex(-1)"
162+
asserthex(-42)=="-0x2a", "hex(-42)"
163+
asserthex( 1<<64) =="0x10000000000000000", "hex(1<<64)"
164+
asserthex(-1<<64) =="-0x10000000000000000", "hex(-1<<64)"
165+
asserthex( 1<<128) =="0x100000000000000000000000000000000", "hex(1<<128)"
166+
asserthex(-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
deff():

‎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
assertFalse, "SyntaxError not raised"
6868

69-
doc="hex"
70-
assertTrue, hex( 0)=="0x0"
71-
assertTrue, hex( 1)=="0x1"
72-
assertTrue, hex(42)=="0x2a"
73-
assertTrue, hex( -0)=="0x0"
74-
assertTrue, hex( -1)=="-0x1"
75-
assertTrue, hex(-42)=="-0x2a"
76-
assertTrue, hex( 1<<64) =="0x10000000000000000"
77-
assertTrue, hex(-1<<64) =="-0x10000000000000000"
78-
assertTrue, hex( 1<<128) =="0x100000000000000000000000000000000"
79-
assertTrue, 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
classA:
8571
pass

0 commit comments

Comments
(0)