Skip to content

Commit

Permalink
Merge pull request #300 from dishmint:dishmint/issue296
Browse files Browse the repository at this point in the history
Update Tests to use M14 Test framework
  • Loading branch information
dishmint authored Feb 3, 2024
2 parents 72d0adc + 300f399 commit 8065a12
Show file tree
Hide file tree
Showing 27 changed files with 9,166 additions and 4,401 deletions.
3 changes: 2 additions & 1 deletion FaizonZaman/LexicalCases/PacletInfo.wl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ PacletObject[
"License" -> "MIT",
"PublisherID" -> "FaizonZaman",
"Version" -> "1.5.0",
"WolframVersion" -> "13.0+",
"WolframVersion" -> "13.3+",
"PrimaryContext" -> "FaizonZaman`LexicalCases`",
"Extensions" -> {
{
"Kernel",
Expand Down
12,960 changes: 8,801 additions & 4,159 deletions FaizonZaman/LexicalCases/ResourceDefinition.nb

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions FaizonZaman/LexicalCases/Tests/LexicalCases.wlt
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@ BeginTestSection["LexicalCases"]

(* STRINGS *)
(* Short Strings *)
VerificationTest[
TestCreate[
LexicalCases[$SampleSentence, $SampleStringExpression]["Data"],
{<|"Match" -> "best key lime pie", "Position" -> {{5, 21}}|>},
"TestID" -> "ShortStringTest1"
]

(* Documentation examples - BoundToken *)
VerificationTest[
TestCreate[
LexicalCases["The great machine whirs. The weak machines sputter.", "great " ~~ BoundToken["machine"]]["Data"],
{<|"Match" -> "great machine", "Position" -> {{5, 17}}|>},
"TestID" -> "LexicalCases-DocExamples-BoundToken-Test1"
]

VerificationTest[
TestCreate[
LexicalCases["The great machine whirs. The weak machines sputter.", "great " ~~ BoundToken["machine"]]["Data"],
{<|"Match" -> "great machine", "Position" -> {{5, 17}}|>},
"TestID" -> "LexicalCases-DocExamples-BoundToken-Test1"
]

VerificationTest[
TestCreate[
LexicalCases["The great machine whirs. The weak machines sputter.", "weak " ~~ BoundToken["machines"]]["Data"],
{<|"Match" -> "weak machines", "Position" -> {{30, 42}}|>},
"TestID" -> "LexicalCases-DocExamples-BoundToken-Test2"
]

VerificationTest[
TestCreate[
LexicalCases["The great machine whirs. The weak machines sputter.", "weak " ~~ BoundToken[RegularExpression["\\w+"]]]["Data"],
{<|"Match" -> "weak machines", "Position" -> {{30, 42}}|>},
"TestID" -> "LexicalCases-DocExamples-BoundToken-Test3"
]

VerificationTest[
TestCreate[
LexicalCases["He was number 1!", "number " ~~ BoundToken[DigitCharacter]]["Data"],
{<|"Match" -> "number 1", "Position" -> {{8, 15}}|>},
"TestID" -> "LexicalCases-DocExamples-BoundToken-Test4"
]

VerificationTest[
TestCreate[
LexicalCases["The great machine whirs. The weak machines sputter.", ("great" | "weak") ~~ " " ~~ BoundToken["machine" | "machines"]]["Data"],
{
<|"Match" -> "great machine", "Position" -> {{5, 17}}|>,
Expand All @@ -50,7 +50,7 @@ VerificationTest[

(* Documentation examples - WordToken *)

VerificationTest[
TestCreate[
LexicalCases[$SampleParagraph, WordToken[2] ~~ " screen"]["Data"],
{
<|"Match" -> "a blank screen", "Position" -> {{144, 157}}|>,
Expand All @@ -60,7 +60,7 @@ VerificationTest[
"TestID" -> "LexicalCases-DocExamples-WordToken-Test1"
]

VerificationTest[
TestCreate[
LexicalCases[$SampleParagraph, WordToken[2, 4] ~~ " screen"]["Data"],
{
<|"Match" -> "sat with a blank screen", "Position" -> {{135, 157}}|>,
Expand All @@ -70,7 +70,7 @@ VerificationTest[
"TestID" -> "LexicalCases-DocExamples-WordToken-Test2"
]

VerificationTest[
TestCreate[
Length[
Join@*Flatten@{
LexicalCases[$SampleParagraph, WordToken[2] ~~ " screen"]["Data"],
Expand All @@ -87,7 +87,7 @@ VerificationTest[
(* Documentation examples - OptionalToken *)


VerificationTest[
TestCreate[
LexicalCases["this is a cool string. this is a string.", "this is a" ~~ OptionalToken["cool"] ~~ "string"]["Data"],
{
<|"Match" -> "this is a cool string", "Position" -> {{1, 21}}|>,
Expand All @@ -97,7 +97,7 @@ VerificationTest[
]

(* Documentation examples - Sandwich *)
VerificationTest[
TestCreate[
LexicalCases[$SampleParagraph, Sandwich[WordToken[2, "KeepContractions"], " he "]]["Data"],
{
<|"Match" -> "but here he sat with", "Position" -> {{123, 142}}|>,
Expand All @@ -107,20 +107,20 @@ VerificationTest[
"TestID" -> "LexicalCases-DocExamples-Sandwich-Test1"
]

VerificationTest[
TestCreate[
LexicalCases["a nice car is good.", Sandwich[w : WordToken[1], BoundToken["car"]] :> w],
LexicalCases["a nice car is good.", Sandwich[w : WordToken[1], BoundToken["car"]] :> w],
"TestID" -> "LexicalCases-DocExamples-Sandwich-Test2"
]

(* Documentation examples - TextType *)
VerificationTest[
TestCreate[
LexicalCases[$SampleParagraph, adjective : TextType["Adjective"] ~~ " screen" :> adjective]["Data"],
{<|"Match" -> "blank", "Position" -> {{146, 157}, {181, 192}}|>},
"TestID" -> "LexicalCases-DocExamples-TextType-Test1"
]

VerificationTest[
TestCreate[
LexicalCases[$SampleParagraph, adjectiveOrDeterminer : TextType["Adjective" | "Determiner"] ~~ " screen" :> adjectiveOrDeterminer]["Data"],
{
<|"Match" -> "blank", "Position" -> {{146, 157}, {181, 192}}|>,
Expand All @@ -131,7 +131,7 @@ VerificationTest[

(* FILES *)

(* VerificationTest[
(* TestCreate[
LexicalCases[$SampleFile, $SampleStringExpression]["Data"],
[[RESULT]],
"TestID" -> "ShortStringTest1"
Expand All @@ -140,7 +140,7 @@ VerificationTest[
(* SearchIndexObjects *)


(* VerificationTest[
(* TestCreate[
LexicalCases[$SampleSearchIndexObject, $SampleStringExpression]["Data"],
[[RESULT]],
"TestID" -> "ShortStringTest1"
Expand All @@ -150,7 +150,7 @@ VerificationTest[
(* WIKIPEDIA - should wiki tests be in a separate file? *)


(* VerificationTest[
(* TestCreate[
LexicalCases[$SampleWikiQuery, $SampleWikiExpression]["Data"],
[[RESULT]],
"TestID" -> "ShortStringTest1"
Expand Down
2 changes: 1 addition & 1 deletion FaizonZaman/LexicalCases/Tests/LexicalStructure.wlt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BeginTestSection["LexicalStructure"]
(* LexicalStructure *)
VerificationTest[
TestCreate[
LexicalStructure[StringExpression["computer" | "computers", TextType["Verb"]]],
TextElement[
List[
Expand Down
22 changes: 11 additions & 11 deletions FaizonZaman/LexicalCases/Tests/Patterns.wlt
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,69 @@
BeginTestSection["Pattrerns"]

(* BoundToken *)
VerificationTest[
TestCreate[
BoundToken["machine"],
BoundToken["machine"],
"TestID" -> "BoundToken-Test1"
]

VerificationTest[
TestCreate[
BoundToken["machine"|"machines"],
BoundToken["machine"|"machines"],
"TestID" -> "BoundToken-Test2"
]

(* WordToken *)

VerificationTest[
TestCreate[
WordToken[3],
WordToken[3],
"TestID" -> "WordToken-Test1"
]

VerificationTest[
TestCreate[
WordToken[1,4],
WordToken[1,4],
"TestID" -> "WordToken-Test2"
]

(* OptionalToken *)

VerificationTest[
TestCreate[
OptionalToken[TextType["Adjective"]],
OptionalToken[TextType["Adjective"]],
"TestID" -> "OptionalToken-Test1"
]

VerificationTest[
TestCreate[
OptionalToken[adjective : TextType["Adjective"] ~~ "sentence"],
OptionalToken[adjective : TextType["Adjective"] ~~ "sentence"],
"TestID" -> "OptionalToken-Test2"
]

(* TextType *)

VerificationTest[
TestCreate[
TextType["Adjective"],
TextType["Adjective"],
"TestID" -> "TextType-Test1"
]

VerificationTest[
TestCreate[
TextType["Adjective"|"Noun"],
TextType["Adjective"|"Noun"],
"TestID" -> "TextType-Test2"
]

(* Sandwich *)

VerificationTest[
TestCreate[
Sandwich[TextType["Adjective"|"Noun"], " computer "],
(TextType["Adjective" | "Noun"] ~~ " computer " ~~ TextType["Adjective" | "Noun"]),
"TestID" -> "Sandwich-Test1"
]

VerificationTest[
TestCreate[
Sandwich[OptionalToken[TextType["Adjective"|"Noun"]], " computer "],
(OptionalToken[TextType["Adjective" | "Noun"]] ~~ " computer " ~~ OptionalToken[TextType["Adjective" | "Noun"]]),
"TestID" -> "Sandwich-Test2"
Expand All @@ -74,7 +74,7 @@ VerificationTest[

(* LexicalPattern *)

VerificationTest[
TestCreate[
LexicalPattern["Alice " ~~ TextType["Verb"] ~~ TextType["Adverb"]],
LexicalPattern["Alice " ~~ TextType["Verb"] ~~ TextType["Adverb"]],
"TestID" -> "LexicalPattern-Test1"
Expand Down
Loading

0 comments on commit 8065a12

Please sign in to comment.