Skip to content

Commit 836ac01

Browse files
committed
TEST: Cast for unsigned int with neg value
1 parent df26331 commit 836ac01

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

integration_tests/cast_02.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,46 @@ def test_02():
3434
print(w)
3535
assert w == u32(11)
3636

37+
def test_03():
38+
x : u32 = u32(-10)
39+
print(x)
40+
assert x == u32(4294967286)
41+
42+
y: u16 = u16(x)
43+
print(y)
44+
assert y == u16(65526)
45+
46+
z: u64 = u64(y)
47+
print(z)
48+
assert z == u64(65526)
49+
50+
w: u8 = u8(z)
51+
print(w)
52+
assert w == u8(246)
53+
54+
def test_04():
55+
x : u64 = u64(-11)
56+
print(x)
57+
# TODO: We are unable to store the following u64 in AST/R
58+
# assert x == u64(18446744073709551605)
59+
60+
y: u8 = u8(x)
61+
print(y)
62+
assert y == u8(245)
63+
64+
z: u16 = u16(y)
65+
print(z)
66+
assert z == u16(245)
67+
68+
w: u32 = u32(z)
69+
print(w)
70+
assert w == u32(245)
71+
3772

3873
def main0():
3974
test_01()
4075
test_02()
76+
test_03()
77+
test_04()
4178

4279
main0()

0 commit comments

Comments
 (0)