Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded tests for acronym and all-your-base exercises using not deprecated functionality #144

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions exercises/practice/acronym/.meta/testAnnotation.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[
{
"name": "acronym.test.basic",
"test_code": "Test.expect (abbreviate \"Portable Network Graphics\" === \"PNG\")"
"name": "basic",
"test_code": "verify do\n labeled \"basic\" do\n expected = \"PNG\"\n actual = abbreviate \"Portable Network Graphics\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual actual expected"
},
{
"name": "acronym.test.lowercaseWords",
"test_code": "Test.expect (abbreviate \"Ruby on Rails\" === \"ROR\")"
"name": "lowercase words",
"test_code": "verify do\n labeled \"lowercase words\" do\n expected = \"ROR\"\n actual = abbreviate \"Ruby on Rails\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual actual expected"
},
{
"name": "acronym.test.punctuation",
"test_code": "Test.expect (abbreviate \"First In, First Out\" === \"FIFO\")"
"name": "punctuation",
"test_code": "verify do\n labeled \"punctuation\" do\n expected = \"FIFO\"\n actual = abbreviate \"First In, First Out\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual actual expected"
},
{
"name": "acronym.test.allCapsWord",
"test_code": "Test.expect (abbreviate \"GNU Image Manipulation Program\" === \"GIMP\")"
"name": "all caps word",
"test_code": "verify do\n labeled \"all caps word\" do\n expected = \"GIMP\"\n actual = abbreviate \"GNU Image Manipulation Program\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual actual expected"
},
{
"name": "acronym.test.punctuationWithoutWhitespace",
"test_code": "Test.expect (abbreviate \"Complementary metal-oxide semiconductor\" === \"CMOS\")"
"name": "punctuation without whitespace",
"test_code": "verify do\n labeled \"punctuation without whitespace\" do\n expected = \"CMOS\"\n actual = abbreviate \"Complementary metal-oxide semiconductor\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual actual expected"
},
{
"name": "acronym.test.veryLongAbbreviation",
"test_code": "Test.expect (abbreviate \"Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me\" === \"ROTFLSHTMDCOALM\")"
"name": "very long abbreviation",
"test_code": "verify do\n labeled \"very long abbreviation\" do\n expected = \"ROTFLSHTMDCOALM\"\n actual = abbreviate \"Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual actual expected"
},
{
"name": "acronym.test.consecutiveDelimiters",
"test_code": "Test.expect (abbreviate \"Something - I made up from thin air\" === \"SIMUFTA\")"
"name": "consecutive delimiters",
"test_code": "verify do\n labeled \"consecutive delimiters\" do\n expected = \"SIMUFTA\"\n actual = abbreviate \"Something - I made up from thin air\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual actual expected"
},
{
"name": "acronym.test.apostrophes",
"test_code": "Test.expect (abbreviate \"Halley's Comet\" === \"HC\")"
"name": "apostrophes",
"test_code": "verify do\n labeled \"apostrophes\" do\n expected = \"HC\"\n actual = abbreviate \"Halley's Comet\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual actual expected"
},
{
"name": "acronym.test.underscoreEmphasis",
"test_code": "Test.expect (abbreviate \"The Road _Not_ Taken\" === \"TRNT\")"
"name": "underscore emphasis",
"test_code": "verify do\n labeled \"underscore emphasis\" do\n expected = \"TRNT\"\n actual = abbreviate \"The Road _Not_ Taken\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual actual expected"
}
]
]
83 changes: 64 additions & 19 deletions exercises/practice/acronym/acronym.test.u
Original file line number Diff line number Diff line change
@@ -1,34 +1,79 @@
use base.test.Test

acronym.test.basic =
Test.expect (abbreviate "Portable Network Graphics" === "PNG")
acronym.test.basic = verify do
labeled "basic" do
expected = "PNG"
actual = abbreviate "Portable Network Graphics"
label "expected" expected
label "actual" actual
ensureEqual actual expected

acronym.test.lowercaseWords =
Test.expect (abbreviate "Ruby on Rails" === "ROR")
acronym.test.lowercaseWords = verify do
labeled "lowercase words" do
expected = "ROR"
actual = abbreviate "Ruby on Rails"
label "expected" expected
label "actual" actual
ensureEqual actual expected

acronym.test.punctuation =
Test.expect (abbreviate "First In, First Out" === "FIFO")
acronym.test.punctuation = verify do
labeled "punctuation" do
expected = "FIFO"
actual = abbreviate "First In, First Out"
label "expected" expected
label "actual" actual
ensureEqual actual expected

acronym.test.allCapsWord =
Test.expect (abbreviate "GNU Image Manipulation Program" === "GIMP")
acronym.test.allCapsWord = verify do
labeled "all caps word" do
expected = "GIMP"
actual = abbreviate "GNU Image Manipulation Program"
label "expected" expected
label "actual" actual
ensureEqual actual expected

acronym.test.punctuationWithoutWhitespace =
Test.expect (abbreviate "Complementary metal-oxide semiconductor" === "CMOS")
acronym.test.punctuationWithoutWhitespace = verify do
labeled "punctuation without whitespace" do
expected = "CMOS"
actual = abbreviate "Complementary metal-oxide semiconductor"
label "expected" expected
label "actual" actual
ensureEqual actual expected

acronym.test.veryLongAbbreviation =
Test.expect (abbreviate "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" === "ROTFLSHTMDCOALM")
acronym.test.veryLongAbbreviation = verify do
labeled "very long abbreviation" do
expected = "ROTFLSHTMDCOALM"
actual = abbreviate "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me"
label "expected" expected
label "actual" actual
ensureEqual actual expected

acronym.test.consecutiveDelimiters =
Test.expect (abbreviate "Something - I made up from thin air" === "SIMUFTA")
acronym.test.consecutiveDelimiters = verify do
labeled "consecutive delimiters" do
expected = "SIMUFTA"
actual = abbreviate "Something - I made up from thin air"
label "expected" expected
label "actual" actual
ensureEqual actual expected

acronym.test.apostrophes =
Test.expect (abbreviate "Halley's Comet" === "HC")
acronym.test.apostrophes = verify do
labeled "apostrophes" do
expected = "HC"
actual = abbreviate "Halley's Comet"
label "expected" expected
label "actual" actual
ensureEqual actual expected

acronym.test.underscoreEmphasis =
Test.expect (abbreviate "The Road _Not_ Taken" === "TRNT")
acronym.test.underscoreEmphasis = verify do
labeled "underscore emphasis" do
expected = "TRNT"
actual = abbreviate "The Road _Not_ Taken"
label "expected" expected
label "actual" actual
ensureEqual actual expected

test> acronym.tests =
runAll [
join [
acronym.test.basic,
acronym.test.lowercaseWords,
acronym.test.punctuation,
Expand Down
44 changes: 22 additions & 22 deletions exercises/practice/all-your-base/.meta/testAnnotation.json
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@
[
{
"name": "single bit one to decimal",
"test_code": "let\n Test.label.deprecated \"single bit one to decimal\" <| Test.expect (rebase +2 [+1] +10 === Some [+1])"
"test_code": "verify do\n labeled \"single bit one to decimal\" do\n expected = Some [+1]\n actual = rebase +2 [+1] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "binary to single decimal",
"test_code": "let\n Test.label.deprecated \"binary to single decimal\" <| Test.expect (rebase +2 [+1,+0,+1] +10 === Some [+5])"
"test_code": "verify do\n labeled \"binary to single decimal\" do\n expected = Some [+5]\n actual = rebase +2 [+1,+0,+1] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "single decimal to binary",
"test_code": "let\n Test.label.deprecated \"single decimal to binary\" <| Test.expect (rebase +10 [+5] +2 === Some [+1,+0,+1])"
"test_code": "verify do\n labeled \"single decimal to binary\" do\n expected = Some [+1,+0,+1]\n actual = rebase +10 [+5] +2\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "binary to multiple decimal",
"test_code": "let\n Test.label.deprecated \"binary to multiple decimal\" <| Test.expect (rebase +2 [+1,+0,+1,+0,+1,+0] +10 === Some [+4,+2])"
"test_code": "verify do\n labeled \"binary to multiple decimal\" do\n expected = Some [+4,+2]\n actual = rebase +2 [+1,+0,+1,+0,+1,+0] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "decimal to binary",
"test_code": "let\n Test.label.deprecated \"decimal to binary\" <| Test.expect (rebase +10 [+4,+2] +2 === Some [+1,+0,+1,+0,+1,+0])"
"test_code": "verify do\n labeled \"decimal to binary\" do\n expected = Some [+1,+0,+1,+0,+1,+0]\n actual = rebase +10 [+4,+2] +2\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "trinary to hexadecimal",
"test_code": "let\n Test.label.deprecated \"trinary to hexadecimal\" <| Test.expect (rebase +3 [+1,+1,+2,+0] +16 === Some [+2,+10])"
"test_code": "verify do\n labeled \"trinary to hexadecimal\" do\n expected = Some [+2,+10]\n actual = rebase +3 [+1,+1,+2,+0] +16\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "hexadecimal to trinary",
"test_code": "let\n Test.label.deprecated \"hexadecimal to trinary\" <| Test.expect (rebase +16 [+2,+10] +3 === Some [+1,+1,+2,+0])"
"test_code": "verify do\n labeled \"hexadecimal to trinary\" do\n expected = Some [+1,+1,+2,+0]\n actual = rebase +16 [+2,+10] +3\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "15-bit integer",
"test_code": "let\n Test.label.deprecated \"15-bit integer\" <| Test.expect (rebase +97 [+3,+46,+60] +73 === Some [+6,+10,+45])"
"test_code": "verify do\n labeled \"15-bit integer\" do\n expected = Some [+6,+10,+45]\n actual = rebase +97 [+3,+46,+60] +73\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "empty list",
"test_code": "let\n Test.label.deprecated \"empty list\" <| Test.expect (rebase +2 [] +10 === Some [+0])"
"test_code": "verify do\n labeled \"empty list\" do\n expected = Some [+0]\n actual = rebase +2 [] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "single zero",
"test_code": "let\n Test.label.deprecated \"single zero\" <| Test.expect (rebase +10 [+0] +2 === Some [+0])"
"test_code": "verify do\n labeled \"single zero\" do\n expected = Some [+0]\n actual = rebase +10 [+0] +2\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "multiple zeros",
"test_code": "let\n Test.label.deprecated \"multiple zeros\" <| Test.expect (rebase +10 [+0,+0,+0] +2 === Some [+0])"
"test_code": "verify do\n labeled \"multiple zeros\" do\n expected = Some [+0]\n actual = rebase +10 [+0,+0,+0] +2\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "leading zeros",
"test_code": "let\n Test.label.deprecated \"leading zeros\" <| Test.expect (rebase +7 [+0,+6,+0] +10 === Some [+4,+2])"
"test_code": "verify do\n labeled \"leading zeros\" do\n expected = Some [+4,+2]\n actual = rebase +7 [+0,+6,+0] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "input base is one",
"test_code": "let\n Test.label.deprecated \"input base is one\" <| Test.expect (rebase +1 [+0] +10 === None)"
"test_code": "verify do\n labeled \"input base is one\" do\n expected = None\n actual = rebase +1 [+0] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "input base is zero",
"test_code": "let\n Test.label.deprecated \"input base is zero\" <| Test.expect (rebase +0 [] +10 === None)"
"test_code": "verify do\n labeled \"input base is zero\" do\n expected = None\n actual = rebase +0 [] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "input base is negative",
"test_code": "let\n Test.label.deprecated \"input base is negative\" <| Test.expect (rebase -2 [+1] +10 === None)"
"test_code": "verify do\n labeled \"input base is negative\" do\n expected = None\n actual = rebase -2 [+1] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "negative digit",
"test_code": "let\n Test.label.deprecated \"negative digit\" <| Test.expect (rebase +2 [+1,-1,+1,+0,+1,+0] +10 === None)"
"test_code": "verify do\n labeled \"negative digit\" do\n expected = None\n actual = rebase +2 [+1,-1,+1,+0,+1,+0] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "invalid positive digit",
"test_code": "let\n Test.label.deprecated \"invalid positive digit\" <| Test.expect (rebase +2 [+1,+2,+1,+0,+1,+0] +10 === None)"
"test_code": "verify do\n labeled \"invalid positive digit\" do\n expected = None\n actual = rebase +2 [+1,+2,+1,+0,+1,+0] +10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "output base is one",
"test_code": "let\n Test.label.deprecated \"output base is one\" <| Test.expect (rebase +2 [+1,+0,+1,+0,+1,+0] +1 === None)"
"test_code": "verify do\n labeled \"output base is one\" do\n expected = None\n actual = rebase +2 [+1,+0,+1,+0,+1,+0] +1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "output base is zero",
"test_code": "let\n Test.label.deprecated \"output base is zero\" <| Test.expect (rebase +10 [+7] +0 === None)"
"test_code": "verify do\n labeled \"output base is zero\" do\n expected = None\n actual = rebase +10 [+7] +0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "output base is negative",
"test_code": "let\n Test.label.deprecated \"output base is negative\" <| Test.expect (rebase +2 [+1] -7 === None)"
"test_code": "verify do\n labeled \"output base is negative\" do\n expected = None\n actual = rebase +2 [+1] -7\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
},
{
"name": "both bases are negative",
"test_code": "let\n Test.label.deprecated \"both bases are negative\" <| Test.expect (rebase -2 [+1] -7 === None)"
"test_code": "verify do\n labeled \"both bases are negative\" do\n expected = None\n actual = rebase -2 [+1] -7\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual"
}
]
]
Loading
Loading