Python: Run match tests if Python 3.10 or newer

Also fixes a bug in the tests
This commit is contained in:
Rasmus Wriedt Larsen
2022-02-01 15:37:22 +01:00
parent a4bb0cc5d8
commit d6f415bae2
2 changed files with 9 additions and 4 deletions

View File

@@ -48,8 +48,8 @@ def test_or_pattern():
# No flow for literal pattern
def test_literal_pattern():
match SOURCE:
case 42 as x:
SINK(x) #$ flow="SOURCE, l:-2 -> x" flow="42, l:-1 -> x"
case "source" as x:
SINK(x) #$ flow="SOURCE, l:-2 -> x" flow="'source', l:-1 -> x"
def test_capture_pattern():
match SOURCE:

View File

@@ -1,3 +1,5 @@
import sys
def check_output(outtext, f):
if outtext == "OK\n":
pass
@@ -59,8 +61,11 @@ if __name__ == "__main__":
check_tests_valid("module-initialization.multiphase")
check_tests_valid("fieldflow.test")
# The below will fail unless we use Python 3.10 or newer.
# check_tests_valid("match.test")
if sys.version_info[:2] >= (3, 10):
print("INFO: Will run `match` tests since we're running Python 3.10 or newer")
check_tests_valid("match.test")
else:
print("WARN: Skipping `match` tests since we're not running 3.10 or newer")
# The below fails when trying to import modules
# check_tests_valid("module-initialization.test")