From 6d0f04375df942985292d0a6b6e487db9a09f3fa Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 16 Sep 2024 15:12:54 -0400 Subject: Have Text:matches() return an optional array of matches --- test/paths.tm | 2 +- test/text.tm | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/paths.tm b/test/paths.tm index 4ef0b028..92a14640 100644 --- a/test/paths.tm +++ b/test/paths.tm @@ -84,7 +84,7 @@ func main(): >> (./foo.txt):ends_with(".txt") = yes >> (./foo.txt):matches($|{..}/foo{..}|) - = yes + = [".", ".txt"]? >> (./foo.txt):replace($/.txt/, ".md") = (./foo.md) diff --git a/test/text.tm b/test/text.tm index f27eaf37..f87cedfb 100644 --- a/test/text.tm +++ b/test/text.tm @@ -251,13 +251,19 @@ func main(): = " good(x, fn(y), BAD(z), w) " >> "Hello":matches($/{id}/) - = yes + = ["Hello"]? >> "Hello":matches($/{lower}/) - = no + = ![Text] >> "Hello":matches($/{upper}/) - = no + = ![Text] >> "Hello...":matches($/{id}/) - = no + = ![Text] + + if matches := "hello world":matches($/{id} {id}/): + >> matches + = ["hello", "world"] + else: + fail("Failed to match") >> "hello world":map($/world/, Text.upper) = "hello WORLD" -- cgit v1.2.3