mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 20:50:14 +01:00
tests: Add tests for builtins: all, any, sum, abs.
This commit is contained in:
20
tests/basics/builtin_allany.py
Normal file
20
tests/basics/builtin_allany.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# test builtin "all" and "any"
|
||||
|
||||
tests = (
|
||||
(),
|
||||
[],
|
||||
[False],
|
||||
[True],
|
||||
[False, True],
|
||||
[True, False],
|
||||
[False, False],
|
||||
[True, True],
|
||||
(False for i in range(10)),
|
||||
(True for i in range(10)),
|
||||
)
|
||||
|
||||
for test in tests:
|
||||
print(all(test))
|
||||
|
||||
for test in tests:
|
||||
print(any(test))
|
||||
14
tests/basics/builtin_sum.py
Normal file
14
tests/basics/builtin_sum.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# test builtin "sum"
|
||||
|
||||
tests = (
|
||||
(),
|
||||
[],
|
||||
[0],
|
||||
[1],
|
||||
[0, 1, 2],
|
||||
(i for i in range(10)),
|
||||
)
|
||||
|
||||
for test in tests:
|
||||
print(sum(test))
|
||||
print(sum(test, -2))
|
||||
Reference in New Issue
Block a user