From 478a2e50021576a40a80a4c6034a3b1938aafe98 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 11 Oct 2025 14:27:56 +0100 Subject: [PATCH] add some more tests from freeCodeCamp tutorial --- temp.txt | 1 + test/regex-tests.sml | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/temp.txt b/temp.txt index 04de606..884f3c8 100644 --- a/temp.txt +++ b/temp.txt @@ -1,3 +1,4 @@ gut feeling Mississipi goooal +favorite diff --git a/test/regex-tests.sml b/test/regex-tests.sml index ebef72b..c851083 100644 --- a/test/regex-tests.sml +++ b/test/regex-tests.sml @@ -551,6 +551,44 @@ struct in Expect.isTrue isExpected end) + , test "chewie quote" (fn _ => + let + (* arrange *) + val sentence = "Aaaaaaargh" + val regexString = "Aa*" + val dfa = CsDfa.fromString regexString + + (* act *) + val matches = CsDfa.matchString (dfa, sentence) + + (* assert *) + val expectedMatches = [(0, 6)] + in + Expect.isTrue (matches = expectedMatches) + end) + , test "favorite" (fn _ => + let + (* arrange *) + val sentenceWithoutU = "favorite" + val sentenceWithU = "favourite" + + val regexString = "favou?rite" + val dfa = CsDfa.fromString regexString + + (* act *) + val matchesWithoutU = CsDfa.matchString (dfa, sentenceWithoutU) + val matchesWithU = CsDfa.matchString (dfa, sentenceWithU) + + (* assert *) + val expectedMatchesWithoutU = [(0, 7)] + val expectedMatchesWithU = [(0, 8)] + + val isExpected = + matchesWithoutU = expectedMatchesWithoutU + andalso matchesWithU = expectedMatchesWithU + in + Expect.isTrue isExpected + end) ] val tests =