Skip to content

builtin,vm: add implementation for builtin hex function #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
builtin,vm: fix builtin-hex test
  • Loading branch information
sbinet committed Nov 6, 2019
commit 33d8c20264eb18d74310f7ce2f898ac582d68a7b
16 changes: 16 additions & 0 deletions builtin/tests/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

from libtest import assertRaises

doc="abs"
assert abs(0) == 0
assert abs(10) == 10
Expand Down Expand Up @@ -151,6 +153,20 @@ def func(p):
ok = True
assert ok, "ValueError not raised"

doc="hex"
assert hex( 0)=="0x0", "hex(0)"
assert hex( 1)=="0x1", "hex(1)"
assert hex(42)=="0x2a", "hex(42)"
assert hex( -0)=="0x0", "hex(-0)"
assert hex( -1)=="-0x1", "hex(-1)"
assert hex(-42)=="-0x2a", "hex(-42)"
assert hex( 1<<64) == "0x10000000000000000", "hex(1<<64)"
assert hex(-1<<64) == "-0x10000000000000000", "hex(-1<<64)"
assert hex( 1<<128) == "0x100000000000000000000000000000000", "hex(1<<128)"
assert hex(-1<<128) == "-0x100000000000000000000000000000000", "hex(-1<<128)"
assertRaises(TypeError, hex, 10.0) ## TypeError: 'float' object cannot be interpreted as an integer
assertRaises(TypeError, hex, float(0)) ## TypeError: 'float' object cannot be interpreted as an integer

doc="iter"
cnt = 0
def f():
Expand Down
File renamed without changes.
14 changes: 0 additions & 14 deletions vm/tests/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,6 @@
else:
assert False, "SyntaxError not raised"

doc="hex"
assert True, hex( 0)=="0x0"
assert True, hex( 1)=="0x1"
assert True, hex(42)=="0x2a"
assert True, hex( -0)=="0x0"
assert True, hex( -1)=="-0x1"
assert True, hex(-42)=="-0x2a"
assert True, hex( 1<<64) == "0x10000000000000000"
assert True, hex(-1<<64) == "-0x10000000000000000"
assert True, hex( 1<<128) == "0x100000000000000000000000000000000"
assert True, hex(-1<<128) == "-0x100000000000000000000000000000000"
assertRaises(TypeError, hex, 10.0) ## TypeError: 'float' object cannot be interpreted as an integer
assertRaises(TypeError, hex, float(0)) ## TypeError: 'float' object cannot be interpreted as an integer

doc="isinstance"
class A:
pass
Expand Down