diff options
Diffstat (limited to 'tests/basics')
-rw-r--r-- | tests/basics/for_break.py | 12 | ||||
-rw-r--r-- | tests/basics/for_return.py | 7 | ||||
-rw-r--r-- | tests/basics/string_istest.py | 20 |
3 files changed, 39 insertions, 0 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()) |