From 460be4038102b4c2a4b2dcd3d316a925e512ef30 Mon Sep 17 00:00:00 2001 From: Jeong Yunwon Date: Wed, 4 May 2022 00:04:06 +0900 Subject: [PATCH] merge basic_types.py to builtin_type.py --- extra_tests/snippets/basic_types.py | 65 --------------------------- extra_tests/snippets/builtin_type.py | 66 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 65 deletions(-) delete mode 100644 extra_tests/snippets/basic_types.py diff --git a/extra_tests/snippets/basic_types.py b/extra_tests/snippets/basic_types.py deleted file mode 100644 index 5f6681c93..000000000 --- a/extra_tests/snippets/basic_types.py +++ /dev/null @@ -1,65 +0,0 @@ -from testutils import assert_raises - - -# Spec: https://docs.python.org/2/library/types.html -print(None) -# TypeType -# print(True) # LOAD_NAME??? -print(1) -# print(1L) # Long -print(1.1) -# ComplexType -print("abc") -# print(u"abc") -# Structural below -print((1, 2)) # Tuple can be any length, but fixed after declared -x = (1,2) -print(x[0]) # Tuple can be any length, but fixed after declared -print([1, 2, 3]) -# print({"first":1,"second":2}) - -print(int(1)) -print(int(1.2)) -print(float(1)) -print(float(1.2)) - -assert type(1 - 2) is int -assert type(2 / 3) is float -x = 1 -assert type(x) is int -assert type(x - 1) is int - -a = bytes([1, 2, 3]) -print(a) -b = bytes([1, 2, 3]) -assert a == b - -with assert_raises(TypeError): - bytes([object()]) - -with assert_raises(TypeError): - bytes(1.0) - -with assert_raises(ValueError): - bytes(-1) - -a = bytearray([1, 2, 3]) -# assert a[1] == 2 - -assert int() == 0 - -a = complex(2, 4) -assert type(a) is complex -assert type(a + a) is complex -assert repr(a) == '(2+4j)' -a = 10j -assert repr(a) == '10j' - -a = 1 -assert a.conjugate() == a - -a = 12345 - -b = a*a*a*a*a*a*a*a -assert b.bit_length() == 109 - diff --git a/extra_tests/snippets/builtin_type.py b/extra_tests/snippets/builtin_type.py index 75c571edd..aa4fb31ee 100644 --- a/extra_tests/snippets/builtin_type.py +++ b/extra_tests/snippets/builtin_type.py @@ -1,3 +1,69 @@ +from testutils import assert_raises + + +# Spec: https://docs.python.org/2/library/types.html +print(None) +# TypeType +# print(True) # LOAD_NAME??? +print(1) +# print(1L) # Long +print(1.1) +# ComplexType +print("abc") +# print(u"abc") +# Structural below +print((1, 2)) # Tuple can be any length, but fixed after declared +x = (1,2) +print(x[0]) # Tuple can be any length, but fixed after declared +print([1, 2, 3]) +# print({"first":1,"second":2}) + +print(int(1)) +print(int(1.2)) +print(float(1)) +print(float(1.2)) + +assert type(1 - 2) is int +assert type(2 / 3) is float +x = 1 +assert type(x) is int +assert type(x - 1) is int + +a = bytes([1, 2, 3]) +print(a) +b = bytes([1, 2, 3]) +assert a == b + +with assert_raises(TypeError): + bytes([object()]) + +with assert_raises(TypeError): + bytes(1.0) + +with assert_raises(ValueError): + bytes(-1) + +a = bytearray([1, 2, 3]) +# assert a[1] == 2 + +assert int() == 0 + +a = complex(2, 4) +assert type(a) is complex +assert type(a + a) is complex +assert repr(a) == '(2+4j)' +a = 10j +assert repr(a) == '10j' + +a = 1 +assert a.conjugate() == a + +a = 12345 + +b = a*a*a*a*a*a*a*a +assert b.bit_length() == 109 + + assert type.__module__ == 'builtins' assert type.__qualname__ == 'type' assert type.__name__ == 'type'