Skip to content

Commit 24ffb8e

Browse files
committed
tests: Add tests for builtins: all, any, sum, abs.
1 parent db1e10d commit 24ffb8e

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

tests/basics/builtin_allany.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# test builtin "all" and "any"
2+
3+
tests = (
4+
(),
5+
[],
6+
[False],
7+
[True],
8+
[False, True],
9+
[True, False],
10+
[False, False],
11+
[True, True],
12+
(False for i in range(10)),
13+
(True for i in range(10)),
14+
)
15+
16+
for test in tests:
17+
print(all(test))
18+
19+
for test in tests:
20+
print(any(test))

tests/basics/builtin_sum.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# test builtin "sum"
2+
3+
tests = (
4+
(),
5+
[],
6+
[0],
7+
[1],
8+
[0, 1, 2],
9+
(i for i in range(10)),
10+
)
11+
12+
for test in tests:
13+
print(sum(test))
14+
print(sum(test, -2))

tests/float/complex1.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@
2626
#print(1j / 2j) uPy doesn't print correctly
2727
#print(1j ** 2) uPy doesn't print correctly
2828
#print(1j ** 2j) uPy doesn't print correctly
29+
30+
# builtin abs
31+
print(abs(1j))
32+
print(abs(1j + 2))

0 commit comments

Comments
 (0)