From 1609f855828d2b932542b3a46158619a7c574555 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 20 Mar 2014 23:41:04 +0000 Subject: Rename test so that it doesn't clash with Python math module. --- tests/basics/math-fun.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/basics/math.py | 49 ------------------------------------------------ 2 files changed, 49 insertions(+), 49 deletions(-) create mode 100644 tests/basics/math-fun.py delete mode 100644 tests/basics/math.py (limited to 'tests') diff --git a/tests/basics/math-fun.py b/tests/basics/math-fun.py new file mode 100644 index 000000000..f5ffbf40d --- /dev/null +++ b/tests/basics/math-fun.py @@ -0,0 +1,49 @@ +# Tests the functions imported from math + +from math import * + +test_values = [-100., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 100.] +p_test_values = [0.1, 0.5, 1.23456] +unit_range_test_values = [-1., -0.75, -0.5, -0.25, 0., 0.25, 0.5, 0.75, 1.] +#IEEE_test_values = [1, 0, float('NaN'), float('Inf'), -float('NaN'), -float('Inf')] +#TODO: float('NaN') + +functions = [(sqrt, p_test_values), + (exp, test_values), + (expm1, test_values), + (log, p_test_values), + (log2, p_test_values), + (log10, p_test_values), + (cosh, test_values), + (sinh, test_values), + (tanh, test_values), + (acosh, [1.0, 5.0, 1.0]), + (asinh, test_values), + (atanh, [-0.99, -0.5, 0.0, 0.5, 0.99]), + (cos, test_values), + (sin, test_values), + (tan, test_values), + (acos, unit_range_test_values), + (asin, unit_range_test_values), + (atan, test_values), + (ceil, test_values), + (fabs, test_values), + (floor, test_values), + #(frexp, test_values), + #(isfinite, [1, 0, float('NaN'), float('Inf')]) + (trunc, test_values) + ] + +for function, test_vals in functions: + for value in test_vals: + print("{:8.7f}".format(function(value))) + +binary_functions = [(copysign, [(23., 42.), (-23., 42.), (23., -42.), + (-23., -42.), (1., 0.0), (1., -0.0)]) + ] + +#for function, test_vals in binary_functions: +# for value1, value2 in test_vals: +# print("{:8.7f}".format(function(value1, value2))) + + diff --git a/tests/basics/math.py b/tests/basics/math.py deleted file mode 100644 index f5ffbf40d..000000000 --- a/tests/basics/math.py +++ /dev/null @@ -1,49 +0,0 @@ -# Tests the functions imported from math - -from math import * - -test_values = [-100., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 100.] -p_test_values = [0.1, 0.5, 1.23456] -unit_range_test_values = [-1., -0.75, -0.5, -0.25, 0., 0.25, 0.5, 0.75, 1.] -#IEEE_test_values = [1, 0, float('NaN'), float('Inf'), -float('NaN'), -float('Inf')] -#TODO: float('NaN') - -functions = [(sqrt, p_test_values), - (exp, test_values), - (expm1, test_values), - (log, p_test_values), - (log2, p_test_values), - (log10, p_test_values), - (cosh, test_values), - (sinh, test_values), - (tanh, test_values), - (acosh, [1.0, 5.0, 1.0]), - (asinh, test_values), - (atanh, [-0.99, -0.5, 0.0, 0.5, 0.99]), - (cos, test_values), - (sin, test_values), - (tan, test_values), - (acos, unit_range_test_values), - (asin, unit_range_test_values), - (atan, test_values), - (ceil, test_values), - (fabs, test_values), - (floor, test_values), - #(frexp, test_values), - #(isfinite, [1, 0, float('NaN'), float('Inf')]) - (trunc, test_values) - ] - -for function, test_vals in functions: - for value in test_vals: - print("{:8.7f}".format(function(value))) - -binary_functions = [(copysign, [(23., 42.), (-23., 42.), (23., -42.), - (-23., -42.), (1., 0.0), (1., -0.0)]) - ] - -#for function, test_vals in binary_functions: -# for value1, value2 in test_vals: -# print("{:8.7f}".format(function(value1, value2))) - - -- cgit v1.2.3 From 613a8e3edf078c284bd981426cc5a256eabb2323 Mon Sep 17 00:00:00 2001 From: xbe Date: Tue, 18 Mar 2014 00:06:29 -0700 Subject: Implement str.partition and add tests for it. --- tests/basics/string_partition.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/basics/string_partition.py (limited to 'tests') diff --git a/tests/basics/string_partition.py b/tests/basics/string_partition.py new file mode 100644 index 000000000..ad70d0250 --- /dev/null +++ b/tests/basics/string_partition.py @@ -0,0 +1,29 @@ +print("asdf".partition('g')) +print("asdf".partition('a')) +print("asdf".partition('s')) +print("asdf".partition('f')) +print("asdf".partition('d')) +print("asdf".partition('asd')) +print("asdf".partition('sdf')) +print("asdf".partition('as')) +print("asdf".partition('df')) +print("asdf".partition('asdf')) +print("asdf".partition('asdfa')) +print("asdf".partition('fasdf')) +print("asdf".partition('fasdfa')) +print("abba".partition('a')) +print("abba".partition('b')) + +try: + print("asdf".partition(1)) +except TypeError: + print("Raised TypeError") +else: + print("Did not raise TypeError") + +try: + print("asdf".partition('')) +except ValueError: + print("Raised ValueError") +else: + print("Did not raise ValueError") -- cgit v1.2.3 From 4504ea8007bbc97aef51ced20a9ff3f460cd7caf Mon Sep 17 00:00:00 2001 From: xbe Date: Wed, 19 Mar 2014 00:46:14 -0700 Subject: Implement str.rpartition and add tests for it. --- tests/basics/string_rpartition.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/basics/string_rpartition.py (limited to 'tests') diff --git a/tests/basics/string_rpartition.py b/tests/basics/string_rpartition.py new file mode 100644 index 000000000..656121c94 --- /dev/null +++ b/tests/basics/string_rpartition.py @@ -0,0 +1,29 @@ +print("asdf".rpartition('g')) +print("asdf".rpartition('a')) +print("asdf".rpartition('s')) +print("asdf".rpartition('f')) +print("asdf".rpartition('d')) +print("asdf".rpartition('asd')) +print("asdf".rpartition('sdf')) +print("asdf".rpartition('as')) +print("asdf".rpartition('df')) +print("asdf".rpartition('asdf')) +print("asdf".rpartition('asdfa')) +print("asdf".rpartition('fasdf')) +print("asdf".rpartition('fasdfa')) +print("abba".rpartition('a')) +print("abba".rpartition('b')) + +try: + print("asdf".rpartition(1)) +except TypeError: + print("Raised TypeError") +else: + print("Did not raise TypeError") + +try: + print("asdf".rpartition('')) +except ValueError: + print("Raised ValueError") +else: + print("Did not raise ValueError") -- cgit v1.2.3 From 42901554db49cd1204054ea695cea6ee4e368b1e Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 22 Mar 2014 00:02:32 +0200 Subject: objint_longlong: Add regression test for improper inplace op implementation. --- tests/basics/int-long.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/basics/int-long.py b/tests/basics/int-long.py index f867d8037..3567e08b2 100644 --- a/tests/basics/int-long.py +++ b/tests/basics/int-long.py @@ -37,3 +37,10 @@ a <<= 5 print(a) a >>= 1 print(a) + +# Test referential integrity of long ints +a = 0x1ffffffff +b = a +a += 1 +print(a) +print(b) -- cgit v1.2.3 From 1ecea7c7539e73f105fef25da8a3bde7783da755 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 21 Mar 2014 23:46:59 +0200 Subject: py: Make 'bytes' be a proper type, support standard constructor args. --- tests/basics/bytes.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/basics/bytes.py b/tests/basics/bytes.py index 7d0cf22d4..a084bc399 100644 --- a/tests/basics/bytes.py +++ b/tests/basics/bytes.py @@ -4,8 +4,36 @@ print(str(a)) print(repr(a)) print(a[0], a[2]) print(a[-1]) +print(str(a, "utf-8")) +print(str(a, "utf-8", "ignore")) +try: + str(a, "utf-8", "ignore", "toomuch") +except TypeError: + print("TypeError") s = 0 for i in a: s += i print(s) + + +print(bytes("abc", "utf-8")) +print(bytes("abc", "utf-8", "replace")) +try: + bytes("abc") +except TypeError: + print("TypeError") +try: + bytes("abc", "utf-8", "replace", "toomuch") +except TypeError: + print("TypeError") + +print(bytes(3)) + +print(bytes([3, 2, 1])) +print(bytes(range(5))) + +def gen(): + for i in range(4): + yield i +print(bytes(gen())) -- cgit v1.2.3