add some more tests from freeCodeCamp tutorial
This commit is contained in:
1
temp.txt
1
temp.txt
@@ -1,3 +1,4 @@
|
|||||||
gut feeling
|
gut feeling
|
||||||
Mississipi
|
Mississipi
|
||||||
goooal
|
goooal
|
||||||
|
favorite
|
||||||
|
|||||||
@@ -551,6 +551,44 @@ struct
|
|||||||
in
|
in
|
||||||
Expect.isTrue isExpected
|
Expect.isTrue isExpected
|
||||||
end)
|
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 =
|
val tests =
|
||||||
|
|||||||
Reference in New Issue
Block a user