summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/for_break.py12
-rw-r--r--tests/basics/for_return.py7
-rw-r--r--tests/basics/string_istest.py20
-rwxr-xr-xtests/run-tests15
4 files changed, 49 insertions, 5 deletions
diff --git a/tests/basics/for_break.py b/tests/basics/for_break.py
index fa8dabd150..f8bb0578e2 100644
--- a/tests/basics/for_break.py
+++ b/tests/basics/for_break.py
@@ -13,3 +13,15 @@ def foo():
i -= 1
foo()
+
+# break from within nested for loop
+def bar():
+ l = [1, 2, 3]
+ for e1 in l:
+ print(e1)
+ for e2 in l:
+ print(e1, e2)
+ if e2 == 2:
+ break
+
+bar()
diff --git a/tests/basics/for_return.py b/tests/basics/for_return.py
new file mode 100644
index 0000000000..0441352ad9
--- /dev/null
+++ b/tests/basics/for_return.py
@@ -0,0 +1,7 @@
+# test returning from within a for loop
+
+def f():
+ for i in [1, 2, 3]:
+ return i
+
+print(f())
diff --git a/tests/basics/string_istest.py b/tests/basics/string_istest.py
new file mode 100644
index 0000000000..7ea6c4508f
--- /dev/null
+++ b/tests/basics/string_istest.py
@@ -0,0 +1,20 @@
+print("".isspace())
+print(" \t\n\r\v\f".isspace())
+print("a".isspace())
+print(" \t\n\r\v\fa".isspace())
+print("".isalpha())
+print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".isalpha())
+print("0abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".isalpha())
+print("this ".isalpha())
+print("".isdigit())
+print("0123456789".isdigit())
+print("0123456789a".isdigit())
+print("0123456789 ".isdigit())
+print("".isupper())
+print("CHEESE-CAKE WITH ... _FROSTING_*99".isupper())
+print("aB".isupper())
+print("".islower())
+print("cheese-cake with ... _frosting_*99".islower())
+print("aB".islower())
+print("123".islower())
+print("123a".islower())
diff --git a/tests/run-tests b/tests/run-tests
index 102655abea..1e6dd50538 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -111,6 +111,7 @@ def run_tests(pyb, tests):
def main():
cmd_parser = argparse.ArgumentParser(description='Run tests for Micro Python.')
cmd_parser.add_argument('--pyboard', action='store_true', help='run the tests on the pyboard')
+ cmd_parser.add_argument('-d', '--test-dirs', nargs='*', help='input test directories (if no files given)')
cmd_parser.add_argument('files', nargs='*', help='input test files')
args = cmd_parser.parse_args()
@@ -122,12 +123,16 @@ def main():
pyb = None
if len(args.files) == 0:
- if pyb is None:
- # run PC tests
- test_dirs = ('basics', 'micropython', 'float', 'import', 'io', 'misc')
+ if args.test_dirs is None:
+ if pyb is None:
+ # run PC tests
+ test_dirs = ('basics', 'micropython', 'float', 'import', 'io', 'misc')
+ else:
+ # run pyboard tests
+ test_dirs = ('basics', 'float', 'pyb', 'pybnative', 'inlineasm')
else:
- # run pyboard tests
- test_dirs = ('basics', 'float', 'pyb', 'pybnative', 'inlineasm')
+ # run tests from these directories
+ test_dirs = args.test_dirs
tests = sorted(test_file for test_files in (glob('{}/*.py'.format(dir)) for dir in test_dirs) for test_file in test_files)
else:
# tests explicitly given