Skip to content

Commit 460be40

Browse files
committed
merge basic_types.py to builtin_type.py
1 parent 2c18207 commit 460be40

File tree

2 files changed

+66
-65
lines changed

2 files changed

+66
-65
lines changed

extra_tests/snippets/basic_types.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

extra_tests/snippets/builtin_type.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,69 @@
1+
from testutils import assert_raises
2+
3+
4+
# Spec: https://docs.python.org/2/library/types.html
5+
print(None)
6+
# TypeType
7+
# print(True) # LOAD_NAME???
8+
print(1)
9+
# print(1L) # Long
10+
print(1.1)
11+
# ComplexType
12+
print("abc")
13+
# print(u"abc")
14+
# Structural below
15+
print((1, 2)) # Tuple can be any length, but fixed after declared
16+
x = (1,2)
17+
print(x[0]) # Tuple can be any length, but fixed after declared
18+
print([1, 2, 3])
19+
# print({"first":1,"second":2})
20+
21+
print(int(1))
22+
print(int(1.2))
23+
print(float(1))
24+
print(float(1.2))
25+
26+
assert type(1 - 2) is int
27+
assert type(2 / 3) is float
28+
x = 1
29+
assert type(x) is int
30+
assert type(x - 1) is int
31+
32+
a = bytes([1, 2, 3])
33+
print(a)
34+
b = bytes([1, 2, 3])
35+
assert a == b
36+
37+
with assert_raises(TypeError):
38+
bytes([object()])
39+
40+
with assert_raises(TypeError):
41+
bytes(1.0)
42+
43+
with assert_raises(ValueError):
44+
bytes(-1)
45+
46+
a = bytearray([1, 2, 3])
47+
# assert a[1] == 2
48+
49+
assert int() == 0
50+
51+
a = complex(2, 4)
52+
assert type(a) is complex
53+
assert type(a + a) is complex
54+
assert repr(a) == '(2+4j)'
55+
a = 10j
56+
assert repr(a) == '10j'
57+
58+
a = 1
59+
assert a.conjugate() == a
60+
61+
a = 12345
62+
63+
b = a*a*a*a*a*a*a*a
64+
assert b.bit_length() == 109
65+
66+
167
assert type.__module__ == 'builtins'
268
assert type.__qualname__ == 'type'
369
assert type.__name__ == 'type'

0 commit comments

Comments
 (0)