From d3a3de71c945533e9f29382c0098de8b85edb302 Mon Sep 17 00:00:00 2001 From: SimaDovakin Date: Sat, 25 Jan 2025 18:57:27 +0200 Subject: [PATCH 1/2] Test upgrades: Upgraded tests for the following exercises: - Armstrong numbers - binary search - Bob - bowling - change --- .../.meta/testAnnotation.json | 20 +- .../armstrong-numbers/armstrongNumbers.test.u | 84 ++++-- .../binary-search/.meta/testAnnotation.json | 24 +- .../binary-search/binarySearch.test.u | 114 ++++--- .../practice/bob/.meta/testAnnotation.json | 52 ++-- exercises/practice/bob/bob.test.u | 277 +++++++++++++----- .../bowling/.meta/testAnnotation.json | 44 +-- exercises/practice/bowling/bowling.test.u | 233 +++++++++++---- .../practice/change/.meta/testAnnotation.json | 24 +- exercises/practice/change/change.test.u | 102 +++++-- 10 files changed, 673 insertions(+), 301 deletions(-) diff --git a/exercises/practice/armstrong-numbers/.meta/testAnnotation.json b/exercises/practice/armstrong-numbers/.meta/testAnnotation.json index 7168af0..604b5b3 100644 --- a/exercises/practice/armstrong-numbers/.meta/testAnnotation.json +++ b/exercises/practice/armstrong-numbers/.meta/testAnnotation.json @@ -1,38 +1,38 @@ [ { "name": "Zero is an Armstrong number", - "test_code": "let\n Test.label.deprecated \"Zero is an Armstrong number\" <| Test.expect (isArmstrongNumber 0 === true)" + "test_code": "verify do\n labeled \"Zero is an Armstrong number\" do\n expected = true\n actual = isArmstrongNumber 0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Single-digit numbers are Armstrong numbers", - "test_code": "let\n Test.label.deprecated \"Single-digit numbers are Armstrong numbers\" <| Test.expect (isArmstrongNumber 5 === true)" + "test_code": "verify do\n labeled \"Single-digit numbers are Armstrong numbers\" do\n expected = true\n actual = isArmstrongNumber 5\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "There are no two-digit Armstrong numbers", - "test_code": "let\n Test.label.deprecated \"There are no two-digit Armstrong numbers\" <| Test.expect (isArmstrongNumber 10 === false)" + "test_code": "verify do\n labeled \"There are no two-digit Armstrong numbers\" do\n expected = false\n actual = isArmstrongNumber 10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Three-digit number that is an Armstrong number", - "test_code": "let\n Test.label.deprecated \"Three-digit number that is an Armstrong number\" <| Test.expect (isArmstrongNumber 153 === true)" + "test_code": "verify do\n labeled \"Three-digit number that is an Armstrong number\" do\n expected = true\n actual = isArmstrongNumber 153\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Three-digit number that is not an Armstrong number", - "test_code": "let\n Test.label.deprecated \"Three-digit number that is not an Armstrong number\" <| Test.expect (isArmstrongNumber 100 === false)" + "test_code": "verify do\n labeled \"Three-digit number that is not an Armstrong number\" do\n expected = false\n actual = isArmstrongNumber 100\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Four-digit number that is an Armstrong number", - "test_code": "let\n Test.label.deprecated \"Four-digit number that is an Armstrong number\" <| Test.expect (isArmstrongNumber 9474 === true)" + "test_code": "verify do\n labeled \"Four-digit number that is an Armstrong number\" do\n expected = true\n actual = isArmstrongNumber 9474\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Four-digit number that is not an Armstrong number", - "test_code": "let\n Test.label.deprecated \"Four-digit number that is not an Armstrong number\" <| Test.expect (isArmstrongNumber 9475 === false)" + "test_code": "verify do\n labeled \"Four-digit number that is not an Armstrong number\" do\n expected = false\n actual = isArmstrongNumber 9475\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Seven-digit number that is an Armstrong number", - "test_code": "let\n Test.label.deprecated \"Seven-digit number that is an Armstrong number\" <| Test.expect (isArmstrongNumber 9926315 === true)" + "test_code": "verify do\n labeled \"Seven-digit number that is an Armstrong number\" do\n expected = true\n actual = isArmstrongNumber 9926315\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Seven-digit number that is not an Armstrong number", - "test_code": "let\n Test.label.deprecated \"Seven-digit number that is not an Armstrong number\" <| Test.expect (isArmstrongNumber 9926314 === false)" + "test_code": "verify do\n labeled \"Seven-digit number that is not an Armstrong number\" do\n expected = false\n actual = isArmstrongNumber 9926314\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/armstrong-numbers/armstrongNumbers.test.u b/exercises/practice/armstrong-numbers/armstrongNumbers.test.u index 436c8fa..856f868 100644 --- a/exercises/practice/armstrong-numbers/armstrongNumbers.test.u +++ b/exercises/practice/armstrong-numbers/armstrongNumbers.test.u @@ -1,31 +1,77 @@ -armstrongNumbers.test.ex1 = let - Test.label.deprecated "Zero is an Armstrong number" <| Test.expect (isArmstrongNumber 0 === true) +armstrongNumbers.test.ex1 = verify do + labeled "Zero is an Armstrong number" do + expected = true + actual = isArmstrongNumber 0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -armstrongNumbers.test.ex2 = let - Test.label.deprecated "Single-digit numbers are Armstrong numbers" <| Test.expect (isArmstrongNumber 5 === true) +armstrongNumbers.test.ex2 = verify do + labeled "Single-digit numbers are Armstrong numbers" do + expected = true + actual = isArmstrongNumber 5 + label "expected" expected + label "actual" actual + ensureEqual expected actual -armstrongNumbers.test.ex3 = let - Test.label.deprecated "There are no two-digit Armstrong numbers" <| Test.expect (isArmstrongNumber 10 === false) +armstrongNumbers.test.ex3 = verify do + labeled "There are no two-digit Armstrong numbers" do + expected = false + actual = isArmstrongNumber 10 + label "expected" expected + label "actual" actual + ensureEqual expected actual -armstrongNumbers.test.ex4 = let - Test.label.deprecated "Three-digit number that is an Armstrong number" <| Test.expect (isArmstrongNumber 153 === true) +armstrongNumbers.test.ex4 = verify do + labeled "Three-digit number that is an Armstrong number" do + expected = true + actual = isArmstrongNumber 153 + label "expected" expected + label "actual" actual + ensureEqual expected actual -armstrongNumbers.test.ex5 = let - Test.label.deprecated "Three-digit number that is not an Armstrong number" <| Test.expect (isArmstrongNumber 100 === false) +armstrongNumbers.test.ex5 = verify do + labeled "Three-digit number that is not an Armstrong number" do + expected = false + actual = isArmstrongNumber 100 + label "expected" expected + label "actual" actual + ensureEqual expected actual -armstrongNumbers.test.ex6 = let - Test.label.deprecated "Four-digit number that is an Armstrong number" <| Test.expect (isArmstrongNumber 9474 === true) +armstrongNumbers.test.ex6 = verify do + labeled "Four-digit number that is an Armstrong number" do + expected = true + actual = isArmstrongNumber 9474 + label "expected" expected + label "actual" actual + ensureEqual expected actual -armstrongNumbers.test.ex7 = let - Test.label.deprecated "Four-digit number that is not an Armstrong number" <| Test.expect (isArmstrongNumber 9475 === false) +armstrongNumbers.test.ex7 = verify do + labeled "Four-digit number that is not an Armstrong number" do + expected = false + actual = isArmstrongNumber 9475 + label "expected" expected + label "actual" actual + ensureEqual expected actual -armstrongNumbers.test.ex8 = let - Test.label.deprecated "Seven-digit number that is an Armstrong number" <| Test.expect (isArmstrongNumber 9926315 === true) +armstrongNumbers.test.ex8 = verify do + labeled "Seven-digit number that is an Armstrong number" do + expected = true + actual = isArmstrongNumber 9926315 + label "expected" expected + label "actual" actual + ensureEqual expected actual -armstrongNumbers.test.ex9 = let - Test.label.deprecated "Seven-digit number that is not an Armstrong number" <| Test.expect (isArmstrongNumber 9926314 === false) +armstrongNumbers.test.ex9 = verify do + labeled "Seven-digit number that is not an Armstrong number" do + expected = false + actual = isArmstrongNumber 9926314 + label "expected" expected + label "actual" actual + ensureEqual expected actual -test> armstrongNumbers.tests = runAll [ + +test> armstrongNumbers.tests = join [ armstrongNumbers.test.ex1, armstrongNumbers.test.ex2, armstrongNumbers.test.ex3, diff --git a/exercises/practice/binary-search/.meta/testAnnotation.json b/exercises/practice/binary-search/.meta/testAnnotation.json index 25cfbb5..02ac4a4 100644 --- a/exercises/practice/binary-search/.meta/testAnnotation.json +++ b/exercises/practice/binary-search/.meta/testAnnotation.json @@ -1,46 +1,46 @@ [ { "name": "finds a value in an array with one element", - "test_code": "expect (Some +0 === binarySearch.find (Array.fromList [6]) 6)\n |> Test.label.deprecated \"finds a value in an array with one element\"" + "test_code": "verify do\n labeled \"finds a value in an array with one element\" do\n expected = Some +0\n actual = binarySearch.find (Array.fromList [6]) 6\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "finds a value in the middle of an array", - "test_code": "expect (Some +3 === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 6)\n |> Test.label.deprecated \"finds a value in the middle of an array\"" + "test_code": "verify do\n labeled \"finds a value in the middle of an array\" do\n expected = Some +3\n actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 6\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "finds a value at the beginning of an array", - "test_code": "expect (Some +0 === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 1)\n |> Test.label.deprecated \"finds a value at the beginning of an array\"" + "test_code": "verify do\n labeled \"finds a value at the beginning of an array\" do\n expected = Some +0\n actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "finds a value at the end of an array", - "test_code": "expect (Some +6 === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 11)\n |> Test.label.deprecated \"finds a value at the end of an array\"" + "test_code": "verify do\n labeled \"finds a value at the end of an array\" do\n expected = Some +6\n actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 11\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "finds a value in an array of odd length", - "test_code": "expect (Some +9 === binarySearch.find (Array.fromList [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634]) 144)\n |> Test.label.deprecated \"finds a value in an array of odd length\"" + "test_code": "verify do\n labeled \"finds a value in an array of odd length\" do\n expected = Some +9\n actual = binarySearch.find (Array.fromList [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634]) 144\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "finds a value in an array of even length", - "test_code": "expect (Some +5 === binarySearch.find (Array.fromList [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]) 21)\n |> Test.label.deprecated \"finds a value in an array of even length\"" + "test_code": "verify do\n labeled \"finds a value in an array of even length\" do\n expected = Some +5\n actual = binarySearch.find (Array.fromList [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]) 21\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "identifies that a value is not included in the array", - "test_code": "expect (None === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 7)\n |> Test.label.deprecated \"identifies that a value is not included in the array\"" + "test_code": "verify do\n labeled \"identifies that a value is not included in the array\" do\n expected = None\n actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 7\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "a value smaller than the array's smallest value is not found", - "test_code": "expect (None === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 0)\n |> Test.label.deprecated \"a value smaller than the array's smallest value is not found\"" + "test_code": "verify do\n labeled \"a value smaller than the array's smallest value is not found\" do\n expected = None\n actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "a value larger than the array's largest value is not found", - "test_code": "expect (None === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 13)\n |> Test.label.deprecated \"a value larger than the array's largest value is not found\"" + "test_code": "verify do\n labeled \"a value larger than the array's largest value is not found\" do\n expected = None\n actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 13\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "nothing is found in an empty array", - "test_code": "expect (None === binarySearch.find (Array.fromList []) 1)\n |> Test.label.deprecated \"nothing is found in an empty array\"" + "test_code": "verify do\n labeled \"nothing is found in an empty array\" do\n expected = None\n actual = binarySearch.find (Array.fromList []) 1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "nothing is found when the left and right bounds cross", - "test_code": "expect (None === binarySearch.find (Array.fromList [1, 2]) 0)\n |> Test.label.deprecated \"nothing is found when the left and right bounds cross\"" + "test_code": "verify do\n labeled \"nothing is found when the left and right bounds cross\" do\n expected = None\n actual = binarySearch.find (Array.fromList [1, 2]) 0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/binary-search/binarySearch.test.u b/exercises/practice/binary-search/binarySearch.test.u index 0b11576..80ce759 100644 --- a/exercises/practice/binary-search/binarySearch.test.u +++ b/exercises/practice/binary-search/binarySearch.test.u @@ -1,50 +1,92 @@ -use data Array +binarySearch.find.tests.ex1 = verify do + labeled "finds a value in an array with one element" do + expected = Some +0 + actual = binarySearch.find (Array.fromList [6]) 6 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex1 = - expect (Some +0 === binarySearch.find (Array.fromList [6]) 6) - |> Test.label.deprecated "finds a value in an array with one element" +binarySearch.find.tests.ex2 = verify do + labeled "finds a value in the middle of an array" do + expected = Some +3 + actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 6 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex2 = - expect (Some +3 === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 6) - |> Test.label.deprecated "finds a value in the middle of an array" +binarySearch.find.tests.ex3 = verify do + labeled "finds a value at the beginning of an array" do + expected = Some +0 + actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 1 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex3 = - expect (Some +0 === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 1) - |> Test.label.deprecated "finds a value at the beginning of an array" +binarySearch.find.tests.ex4 = verify do + labeled "finds a value at the end of an array" do + expected = Some +6 + actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 11 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex4 = - expect (Some +6 === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 11) - |> Test.label.deprecated "finds a value at the end of an array" +binarySearch.find.tests.ex5 = verify do + labeled "finds a value in an array of odd length" do + expected = Some +9 + actual = binarySearch.find (Array.fromList [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634]) 144 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex5 = - expect (Some +9 === binarySearch.find (Array.fromList [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634]) 144) - |> Test.label.deprecated "finds a value in an array of odd length" +binarySearch.find.tests.ex6 = verify do + labeled "finds a value in an array of even length" do + expected = Some +5 + actual = binarySearch.find (Array.fromList [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]) 21 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex6 = - expect (Some +5 === binarySearch.find (Array.fromList [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]) 21) - |> Test.label.deprecated "finds a value in an array of even length" +binarySearch.find.tests.ex7 = verify do + labeled "identifies that a value is not included in the array" do + expected = None + actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 7 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex7 = - expect (None === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 7) - |> Test.label.deprecated "identifies that a value is not included in the array" +binarySearch.find.tests.ex8 = verify do + labeled "a value smaller than the array's smallest value is not found" do + expected = None + actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex8 = - expect (None === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 0) - |> Test.label.deprecated "a value smaller than the array's smallest value is not found" +binarySearch.find.tests.ex9 = verify do + labeled "a value larger than the array's largest value is not found" do + expected = None + actual = binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 13 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex9 = - expect (None === binarySearch.find (Array.fromList [1, 3, 4, 6, 8, 9, 11]) 13) - |> Test.label.deprecated "a value larger than the array's largest value is not found" +binarySearch.find.tests.ex10 = verify do + labeled "nothing is found in an empty array" do + expected = None + actual = binarySearch.find (Array.fromList []) 1 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex10 = - expect (None === binarySearch.find (Array.fromList []) 1) - |> Test.label.deprecated "nothing is found in an empty array" +binarySearch.find.tests.ex11 = verify do + labeled "nothing is found when the left and right bounds cross" do + expected = None + actual = binarySearch.find (Array.fromList [1, 2]) 0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -binarySearch.find.tests.ex11 = - expect (None === binarySearch.find (Array.fromList [1, 2]) 0) - |> Test.label.deprecated "nothing is found when the left and right bounds cross" - -test> binarySearch.tests = runAll [ +test> binarySearch.tests = join [ binarySearch.find.tests.ex1, binarySearch.find.tests.ex2, binarySearch.find.tests.ex3, diff --git a/exercises/practice/bob/.meta/testAnnotation.json b/exercises/practice/bob/.meta/testAnnotation.json index 20d8377..070b3da 100644 --- a/exercises/practice/bob/.meta/testAnnotation.json +++ b/exercises/practice/bob/.meta/testAnnotation.json @@ -1,102 +1,102 @@ [ { "name": "Stating something", - "test_code": "let\n Test.label.deprecated \"Stating something\" <| Test.expect (response \"Tom-ay-to, tom-aaaah-to.\" === \"Whatever.\")" + "test_code": "verify do\n labeled \"Stating something\" do\n expected = \"Whatever.\"\n actual = response \"Tom-ay-to, tom-aaaah-to.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Shouting", - "test_code": "let\n Test.label.deprecated \"Shouting\" <| Test.expect (response \"WATCH OUT!\" === \"Whoa, chill out!\")" + "test_code": "verify do\n labeled \"Shouting\" do\n expected = \"Whoa, chill out!\"\n actual = response \"WATCH OUT!\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Shouting gibberish", - "test_code": "let\n Test.label.deprecated \"Shouting gibberish\" <| Test.expect (response \"FCECDFCAAB\" === \"Whoa, chill out!\")" + "test_code": "verify do\n labeled \"Shouting gibberish\" do\n expected = \"Whoa, chill out!\"\n actual = response \"FCECDFCAAB\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Asking a question", - "test_code": "let\n Test.label.deprecated \"Asking a question\" <| Test.expect (response \"Does this cryogenic chamber make me look fat?\" === \"Sure.\")" + "test_code": "verify do\n labeled \"Asking a question\" do\n expected = \"Sure.\"\n actual = response \"Does this cryogenic chamber make me look fat?\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Asking a numeric question", - "test_code": "let\n Test.label.deprecated \"Asking a numeric question\" <| Test.expect (response \"You are, what, like 15?\" === \"Sure.\")" + "test_code": "verify do\n labeled \"Asking a numeric question\" do\n expected = \"Sure.\"\n actual = response \"You are, what, like 15?\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Asking gibberish", - "test_code": "let\n Test.label.deprecated \"Asking gibberish\" <| Test.expect (response \"fffbbcbeab?\" === \"Sure.\")" + "test_code": "verify do\n labeled \"Asking gibberish\" do\n expected = \"Sure.\"\n actual = response \"fffbbcbeab?\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Talking forcefully", - "test_code": "let\n Test.label.deprecated \"Talking forcefully\" <| Test.expect (response \"Hi there!\" === \"Whatever.\")" + "test_code": "verify do\n labeled \"Talking forcefully\" do\n expected = \"Whatever.\"\n actual = response \"Hi there!\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Using acronyms in regular speech", - "test_code": "let\n Test.label.deprecated \"Using acronyms in regular speech\" <| Test.expect (response \"It's OK if you don't want to go work for NASA.\" === \"Whatever.\")" + "test_code": "verify do\n labeled \"Using acronyms in regular speech\" do\n expected = \"Whatever.\"\n actual = response \"It's OK if you don't want to go work for NASA.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Forceful question", - "test_code": "let\n Test.label.deprecated \"Forceful question\" <| Test.expect (response \"WHAT'S GOING ON?\" === \"Calm down, I know what I'm doing!\")" + "test_code": "verify do\n labeled \"Forceful question\" do\n expected = \"Calm down, I know what I'm doing!\"\n actual = response \"WHAT'S GOING ON?\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Shouting numbers", - "test_code": "let\n Test.label.deprecated \"Shouting numbers\" <| Test.expect (response \"1, 2, 3 GO!\" === \"Whoa, chill out!\")" + "test_code": "verify do\n labeled \"Shouting numbers\" do\n expected = \"Whoa, chill out!\"\n actual = response \"1, 2, 3 GO!\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "No letters", - "test_code": "let\n Test.label.deprecated \"No letters\" <| Test.expect (response \"1, 2, 3\" === \"Whatever.\")" + "test_code": "verify do\n labeled \"No letters\" do\n expected = \"Whatever.\"\n actual = response \"1, 2, 3\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Question with no letters", - "test_code": "let\n Test.label.deprecated \"Question with no letters\" <| Test.expect (response \"4?\" === \"Sure.\")" + "test_code": "verify do\n labeled \"Question with no letters\" do\n expected = \"Sure.\"\n actual = response \"4?\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Shouting with special characters", - "test_code": "let\n Test.label.deprecated \"Shouting with special characters\" <| Test.expect (response \"ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!\" === \"Whoa, chill out!\")" + "test_code": "verify do\n labeled \"Shouting with special characters\" do\n expected = \"Whoa, chill out!\"\n actual = response \"ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Shouting with no exclamation mark", - "test_code": "let\n Test.label.deprecated \"Shouting with no exclamation mark\" <| Test.expect (response \"I HATE THE DENTIST\" === \"Whoa, chill out!\")" + "test_code": "verify do\n labeled \"Shouting with no exclamation mark\" do\n expected = \"Whoa, chill out!\"\n actual = response \"I HATE THE DENTIST\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Statement containing question mark", - "test_code": "let\n Test.label.deprecated \"Statement containing question mark\" <| Test.expect (response \"Ending with ? means a question.\" === \"Whatever.\")" + "test_code": "verify do\n labeled \"Statement containing question mark\" do\n expected = \"Whatever.\"\n actual = response \"Ending with ? means a question.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Non-letters with question", - "test_code": "let\n Test.label.deprecated \"Non-letters with question\" <| Test.expect (response \":) ?\" === \"Sure.\")" + "test_code": "verify do\n labeled \"Non-letters with question\" do\n expected = \"Sure.\"\n actual = response \":) ?\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Prattling on", - "test_code": "let\n Test.label.deprecated \"Prattling on\" <| Test.expect (response \"Wait! Hang on. Are you going to be OK?\" === \"Sure.\")" + "test_code": "verify do\n labeled \"Prattling on\" do\n expected = \"Sure.\"\n actual = response \"Wait! Hang on. Are you going to be OK?\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Silence", - "test_code": "let\n Test.label.deprecated \"Silence\" <| Test.expect (response \"\" === \"Fine. Be that way!\")" + "test_code": "verify do\n labeled \"Silence\" do\n expected = \"Fine. Be that way!\"\n actual = response \"\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Prolonged silence", - "test_code": "let\n Test.label.deprecated \"Prolonged silence\" <| Test.expect (response \" \" === \"Fine. Be that way!\")" + "test_code": "verify do\n labeled \"Prolonged silence\" do\n expected = \"Fine. Be that way!\"\n actual = response \" \"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Alternate silence", - "test_code": "let\n Test.label.deprecated \"Alternate silence\" <| Test.expect (response \"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\" === \"Fine. Be that way!\")" + "test_code": "verify do\n labeled \"Alternate silence\" do\n expected = \"Fine. Be that way!\"\n actual = response \"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Multiple line question", - "test_code": "let\n Test.label.deprecated \"Multiple line question\" <| Test.expect (response \"\\nDoes this cryogenic chamber make me look fat?\\nNo.\" === \"Whatever.\")" + "test_code": "verify do\n labeled \"Multiple line question\" do\n expected = \"Whatever.\"\n actual = response \"\\nDoes this cryogenic chamber make me look fat?\\nNo.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Starting with whitespace", - "test_code": "let\n Test.label.deprecated \"Starting with whitespace\" <| Test.expect (response \" hmmmmmmm...\" === \"Whatever.\")" + "test_code": "verify do\n labeled \"Starting with whitespace\" do\n expected = \"Whatever.\"\n actual = response \" hmmmmmmm...\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Ending with whitespace", - "test_code": "let\n Test.label.deprecated \"Ending with whitespace\" <| Test.expect (response \"Okay if like my spacebar quite a bit? \" === \"Sure.\")" + "test_code": "verify do\n labeled \"Ending with whitespace\" do\n expected = \"Sure.\"\n actual = response \"Okay if like my spacebar quite a bit? \"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Other whitespace", - "test_code": "let\n Test.label.deprecated \"Other whitespace\" <| Test.expect (response \"\\n\\r \\t\" === \"Fine. Be that way!\")" + "test_code": "verify do\n labeled \"Other whitespace\" do\n expected = \"Fine. Be that way!\"\n actual = response \"\\n\\r \\t\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Non-question ending with whitespace", - "test_code": "let\n Test.label.deprecated \"Non-question ending with whitespace\" <| Test.expect (response \"This is a statement ending with whitespace \" === \"Whatever.\")" + "test_code": "verify do\n labeled \"Non-question ending with whitespace\" do\n expected = \"Whatever.\"\n actual = response \"This is a statement ending with whitespace \"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/bob/bob.test.u b/exercises/practice/bob/bob.test.u index 0a2db19..477a1b2 100644 --- a/exercises/practice/bob/bob.test.u +++ b/exercises/practice/bob/bob.test.u @@ -1,79 +1,204 @@ -bob.test.ex1 = let - Test.label.deprecated "Stating something" <| Test.expect (response "Tom-ay-to, tom-aaaah-to." === "Whatever.") - -bob.test.ex2 = let - Test.label.deprecated "Shouting" <| Test.expect (response "WATCH OUT!" === "Whoa, chill out!") - -bob.test.ex3 = let - Test.label.deprecated "Shouting gibberish" <| Test.expect (response "FCECDFCAAB" === "Whoa, chill out!") - -bob.test.ex4 = let - Test.label.deprecated "Asking a question" <| Test.expect (response "Does this cryogenic chamber make me look fat?" === "Sure.") - -bob.test.ex5 = let - Test.label.deprecated "Asking a numeric question" <| Test.expect (response "You are, what, like 15?" === "Sure.") - -bob.test.ex6 = let - Test.label.deprecated "Asking gibberish" <| Test.expect (response "fffbbcbeab?" === "Sure.") - -bob.test.ex7 = let - Test.label.deprecated "Talking forcefully" <| Test.expect (response "Hi there!" === "Whatever.") - -bob.test.ex8 = let - Test.label.deprecated "Using acronyms in regular speech" <| Test.expect (response "It's OK if you don't want to go work for NASA." === "Whatever.") - -bob.test.ex9 = let - Test.label.deprecated "Forceful question" <| Test.expect (response "WHAT'S GOING ON?" === "Calm down, I know what I'm doing!") - -bob.test.ex10 = let - Test.label.deprecated "Shouting numbers" <| Test.expect (response "1, 2, 3 GO!" === "Whoa, chill out!") - -bob.test.ex11 = let - Test.label.deprecated "No letters" <| Test.expect (response "1, 2, 3" === "Whatever.") - -bob.test.ex12 = let - Test.label.deprecated "Question with no letters" <| Test.expect (response "4?" === "Sure.") - -bob.test.ex13 = let - Test.label.deprecated "Shouting with special characters" <| Test.expect (response "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" === "Whoa, chill out!") - -bob.test.ex14 = let - Test.label.deprecated "Shouting with no exclamation mark" <| Test.expect (response "I HATE THE DENTIST" === "Whoa, chill out!") - -bob.test.ex15 = let - Test.label.deprecated "Statement containing question mark" <| Test.expect (response "Ending with ? means a question." === "Whatever.") - -bob.test.ex16 = let - Test.label.deprecated "Non-letters with question" <| Test.expect (response ":) ?" === "Sure.") - -bob.test.ex17 = let - Test.label.deprecated "Prattling on" <| Test.expect (response "Wait! Hang on. Are you going to be OK?" === "Sure.") - -bob.test.ex18 = let - Test.label.deprecated "Silence" <| Test.expect (response "" === "Fine. Be that way!") - -bob.test.ex19 = let - Test.label.deprecated "Prolonged silence" <| Test.expect (response " " === "Fine. Be that way!") - -bob.test.ex20 = let - Test.label.deprecated "Alternate silence" <| Test.expect (response "\t\t\t\t\t\t\t\t\t\t" === "Fine. Be that way!") - -bob.test.ex21 = let - Test.label.deprecated "Multiple line question" <| Test.expect (response "\nDoes this cryogenic chamber make me look fat?\nNo." === "Whatever.") - -bob.test.ex22 = let - Test.label.deprecated "Starting with whitespace" <| Test.expect (response " hmmmmmmm..." === "Whatever.") - -bob.test.ex23 = let - Test.label.deprecated "Ending with whitespace" <| Test.expect (response "Okay if like my spacebar quite a bit? " === "Sure.") - -bob.test.ex24 = let - Test.label.deprecated "Other whitespace" <| Test.expect (response "\n\r \t" === "Fine. Be that way!") - -bob.test.ex25 = let - Test.label.deprecated "Non-question ending with whitespace" <| Test.expect (response "This is a statement ending with whitespace " === "Whatever.") - -test> bob.tests = runAll [ +bob.test.ex1 = verify do + labeled "Stating something" do + expected = "Whatever." + actual = response "Tom-ay-to, tom-aaaah-to." + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex2 = verify do + labeled "Shouting" do + expected = "Whoa, chill out!" + actual = response "WATCH OUT!" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex3 = verify do + labeled "Shouting gibberish" do + expected = "Whoa, chill out!" + actual = response "FCECDFCAAB" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex4 = verify do + labeled "Asking a question" do + expected = "Sure." + actual = response "Does this cryogenic chamber make me look fat?" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex5 = verify do + labeled "Asking a numeric question" do + expected = "Sure." + actual = response "You are, what, like 15?" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex6 = verify do + labeled "Asking gibberish" do + expected = "Sure." + actual = response "fffbbcbeab?" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex7 = verify do + labeled "Talking forcefully" do + expected = "Whatever." + actual = response "Hi there!" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex8 = verify do + labeled "Using acronyms in regular speech" do + expected = "Whatever." + actual = response "It's OK if you don't want to go work for NASA." + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex9 = verify do + labeled "Forceful question" do + expected = "Calm down, I know what I'm doing!" + actual = response "WHAT'S GOING ON?" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex10 = verify do + labeled "Shouting numbers" do + expected = "Whoa, chill out!" + actual = response "1, 2, 3 GO!" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex11 = verify do + labeled "No letters" do + expected = "Whatever." + actual = response "1, 2, 3" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex12 = verify do + labeled "Question with no letters" do + expected = "Sure." + actual = response "4?" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex13 = verify do + labeled "Shouting with special characters" do + expected = "Whoa, chill out!" + actual = response "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex14 = verify do + labeled "Shouting with no exclamation mark" do + expected = "Whoa, chill out!" + actual = response "I HATE THE DENTIST" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex15 = verify do + labeled "Statement containing question mark" do + expected = "Whatever." + actual = response "Ending with ? means a question." + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex16 = verify do + labeled "Non-letters with question" do + expected = "Sure." + actual = response ":) ?" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex17 = verify do + labeled "Prattling on" do + expected = "Sure." + actual = response "Wait! Hang on. Are you going to be OK?" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex18 = verify do + labeled "Silence" do + expected = "Fine. Be that way!" + actual = response "" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex19 = verify do + labeled "Prolonged silence" do + expected = "Fine. Be that way!" + actual = response " " + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex20 = verify do + labeled "Alternate silence" do + expected = "Fine. Be that way!" + actual = response "\t\t\t\t\t\t\t\t\t\t" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex21 = verify do + labeled "Multiple line question" do + expected = "Whatever." + actual = response "\nDoes this cryogenic chamber make me look fat?\nNo." + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex22 = verify do + labeled "Starting with whitespace" do + expected = "Whatever." + actual = response " hmmmmmmm..." + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex23 = verify do + labeled "Ending with whitespace" do + expected = "Sure." + actual = response "Okay if like my spacebar quite a bit? " + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex24 = verify do + labeled "Other whitespace" do + expected = "Fine. Be that way!" + actual = response "\n\r \t" + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bob.test.ex25 = verify do + labeled "Non-question ending with whitespace" do + expected = "Whatever." + actual = response "This is a statement ending with whitespace " + label "expected" expected + label "actual" actual + ensureEqual expected actual + +test> bob.tests = join [ bob.test.ex1, bob.test.ex2, bob.test.ex3, diff --git a/exercises/practice/bowling/.meta/testAnnotation.json b/exercises/practice/bowling/.meta/testAnnotation.json index b6c1849..59ae77a 100644 --- a/exercises/practice/bowling/.meta/testAnnotation.json +++ b/exercises/practice/bowling/.meta/testAnnotation.json @@ -1,86 +1,86 @@ [ { "name": "should be able to score a game with all zeros", - "test_code": "let\n Test.label.deprecated \"should be able to score a game with all zeros\" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (0))" + "test_code": "verify do\n labeled \"should be able to score a game with all zeros\" do\n expected = Right (0)\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "should be able to score a game with no strikes or spares", - "test_code": "let\n Test.label.deprecated \"should be able to score a game with no strikes or spares\" <| Test.expect (score [3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6] === Right (90))" + "test_code": "verify do\n labeled \"should be able to score a game with no strikes or spares\" do\n expected = Right (90)\n actual = score [3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "a spare followed by zeros is worth ten points", - "test_code": "let\n Test.label.deprecated \"a spare followed by zeros is worth ten points\" <| Test.expect (score [6,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (10))" + "test_code": "verify do\n labeled \"a spare followed by zeros is worth ten points\" do\n expected = Right (10)\n actual = score [6,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "points scored in the roll after a spare are counted twice", - "test_code": "let\n Test.label.deprecated \"points scored in the roll after a spare are counted twice\" <| Test.expect (score [6,4,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (16))" + "test_code": "verify do\n labeled \"points scored in the roll after a spare are counted twice\" do\n expected = Right (16)\n actual = score [6,4,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "consecutive spares each get a one roll bonus", - "test_code": "let\n Test.label.deprecated \"consecutive spares each get a one roll bonus\" <| Test.expect (score [5,5,3,7,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (31))" + "test_code": "verify do\n labeled \"consecutive spares each get a one roll bonus\" do\n expected = Right (31)\n actual = score [5,5,3,7,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "a spare in the last frame gets a one roll bonus that is counted once", - "test_code": "let\n Test.label.deprecated \"a spare in the last frame gets a one roll bonus that is counted once\" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,7] === Right (17))" + "test_code": "verify do\n labeled \"a spare in the last frame gets a one roll bonus that is counted once\" do\n expected = Right (17)\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,7]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "a strike earns ten points in a frame with a single roll", - "test_code": "let\n Test.label.deprecated \"a strike earns ten points in a frame with a single roll\" <| Test.expect (score [10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (10))" + "test_code": "verify do\n labeled \"a strike earns ten points in a frame with a single roll\" do\n expected = Right (10)\n actual = score [10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "points scored in the two rolls after a strike are counted twice as a bonus", - "test_code": "let\n Test.label.deprecated \"points scored in the two rolls after a strike are counted twice as a bonus\" <| Test.expect (score [10,5,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (26))" + "test_code": "verify do\n labeled \"points scored in the two rolls after a strike are counted twice as a bonus\" do\n expected = Right (26)\n actual = score [10,5,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "consecutive strikes each get the two roll bonus", - "test_code": "let\n Test.label.deprecated \"consecutive strikes each get the two roll bonus\" <| Test.expect (score [10,10,10,5,3,0,0,0,0,0,0,0,0,0,0,0,0] === Right (81))" + "test_code": "verify do\n labeled \"consecutive strikes each get the two roll bonus\" do\n expected = Right (81)\n actual = score [10,10,10,5,3,0,0,0,0,0,0,0,0,0,0,0,0]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "a strike in the last frame gets a two roll bonus that is counted once", - "test_code": "let\n Test.label.deprecated \"a strike in the last frame gets a two roll bonus that is counted once\" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,1] === Right (18))" + "test_code": "verify do\n labeled \"a strike in the last frame gets a two roll bonus that is counted once\" do\n expected = Right (18)\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,1]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "rolling a spare with the two roll bonus does not get a bonus roll", - "test_code": "let\n Test.label.deprecated \"rolling a spare with the two roll bonus does not get a bonus roll\" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,3] === Right (20))" + "test_code": "verify do\n labeled \"rolling a spare with the two roll bonus does not get a bonus roll\" do\n expected = Right (20)\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,3]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "strikes with the two roll bonus do not get bonus rolls", - "test_code": "let\n Test.label.deprecated \"strikes with the two roll bonus do not get bonus rolls\" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10] === Right (30))" + "test_code": "verify do\n labeled \"strikes with the two roll bonus do not get bonus rolls\" do\n expected = Right (30)\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "last two strikes followed by only last bonus with non strike points", - "test_code": "let\n Test.label.deprecated \"last two strikes followed by only last bonus with non strike points\" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,0,1] === Right (31))" + "test_code": "verify do\n labeled \"last two strikes followed by only last bonus with non strike points\" do\n expected = Right (31)\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,0,1]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "a strike with the one roll bonus after a spare in the last frame does not get a bonus", - "test_code": "let\n Test.label.deprecated \"a strike with the one roll bonus after a spare in the last frame does not get a bonus\" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,10] === Right (20))" + "test_code": "verify do\n labeled \"a strike with the one roll bonus after a spare in the last frame does not get a bonus\" do\n expected = Right (20)\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,10]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "all strikes is a perfect game", - "test_code": "let\n Test.label.deprecated \"all strikes is a perfect game\" <| Test.expect (score [10,10,10,10,10,10,10,10,10,10,10,10] === Right (300))" + "test_code": "verify do\n labeled \"all strikes is a perfect game\" do\n expected = Right (300)\n actual = score [10,10,10,10,10,10,10,10,10,10,10,10]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike", - "test_code": "Test.label.deprecated \"two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike\" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,6] === Right (26))" + "test_code": "verify do\n labeled \"two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike\" do\n expected = Right (26)\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,6]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "an unstarted game cannot be scored", - "test_code": "let\n Test.label.deprecated \"an unstarted game cannot be scored\" <| Test.expect (score [] === Left ( Error \"Score cannot be taken until the end of the game\"))" + "test_code": "verify do\n labeled \"an unstarted game cannot be scored\" do\n expected = Left ( Error \"Score cannot be taken until the end of the game\")\n actual = score []\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "an incomplete game cannot be scored", - "test_code": "let\n Test.label.deprecated \"an incomplete game cannot be scored\" <| Test.expect (score [0,0] === Left ( Error \"Score cannot be taken until the end of the game\"))" + "test_code": "verify do\n labeled \"an incomplete game cannot be scored\" do\n expected = Left ( Error \"Score cannot be taken until the end of the game\")\n actual = score [0,0]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "bonus rolls for a strike in the last frame must be rolled before score can be calculated", - "test_code": "let\n Test.label.deprecated \"bonus rolls for a strike in the last frame must be rolled before score can be calculated\" <| Test.expect ( score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10] === Left ( Error \"Score cannot be taken until the end of the game\"))" + "test_code": "verify do\n labeled \"bonus rolls for a strike in the last frame must be rolled before score can be calculated\" do\n expected = Left ( Error \"Score cannot be taken until the end of the game\")\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "both bonus rolls for a strike in the last frame must be rolled before score can be calculated", - "test_code": "let\n Test.label.deprecated \"both bonus rolls for a strike in the last frame must be rolled before score can be calculated\" <| Test.expect ( score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10] === Left ( Error \"Score cannot be taken until the end of the game\"))" + "test_code": "verify do\n labeled \"both bonus rolls for a strike in the last frame must be rolled before score can be calculated\" do\n expected = Left ( Error \"Score cannot be taken until the end of the game\")\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "bonus roll for a spare in the last frame must be rolled before score can be calculated", - "test_code": "let\n Test.label.deprecated \"bonus roll for a spare in the last frame must be rolled before score can be calculated\" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3] === Left ( Error \"Score cannot be taken until the end of the game\"))" + "test_code": "verify do\n labeled \"bonus roll for a spare in the last frame must be rolled before score can be calculated\" do\n expected = Left ( Error \"Score cannot be taken until the end of the game\")\n actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3]\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/bowling/bowling.test.u b/exercises/practice/bowling/bowling.test.u index c19db37..c8573d2 100644 --- a/exercises/practice/bowling/bowling.test.u +++ b/exercises/practice/bowling/bowling.test.u @@ -1,67 +1,172 @@ -bowling.test.ex1 = let - Test.label.deprecated "should be able to score a game with all zeros" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (0)) - -bowling.test.ex2 = let - Test.label.deprecated "should be able to score a game with no strikes or spares" <| Test.expect (score [3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6] === Right (90)) - -bowling.test.ex3 = let - Test.label.deprecated "a spare followed by zeros is worth ten points" <| Test.expect (score [6,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (10)) - -bowling.test.ex4 = let - Test.label.deprecated "points scored in the roll after a spare are counted twice" <| Test.expect (score [6,4,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (16)) - -bowling.test.ex5 = let - Test.label.deprecated "consecutive spares each get a one roll bonus" <| Test.expect (score [5,5,3,7,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (31)) - -bowling.test.ex6 = let - Test.label.deprecated "a spare in the last frame gets a one roll bonus that is counted once" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,7] === Right (17)) - -bowling.test.ex7 = let - Test.label.deprecated "a strike earns ten points in a frame with a single roll" <| Test.expect (score [10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (10)) - -bowling.test.ex8 = let - Test.label.deprecated "points scored in the two rolls after a strike are counted twice as a bonus" <| Test.expect (score [10,5,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] === Right (26)) - -bowling.test.ex9 = let - Test.label.deprecated "consecutive strikes each get the two roll bonus" <| Test.expect (score [10,10,10,5,3,0,0,0,0,0,0,0,0,0,0,0,0] === Right (81)) - -bowling.test.ex10 = let - Test.label.deprecated "a strike in the last frame gets a two roll bonus that is counted once" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,1] === Right (18)) - -bowling.test.ex11 = let - Test.label.deprecated "rolling a spare with the two roll bonus does not get a bonus roll" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,3] === Right (20)) - -bowling.test.ex12 = let - Test.label.deprecated "strikes with the two roll bonus do not get bonus rolls" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10] === Right (30)) - -bowling.test.ex13 = let - Test.label.deprecated "last two strikes followed by only last bonus with non strike points" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,0,1] === Right (31)) - -bowling.test.ex14 = let - Test.label.deprecated "a strike with the one roll bonus after a spare in the last frame does not get a bonus" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,10] === Right (20)) - -bowling.test.ex15 = let - Test.label.deprecated "all strikes is a perfect game" <| Test.expect (score [10,10,10,10,10,10,10,10,10,10,10,10] === Right (300)) - -bowling.test.ex16 = - Test.label.deprecated "two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,6] === Right (26)) - -bowling.test.ex17 = let - Test.label.deprecated "an unstarted game cannot be scored" <| Test.expect (score [] === Left ( Error "Score cannot be taken until the end of the game")) - -bowling.test.ex18 = let - Test.label.deprecated "an incomplete game cannot be scored" <| Test.expect (score [0,0] === Left ( Error "Score cannot be taken until the end of the game")) - -bowling.test.ex19 = let - Test.label.deprecated "bonus rolls for a strike in the last frame must be rolled before score can be calculated" <| Test.expect ( score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10] === Left ( Error "Score cannot be taken until the end of the game")) - -bowling.test.ex20 = let - Test.label.deprecated "both bonus rolls for a strike in the last frame must be rolled before score can be calculated" <| Test.expect ( score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10] === Left ( Error "Score cannot be taken until the end of the game")) - -bowling.test.ex21 = let - Test.label.deprecated "bonus roll for a spare in the last frame must be rolled before score can be calculated" <| Test.expect (score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3] === Left ( Error "Score cannot be taken until the end of the game")) - -test> bowling.tests = runAll [ +bowling.test.ex1 = verify do + labeled "should be able to score a game with all zeros" do + expected = Right (0) + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex2 = verify do + labeled "should be able to score a game with no strikes or spares" do + expected = Right (90) + actual = score [3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6,3,6] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex3 = verify do + labeled "a spare followed by zeros is worth ten points" do + expected = Right (10) + actual = score [6,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex4 = verify do + labeled "points scored in the roll after a spare are counted twice" do + expected = Right (16) + actual = score [6,4,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex5 = verify do + labeled "consecutive spares each get a one roll bonus" do + expected = Right (31) + actual = score [5,5,3,7,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex6 = verify do + labeled "a spare in the last frame gets a one roll bonus that is counted once" do + expected = Right (17) + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,7] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex7 = verify do + labeled "a strike earns ten points in a frame with a single roll" do + expected = Right (10) + actual = score [10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex8 = verify do + labeled "points scored in the two rolls after a strike are counted twice as a bonus" do + expected = Right (26) + actual = score [10,5,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex9 = verify do + labeled "consecutive strikes each get the two roll bonus" do + expected = Right (81) + actual = score [10,10,10,5,3,0,0,0,0,0,0,0,0,0,0,0,0] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex10 = verify do + labeled "a strike in the last frame gets a two roll bonus that is counted once" do + expected = Right (18) + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,1] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex11 = verify do + labeled "rolling a spare with the two roll bonus does not get a bonus roll" do + expected = Right (20) + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,7,3] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex12 = verify do + labeled "strikes with the two roll bonus do not get bonus rolls" do + expected = Right (30) + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex13 = verify do + labeled "last two strikes followed by only last bonus with non strike points" do + expected = Right (31) + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,0,1] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex14 = verify do + labeled "a strike with the one roll bonus after a spare in the last frame does not get a bonus" do + expected = Right (20) + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3,10] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex15 = verify do + labeled "all strikes is a perfect game" do + expected = Right (300) + actual = score [10,10,10,10,10,10,10,10,10,10,10,10] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex16 = verify do + labeled "two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike" do + expected = Right (26) + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,6] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex17 = verify do + labeled "an unstarted game cannot be scored" do + expected = Left ( Error "Score cannot be taken until the end of the game") + actual = score [] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex18 = verify do + labeled "an incomplete game cannot be scored" do + expected = Left ( Error "Score cannot be taken until the end of the game") + actual = score [0,0] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex19 = verify do + labeled "bonus rolls for a strike in the last frame must be rolled before score can be calculated" do + expected = Left ( Error "Score cannot be taken until the end of the game") + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex20 = verify do + labeled "both bonus rolls for a strike in the last frame must be rolled before score can be calculated" do + expected = Left ( Error "Score cannot be taken until the end of the game") + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +bowling.test.ex21 = verify do + labeled "bonus roll for a spare in the last frame must be rolled before score can be calculated" do + expected = Left ( Error "Score cannot be taken until the end of the game") + actual = score [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,3] + label "expected" expected + label "actual" actual + ensureEqual expected actual + +test> bowling.tests = join [ bowling.test.ex1, bowling.test.ex2, bowling.test.ex3, diff --git a/exercises/practice/change/.meta/testAnnotation.json b/exercises/practice/change/.meta/testAnnotation.json index 2b788eb..f0a513f 100644 --- a/exercises/practice/change/.meta/testAnnotation.json +++ b/exercises/practice/change/.meta/testAnnotation.json @@ -1,46 +1,46 @@ [ { "name": "change for 1 cent", - "test_code": "let\n Test.label.deprecated \"change for 1 cent\" <| Test.expect (findFewestCoins [1,5,10,25] 1 === Some [1])" + "test_code": "verify do\n labeled \"change for 1 cent\" do\n expected = Some [1]\n actual = findFewestCoins [1,5,10,25] 1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "single coin change", - "test_code": "let\n Test.label.deprecated \"single coin change\" <| Test.expect (findFewestCoins [1,5,10,25,100] 25 === Some [25])" + "test_code": "verify do\n labeled \"single coin change\" do\n expected = Some [25]\n actual = findFewestCoins [1,5,10,25,100] 25\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "multiple coin change", - "test_code": "let\n Test.label.deprecated \"multiple coin change\" <| Test.expect (findFewestCoins [1,5,10,25,100] 15 === Some [5,10])" + "test_code": "verify do\n labeled \"multiple coin change\" do\n expected = Some [5,10]\n actual = findFewestCoins [1,5,10,25,100] 15\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "change with Lilliputian Coins", - "test_code": "let\n Test.label.deprecated \"change with Lilliputian Coins\" <| Test.expect (findFewestCoins [1,4,15,20,50] 23 === Some [4,4,15])" + "test_code": "verify do\n labeled \"change with Lilliputian Coins\" do\n expected = Some [4,4,15]\n actual = findFewestCoins [1,4,15,20,50] 23\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "change with Lower Elbonia Coins", - "test_code": "let\n Test.label.deprecated \"change with Lower Elbonia Coins\" <| Test.expect (findFewestCoins [1,5,10,21,25] 63 === Some [21,21,21])" + "test_code": "verify do\n labeled \"change with Lower Elbonia Coins\" do\n expected = Some [21,21,21]\n actual = findFewestCoins [1,5,10,21,25] 63\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "large target values", - "test_code": "let\n Test.label.deprecated \"large target values\" <| Test.expect (findFewestCoins [1,2,5,10,20,50,100] 999 === Some [2,2,5,20,20,50,100,100,100,100,100,100,100,100,100])" + "test_code": "verify do\n labeled \"large target values\" do\n expected = Some [2,2,5,20,20,50,100,100,100,100,100,100,100,100,100]\n actual = findFewestCoins [1,2,5,10,20,50,100] 999\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "possible change without unit coins available", - "test_code": "let\n Test.label.deprecated \"possible change without unit coins available\" <| Test.expect (findFewestCoins [2,5,10,20,50] 21 === Some [2,2,2,5,10])" + "test_code": "verify do\n labeled \"possible change without unit coins available\" do\n expected = Some [2,2,2,5,10]\n actual = findFewestCoins [2,5,10,20,50] 21\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "another possible change without unit coins available", - "test_code": "let\n Test.label.deprecated \"another possible change without unit coins available\" <| Test.expect (findFewestCoins [4,5] 27 === Some [4,4,4,5,5,5])" + "test_code": "verify do\n labeled \"another possible change without unit coins available\" do\n expected = Some [4,4,4,5,5,5]\n actual = findFewestCoins [4,5] 27\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "no coins make 0 change", - "test_code": "let\n Test.label.deprecated \"no coins make 0 change\" <| Test.expect (findFewestCoins [1,5,10,21,25] 0 === Some [])" + "test_code": "verify do\n labeled \"no coins make 0 change\" do\n expected = Some []\n actual = findFewestCoins [1,5,10,21,25] 0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "error testing for change smaller than the smallest of coins", - "test_code": "let\n Test.label.deprecated \"error testing for change smaller than the smallest of coins\" <| Test.expect (findFewestCoins [5,10] 3 === None)" + "test_code": "verify do\n labeled \"error testing for change smaller than the smallest of coins\" do\n expected = None\n actual = findFewestCoins [5,10] 3\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "error if no combination can add up to target", - "test_code": "let\n Test.label.deprecated \"error if no combination can add up to target\" <| Test.expect (findFewestCoins [5,10] 94 === None)" + "test_code": "verify do\n labeled \"error if no combination can add up to target\" do\n expected = None\n actual = findFewestCoins [5,10] 94\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/change/change.test.u b/exercises/practice/change/change.test.u index a5caa2e..f8510d4 100644 --- a/exercises/practice/change/change.test.u +++ b/exercises/practice/change/change.test.u @@ -1,37 +1,92 @@ -change.test.ex1 = let - Test.label.deprecated "change for 1 cent" <| Test.expect (findFewestCoins [1,5,10,25] 1 === Some [1]) +change.test.ex1 = verify do + labeled "change for 1 cent" do + expected = Some [1] + actual = findFewestCoins [1,5,10,25] 1 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex2 = let - Test.label.deprecated "single coin change" <| Test.expect (findFewestCoins [1,5,10,25,100] 25 === Some [25]) +change.test.ex2 = verify do + labeled "single coin change" do + expected = Some [25] + actual = findFewestCoins [1,5,10,25,100] 25 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex3 = let - Test.label.deprecated "multiple coin change" <| Test.expect (findFewestCoins [1,5,10,25,100] 15 === Some [5,10]) +change.test.ex3 = verify do + labeled "multiple coin change" do + expected = Some [5,10] + actual = findFewestCoins [1,5,10,25,100] 15 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex4 = let - Test.label.deprecated "change with Lilliputian Coins" <| Test.expect (findFewestCoins [1,4,15,20,50] 23 === Some [4,4,15]) +change.test.ex4 = verify do + labeled "change with Lilliputian Coins" do + expected = Some [4,4,15] + actual = findFewestCoins [1,4,15,20,50] 23 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex5 = let - Test.label.deprecated "change with Lower Elbonia Coins" <| Test.expect (findFewestCoins [1,5,10,21,25] 63 === Some [21,21,21]) +change.test.ex5 = verify do + labeled "change with Lower Elbonia Coins" do + expected = Some [21,21,21] + actual = findFewestCoins [1,5,10,21,25] 63 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex6 = let - Test.label.deprecated "large target values" <| Test.expect (findFewestCoins [1,2,5,10,20,50,100] 999 === Some [2,2,5,20,20,50,100,100,100,100,100,100,100,100,100]) +change.test.ex6 = verify do + labeled "large target values" do + expected = Some [2,2,5,20,20,50,100,100,100,100,100,100,100,100,100] + actual = findFewestCoins [1,2,5,10,20,50,100] 999 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex7 = let - Test.label.deprecated "possible change without unit coins available" <| Test.expect (findFewestCoins [2,5,10,20,50] 21 === Some [2,2,2,5,10]) +change.test.ex7 = verify do + labeled "possible change without unit coins available" do + expected = Some [2,2,2,5,10] + actual = findFewestCoins [2,5,10,20,50] 21 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex8 = let - Test.label.deprecated "another possible change without unit coins available" <| Test.expect (findFewestCoins [4,5] 27 === Some [4,4,4,5,5,5]) +change.test.ex8 = verify do + labeled "another possible change without unit coins available" do + expected = Some [4,4,4,5,5,5] + actual = findFewestCoins [4,5] 27 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex9 = let - Test.label.deprecated "no coins make 0 change" <| Test.expect (findFewestCoins [1,5,10,21,25] 0 === Some []) +change.test.ex9 = verify do + labeled "no coins make 0 change" do + expected = Some [] + actual = findFewestCoins [1,5,10,21,25] 0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex10 = let - Test.label.deprecated "error testing for change smaller than the smallest of coins" <| Test.expect (findFewestCoins [5,10] 3 === None) +change.test.ex10 = verify do + labeled "error testing for change smaller than the smallest of coins" do + expected = None + actual = findFewestCoins [5,10] 3 + label "expected" expected + label "actual" actual + ensureEqual expected actual -change.test.ex11 = let - Test.label.deprecated "error if no combination can add up to target" <| Test.expect (findFewestCoins [5,10] 94 === None) +change.test.ex11 = verify do + labeled "error if no combination can add up to target" do + expected = None + actual = findFewestCoins [5,10] 94 + label "expected" expected + label "actual" actual + ensureEqual expected actual -test> change.tests = runAll [ +test> change.tests = join [ change.test.ex1, change.test.ex2, change.test.ex3, @@ -44,4 +99,3 @@ test> change.tests = runAll [ change.test.ex10, change.test.ex11 ] - From 6c76b9662cc2b0176d152a135435c39c088ef347 Mon Sep 17 00:00:00 2001 From: SimaDovakin Date: Sat, 8 Feb 2025 17:28:58 +0200 Subject: [PATCH 2/2] Test upgrades for the following exercises: - clock - Collatz conjecture - crypto square - darts - diamond - difference of squares - D'n'D character --- .../practice/clock/.meta/testAnnotation.json | 106 ++-- exercises/practice/clock/clock.test.u | 574 +++++++++++++----- .../.meta/testAnnotation.json | 12 +- .../collatz-conjecture/collatz.test.u | 47 +- .../crypto-square/.meta/testAnnotation.json | 16 +- .../practice/crypto-square/crypto.test.u | 65 +- .../practice/darts/.meta/testAnnotation.json | 28 +- exercises/practice/darts/darts.test.u | 119 +++- .../diamond/.meta/testAnnotation.json | 12 +- exercises/practice/diamond/diamond.test.u | 47 +- .../.meta/testAnnotation.json | 20 +- .../differenceOfSquares.test.u | 85 ++- .../dnd-character/.meta/testAnnotation.json | 36 +- .../dnd-character/dndCharacter.test.u | 286 +++++---- 14 files changed, 982 insertions(+), 471 deletions(-) diff --git a/exercises/practice/clock/.meta/testAnnotation.json b/exercises/practice/clock/.meta/testAnnotation.json index e9f1420..2f79274 100644 --- a/exercises/practice/clock/.meta/testAnnotation.json +++ b/exercises/practice/clock/.meta/testAnnotation.json @@ -1,210 +1,210 @@ [ { "name": "Create a new clock with an initial time, on the hour", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, on the hour\" <| Test.expect (create +8 +0 === \"08:00\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, on the hour\" do\n expected = \"08:00\"\n actual = create +8 +0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, past the hour", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, past the hour\" <| Test.expect (create +11 +9 === \"11:09\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, past the hour\" do\n expected = \"11:09\"\n actual = create +11 +9\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, midnight is zero hours", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, midnight is zero hours\" <| Test.expect (create +24 +0 === \"00:00\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, midnight is zero hours\" do\n expected = \"00:00\"\n actual = create +24 +0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, hour rolls over", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, hour rolls over\" <| Test.expect (create +25 +0 === \"01:00\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, hour rolls over\" do\n expected = \"01:00\"\n actual = create +25 +0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, hour rolls over continuously", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, hour rolls over continuously\" <| Test.expect (create +100 +0 === \"04:00\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, hour rolls over continuously\" do\n expected = \"04:00\"\n actual = create +100 +0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, sixty minutes is next hour", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, sixty minutes is next hour\" <| Test.expect (create +1 +60 === \"02:00\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, sixty minutes is next hour\" do\n expected = \"02:00\"\n actual = create +1 +60\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, minutes roll over", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, minutes roll over\" <| Test.expect (create +0 +160 === \"02:40\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, minutes roll over\" do\n expected = \"02:40\"\n actual = create +0 +160\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, minutes roll over continuously", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, minutes roll over continuously\" <| Test.expect (create +0 +1723 === \"04:43\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, minutes roll over continuously\" do\n expected = \"04:43\"\n actual = create +0 +1723\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, hour and minutes roll over", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, hour and minutes roll over\" <| Test.expect (create +25 +160 === \"03:40\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, hour and minutes roll over\" do\n expected = \"03:40\"\n actual = create +25 +160\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, hour and minutes roll over continuously", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, hour and minutes roll over continuously\" <| Test.expect (create +201 +3001 === \"11:01\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, hour and minutes roll over continuously\" do\n expected = \"11:01\"\n actual = create +201 +3001\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, hour and minutes roll over to exactly midnight", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, hour and minutes roll over to exactly midnight\" <| Test.expect (create +72 +8640 === \"00:00\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, hour and minutes roll over to exactly midnight\" do\n expected = \"00:00\"\n actual = create +72 +8640\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, negative hour", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, negative hour\" <| Test.expect (create -1 +15 === \"23:15\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, negative hour\" do\n expected = \"23:15\"\n actual = create -1 +15\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, negative hour rolls over", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, negative hour rolls over\" <| Test.expect (create -25 +0 === \"23:00\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, negative hour rolls over\" do\n expected = \"23:00\"\n actual = create -25 +0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, negative hour rolls over continuously", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, negative hour rolls over continuously\" <| Test.expect (create -91 +0 === \"05:00\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, negative hour rolls over continuously\" do\n expected = \"05:00\"\n actual = create -91 +0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, negative minutes", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, negative minutes\" <| Test.expect (create +1 -40 === \"00:20\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, negative minutes\" do\n expected = \"00:20\"\n actual = create +1 -40\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, negative minutes roll over", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, negative minutes roll over\" <| Test.expect (create +1 -160 === \"22:20\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, negative minutes roll over\" do\n expected = \"22:20\"\n actual = create +1 -160\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, negative minutes roll over continuously", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, negative minutes roll over continuously\" <| Test.expect (create +1 -4820 === \"16:40\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, negative minutes roll over continuously\" do\n expected = \"16:40\"\n actual = create +1 -4820\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, negative sixty minutes is previous hour", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, negative sixty minutes is previous hour\" <| Test.expect (create +2 -60 === \"01:00\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, negative sixty minutes is previous hour\" do\n expected = \"01:00\"\n actual = create +2 -60\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, negative hour and minutes both roll over", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, negative hour and minutes both roll over\" <| Test.expect (create -25 -160 === \"20:20\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, negative hour and minutes both roll over\" do\n expected = \"20:20\"\n actual = create -25 -160\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Create a new clock with an initial time, negative hour and minutes both roll over continuously", - "test_code": "let\n Test.label.deprecated \"Create a new clock with an initial time, negative hour and minutes both roll over continuously\" <| Test.expect (create -121 -5810 === \"22:10\")" + "test_code": "verify do\n labeled \"Create a new clock with an initial time, negative hour and minutes both roll over continuously\" do\n expected = \"22:10\"\n actual = create -121 -5810\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Add minutes, add minutes", - "test_code": "let\n Test.label.deprecated \"Add minutes, add minutes\" <| Test.expect (add +10 +0 +3 === \"10:03\")" + "test_code": "verify do\n labeled \"Add minutes, add minutes\" do\n expected = \"10:03\"\n actual = add +10 +0 +3\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Add minutes, add no minutes", - "test_code": "let\n Test.label.deprecated \"Add minutes, add no minutes\" <| Test.expect (add +6 +41 +0 === \"06:41\")" + "test_code": "verify do\n labeled \"Add minutes, add no minutes\" do\n expected = \"06:41\"\n actual = add +6 +41 +0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Add minutes, add to next hour", - "test_code": "let\n Test.label.deprecated \"Add minutes, add to next hour\" <| Test.expect (add +0 +45 +40 === \"01:25\")" + "test_code": "verify do\n labeled \"Add minutes, add to next hour\" do\n expected = \"01:25\"\n actual = add +0 +45 +40\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Add minutes, add more than one hour", - "test_code": "let\n Test.label.deprecated \"Add minutes, add more than one hour\" <| Test.expect (add +10 +0 +61 === \"11:01\")" + "test_code": "verify do\n labeled \"Add minutes, add more than one hour\" do\n expected = \"11:01\"\n actual = add +10 +0 +61\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Add minutes, add more than two hours with carry", - "test_code": "let\n Test.label.deprecated \"Add minutes, add more than two hours with carry\" <| Test.expect (add +0 +45 +160 === \"03:25\")" + "test_code": "verify do\n labeled \"Add minutes, add more than two hours with carry\" do\n expected = \"03:25\"\n actual = add +0 +45 +160\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Add minutes, add across midnight", - "test_code": "let\n Test.label.deprecated \"Add minutes, add across midnight\" <| Test.expect (add +23 +59 +2 === \"00:01\")" + "test_code": "verify do\n labeled \"Add minutes, add across midnight\" do\n expected = \"00:01\"\n actual = add +23 +59 +2\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Add minutes, add more than one day (1500 min = 25 hrs)", - "test_code": "let\n Test.label.deprecated \"Add minutes, add more than one day (1500 min = 25 hrs)\" <| Test.expect (add +5 +32 +1500 === \"06:32\")" + "test_code": "verify do\n labeled \"Add minutes, add more than one day (1500 min = 25 hrs)\" do\n expected = \"06:32\"\n actual = add +5 +32 +1500\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Add minutes, add more than two days", - "test_code": "let\n Test.label.deprecated \"Add minutes, add more than two days\" <| Test.expect (add +1 +1 +3500 === \"11:21\")" + "test_code": "verify do\n labeled \"Add minutes, add more than two days\" do\n expected = \"11:21\"\n actual = add +1 +1 +3500\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Subtract minutes, subtract minutes", - "test_code": "let\n Test.label.deprecated \"Subtract minutes, subtract minutes\" <| Test.expect (subtract +10 +3 +3 === \"10:00\")" + "test_code": "verify do\n labeled \"Subtract minutes, subtract minutes\" do\n expected = \"10:00\"\n actual = subtract +10 +3 +3\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Subtract minutes, subtract to previous hour", - "test_code": "let\n Test.label.deprecated \"Subtract minutes, subtract to previous hour\" <| Test.expect (subtract +10 +3 +30 === \"09:33\")" + "test_code": "verify do\n labeled \"Subtract minutes, subtract to previous hour\" do\n expected = \"09:33\"\n actual = subtract +10 +3 +30\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Subtract minutes, subtract more than an hour", - "test_code": "let\n Test.label.deprecated \"Subtract minutes, subtract more than an hour\" <| Test.expect (subtract +10 +3 +70 === \"08:53\")" + "test_code": "verify do\n labeled \"Subtract minutes, subtract more than an hour\" do\n expected = \"08:53\"\n actual = subtract +10 +3 +70\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Subtract minutes, subtract across midnight", - "test_code": "let\n Test.label.deprecated \"Subtract minutes, subtract across midnight\" <| Test.expect (subtract +0 +3 +4 === \"23:59\")" + "test_code": "verify do\n labeled \"Subtract minutes, subtract across midnight\" do\n expected = \"23:59\"\n actual = subtract +0 +3 +4\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Subtract minutes, subtract more than two hours", - "test_code": "let\n Test.label.deprecated \"Subtract minutes, subtract more than two hours\" <| Test.expect (subtract +0 +0 +160 === \"21:20\")" + "test_code": "verify do\n labeled \"Subtract minutes, subtract more than two hours\" do\n expected = \"21:20\"\n actual = subtract +0 +0 +160\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Subtract minutes, subtract more than two hours with borrow", - "test_code": "let\n Test.label.deprecated \"Subtract minutes, subtract more than two hours with borrow\" <| Test.expect (subtract +6 +15 +160 === \"03:35\")" + "test_code": "verify do\n labeled \"Subtract minutes, subtract more than two hours with borrow\" do\n expected = \"03:35\"\n actual = subtract +6 +15 +160\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Subtract minutes, subtract more than one day (1500 min = 25 hrs)", - "test_code": "let\n Test.label.deprecated \"Subtract minutes, subtract more than one day (1500 min = 25 hrs)\" <| Test.expect (subtract +5 +32 +1500 === \"04:32\")" + "test_code": "verify do\n labeled \"Subtract minutes, subtract more than one day (1500 min = 25 hrs)\" do\n expected = \"04:32\"\n actual = subtract +5 +32 +1500\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Subtract minutes, subtract more than two days", - "test_code": "let\n Test.label.deprecated \"Subtract minutes, subtract more than two days\" <| Test.expect (subtract +2 +20 +3000 === \"00:20\")" + "test_code": "verify do\n labeled \"Subtract minutes, subtract more than two days\" do\n expected = \"00:20\"\n actual = subtract +2 +20 +3000\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with same time", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with same time\" <| Test.expect (equal (+15, +37) (+15, +37) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with same time\" do\n expected = true\n actual = equal (+15, +37) (+15, +37)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks a minute apart", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks a minute apart\" <| Test.expect (equal (+15, +36) (+15, +37) === false)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks a minute apart\" do\n expected = false\n actual = equal (+15, +36) (+15, +37)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks an hour apart", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks an hour apart\" <| Test.expect (equal (+14, +37) (+15, +37) === false)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks an hour apart\" do\n expected = false\n actual = equal (+14, +37) (+15, +37)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with hour overflow", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with hour overflow\" <| Test.expect (equal (+10, +37) (+34, +37) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with hour overflow\" do\n expected = true\n actual = equal (+10, +37) (+34, +37)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with hour overflow by several days", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with hour overflow by several days\" <| Test.expect (equal (+3, +11) (+99, +11) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with hour overflow by several days\" do\n expected = true\n actual = equal (+3, +11) (+99, +11)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with negative hour", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with negative hour\" <| Test.expect (equal (+22, +40) (-2, +40) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with negative hour\" do\n expected = true\n actual = equal (+22, +40) (-2, +40)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with negative hour that wraps", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with negative hour that wraps\" <| Test.expect (equal (+17, +3) (-31, +3) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with negative hour that wraps\" do\n expected = true\n actual = equal (+17, +3) (-31, +3)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with negative hour that wraps multiple times", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with negative hour that wraps multiple times\" <| Test.expect (equal (+13, +49) (-83, +49) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with negative hour that wraps multiple times\" do\n expected = true\n actual = equal (+13, +49) (-83, +49)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with minute overflow", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with minute overflow\" <| Test.expect (equal (+0, +1) (+0, +1441) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with minute overflow\" do\n expected = true\n actual = equal (+0, +1) (+0, +1441)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with minute overflow by several days", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with minute overflow by several days\" <| Test.expect (equal (+2, +2) (+2, +4322) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with minute overflow by several days\" do\n expected = true\n actual = equal (+2, +2) (+2, +4322)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with negative minute", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with negative minute\" <| Test.expect (equal (+2, +40) (+3, -20) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with negative minute\" do\n expected = true\n actual = equal (+2, +40) (+3, -20)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with negative minute that wraps", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with negative minute that wraps\" <| Test.expect (equal (+4, +10) (+5, -1490) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with negative minute that wraps\" do\n expected = true\n actual = equal (+4, +10) (+5, -1490)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with negative minute that wraps multiple times", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with negative minute that wraps multiple times\" <| Test.expect (equal (+6, +15) (+6, -4305) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with negative minute that wraps multiple times\" do\n expected = true\n actual = equal (+6, +15) (+6, -4305)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with negative hours and minutes", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with negative hours and minutes\" <| Test.expect (equal (+7, +32) (-12, -268) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with negative hours and minutes\" do\n expected = true\n actual = equal (+7, +32) (-12, -268)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, clocks with negative hours and minutes that wrap", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, clocks with negative hours and minutes that wrap\" <| Test.expect (equal (+18, +7) (-54, -11513) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, clocks with negative hours and minutes that wrap\" do\n expected = true\n actual = equal (+18, +7) (-54, -11513)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Compare two clocks for equality, full clock and zeroed clock", - "test_code": "let\n Test.label.deprecated \"Compare two clocks for equality, full clock and zeroed clock\" <| Test.expect (equal (+24, +0) (+0, +0) === true)" + "test_code": "verify do\n labeled \"Compare two clocks for equality, full clock and zeroed clock\" do\n expected = true\n actual = equal (+24, +0) (+0, +0)\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/clock/clock.test.u b/exercises/practice/clock/clock.test.u index 7ed5e1b..1697215 100644 --- a/exercises/practice/clock/clock.test.u +++ b/exercises/practice/clock/clock.test.u @@ -1,160 +1,420 @@ -clock.test.ex1 = let - Test.label.deprecated "Create a new clock with an initial time, on the hour" <| Test.expect (create +8 +0 === "08:00") - -clock.test.ex2 = let - Test.label.deprecated "Create a new clock with an initial time, past the hour" <| Test.expect (create +11 +9 === "11:09") - -clock.test.ex3 = let - Test.label.deprecated "Create a new clock with an initial time, midnight is zero hours" <| Test.expect (create +24 +0 === "00:00") - -clock.test.ex4 = let - Test.label.deprecated "Create a new clock with an initial time, hour rolls over" <| Test.expect (create +25 +0 === "01:00") - -clock.test.ex5 = let - Test.label.deprecated "Create a new clock with an initial time, hour rolls over continuously" <| Test.expect (create +100 +0 === "04:00") - -clock.test.ex6 = let - Test.label.deprecated "Create a new clock with an initial time, sixty minutes is next hour" <| Test.expect (create +1 +60 === "02:00") - -clock.test.ex7 = let - Test.label.deprecated "Create a new clock with an initial time, minutes roll over" <| Test.expect (create +0 +160 === "02:40") - -clock.test.ex8 = let - Test.label.deprecated "Create a new clock with an initial time, minutes roll over continuously" <| Test.expect (create +0 +1723 === "04:43") - -clock.test.ex9 = let - Test.label.deprecated "Create a new clock with an initial time, hour and minutes roll over" <| Test.expect (create +25 +160 === "03:40") - -clock.test.ex10 = let - Test.label.deprecated "Create a new clock with an initial time, hour and minutes roll over continuously" <| Test.expect (create +201 +3001 === "11:01") - -clock.test.ex11 = let - Test.label.deprecated "Create a new clock with an initial time, hour and minutes roll over to exactly midnight" <| Test.expect (create +72 +8640 === "00:00") - -clock.test.ex12 = let - Test.label.deprecated "Create a new clock with an initial time, negative hour" <| Test.expect (create -1 +15 === "23:15") - -clock.test.ex13 = let - Test.label.deprecated "Create a new clock with an initial time, negative hour rolls over" <| Test.expect (create -25 +0 === "23:00") - -clock.test.ex14 = let - Test.label.deprecated "Create a new clock with an initial time, negative hour rolls over continuously" <| Test.expect (create -91 +0 === "05:00") - -clock.test.ex15 = let - Test.label.deprecated "Create a new clock with an initial time, negative minutes" <| Test.expect (create +1 -40 === "00:20") - -clock.test.ex16 = let - Test.label.deprecated "Create a new clock with an initial time, negative minutes roll over" <| Test.expect (create +1 -160 === "22:20") - -clock.test.ex17 = let - Test.label.deprecated "Create a new clock with an initial time, negative minutes roll over continuously" <| Test.expect (create +1 -4820 === "16:40") - -clock.test.ex18 = let - Test.label.deprecated "Create a new clock with an initial time, negative sixty minutes is previous hour" <| Test.expect (create +2 -60 === "01:00") - -clock.test.ex19 = let - Test.label.deprecated "Create a new clock with an initial time, negative hour and minutes both roll over" <| Test.expect (create -25 -160 === "20:20") - -clock.test.ex20 = let - Test.label.deprecated "Create a new clock with an initial time, negative hour and minutes both roll over continuously" <| Test.expect (create -121 -5810 === "22:10") - -clock.test.ex21 = let - Test.label.deprecated "Add minutes, add minutes" <| Test.expect (add +10 +0 +3 === "10:03") - -clock.test.ex22 = let - Test.label.deprecated "Add minutes, add no minutes" <| Test.expect (add +6 +41 +0 === "06:41") - -clock.test.ex23 = let - Test.label.deprecated "Add minutes, add to next hour" <| Test.expect (add +0 +45 +40 === "01:25") - -clock.test.ex24 = let - Test.label.deprecated "Add minutes, add more than one hour" <| Test.expect (add +10 +0 +61 === "11:01") - -clock.test.ex25 = let - Test.label.deprecated "Add minutes, add more than two hours with carry" <| Test.expect (add +0 +45 +160 === "03:25") - -clock.test.ex26 = let - Test.label.deprecated "Add minutes, add across midnight" <| Test.expect (add +23 +59 +2 === "00:01") - -clock.test.ex27 = let - Test.label.deprecated "Add minutes, add more than one day (1500 min = 25 hrs)" <| Test.expect (add +5 +32 +1500 === "06:32") - -clock.test.ex28 = let - Test.label.deprecated "Add minutes, add more than two days" <| Test.expect (add +1 +1 +3500 === "11:21") - -clock.test.ex29 = let - Test.label.deprecated "Subtract minutes, subtract minutes" <| Test.expect (subtract +10 +3 +3 === "10:00") - -clock.test.ex30 = let - Test.label.deprecated "Subtract minutes, subtract to previous hour" <| Test.expect (subtract +10 +3 +30 === "09:33") - -clock.test.ex31 = let - Test.label.deprecated "Subtract minutes, subtract more than an hour" <| Test.expect (subtract +10 +3 +70 === "08:53") - -clock.test.ex32 = let - Test.label.deprecated "Subtract minutes, subtract across midnight" <| Test.expect (subtract +0 +3 +4 === "23:59") - -clock.test.ex33 = let - Test.label.deprecated "Subtract minutes, subtract more than two hours" <| Test.expect (subtract +0 +0 +160 === "21:20") - -clock.test.ex34 = let - Test.label.deprecated "Subtract minutes, subtract more than two hours with borrow" <| Test.expect (subtract +6 +15 +160 === "03:35") - -clock.test.ex35 = let - Test.label.deprecated "Subtract minutes, subtract more than one day (1500 min = 25 hrs)" <| Test.expect (subtract +5 +32 +1500 === "04:32") - -clock.test.ex36 = let - Test.label.deprecated "Subtract minutes, subtract more than two days" <| Test.expect (subtract +2 +20 +3000 === "00:20") - -clock.test.ex37 = let - Test.label.deprecated "Compare two clocks for equality, clocks with same time" <| Test.expect (equal (+15, +37) (+15, +37) === true) - -clock.test.ex38 = let - Test.label.deprecated "Compare two clocks for equality, clocks a minute apart" <| Test.expect (equal (+15, +36) (+15, +37) === false) - -clock.test.ex39 = let - Test.label.deprecated "Compare two clocks for equality, clocks an hour apart" <| Test.expect (equal (+14, +37) (+15, +37) === false) - -clock.test.ex40 = let - Test.label.deprecated "Compare two clocks for equality, clocks with hour overflow" <| Test.expect (equal (+10, +37) (+34, +37) === true) - -clock.test.ex41 = let - Test.label.deprecated "Compare two clocks for equality, clocks with hour overflow by several days" <| Test.expect (equal (+3, +11) (+99, +11) === true) - -clock.test.ex42 = let - Test.label.deprecated "Compare two clocks for equality, clocks with negative hour" <| Test.expect (equal (+22, +40) (-2, +40) === true) - -clock.test.ex43 = let - Test.label.deprecated "Compare two clocks for equality, clocks with negative hour that wraps" <| Test.expect (equal (+17, +3) (-31, +3) === true) - -clock.test.ex44 = let - Test.label.deprecated "Compare two clocks for equality, clocks with negative hour that wraps multiple times" <| Test.expect (equal (+13, +49) (-83, +49) === true) - -clock.test.ex45 = let - Test.label.deprecated "Compare two clocks for equality, clocks with minute overflow" <| Test.expect (equal (+0, +1) (+0, +1441) === true) - -clock.test.ex46 = let - Test.label.deprecated "Compare two clocks for equality, clocks with minute overflow by several days" <| Test.expect (equal (+2, +2) (+2, +4322) === true) - -clock.test.ex47 = let - Test.label.deprecated "Compare two clocks for equality, clocks with negative minute" <| Test.expect (equal (+2, +40) (+3, -20) === true) - -clock.test.ex48 = let - Test.label.deprecated "Compare two clocks for equality, clocks with negative minute that wraps" <| Test.expect (equal (+4, +10) (+5, -1490) === true) - -clock.test.ex49 = let - Test.label.deprecated "Compare two clocks for equality, clocks with negative minute that wraps multiple times" <| Test.expect (equal (+6, +15) (+6, -4305) === true) - -clock.test.ex50 = let - Test.label.deprecated "Compare two clocks for equality, clocks with negative hours and minutes" <| Test.expect (equal (+7, +32) (-12, -268) === true) - -clock.test.ex51 = let - Test.label.deprecated "Compare two clocks for equality, clocks with negative hours and minutes that wrap" <| Test.expect (equal (+18, +7) (-54, -11513) === true) - -clock.test.ex52 = let - Test.label.deprecated "Compare two clocks for equality, full clock and zeroed clock" <| Test.expect (equal (+24, +0) (+0, +0) === true) - -test> clock.tests = runAll [ +clock.test.ex1 = verify do + labeled "Create a new clock with an initial time, on the hour" do + expected = "08:00" + actual = create +8 +0 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex2 = verify do + labeled "Create a new clock with an initial time, past the hour" do + expected = "11:09" + actual = create +11 +9 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex3 = verify do + labeled "Create a new clock with an initial time, midnight is zero hours" do + expected = "00:00" + actual = create +24 +0 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex4 = verify do + labeled "Create a new clock with an initial time, hour rolls over" do + expected = "01:00" + actual = create +25 +0 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex5 = verify do + labeled "Create a new clock with an initial time, hour rolls over continuously" do + expected = "04:00" + actual = create +100 +0 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex6 = verify do + labeled "Create a new clock with an initial time, sixty minutes is next hour" do + expected = "02:00" + actual = create +1 +60 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex7 = verify do + labeled "Create a new clock with an initial time, minutes roll over" do + expected = "02:40" + actual = create +0 +160 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex8 = verify do + labeled "Create a new clock with an initial time, minutes roll over continuously" do + expected = "04:43" + actual = create +0 +1723 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex9 = verify do + labeled "Create a new clock with an initial time, hour and minutes roll over" do + expected = "03:40" + actual = create +25 +160 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex10 = verify do + labeled "Create a new clock with an initial time, hour and minutes roll over continuously" do + expected = "11:01" + actual = create +201 +3001 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex11 = verify do + labeled "Create a new clock with an initial time, hour and minutes roll over to exactly midnight" do + expected = "00:00" + actual = create +72 +8640 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex12 = verify do + labeled "Create a new clock with an initial time, negative hour" do + expected = "23:15" + actual = create -1 +15 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex13 = verify do + labeled "Create a new clock with an initial time, negative hour rolls over" do + expected = "23:00" + actual = create -25 +0 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex14 = verify do + labeled "Create a new clock with an initial time, negative hour rolls over continuously" do + expected = "05:00" + actual = create -91 +0 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex15 = verify do + labeled "Create a new clock with an initial time, negative minutes" do + expected = "00:20" + actual = create +1 -40 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex16 = verify do + labeled "Create a new clock with an initial time, negative minutes roll over" do + expected = "22:20" + actual = create +1 -160 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex17 = verify do + labeled "Create a new clock with an initial time, negative minutes roll over continuously" do + expected = "16:40" + actual = create +1 -4820 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex18 = verify do + labeled "Create a new clock with an initial time, negative sixty minutes is previous hour" do + expected = "01:00" + actual = create +2 -60 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex19 = verify do + labeled "Create a new clock with an initial time, negative hour and minutes both roll over" do + expected = "20:20" + actual = create -25 -160 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex20 = verify do + labeled "Create a new clock with an initial time, negative hour and minutes both roll over continuously" do + expected = "22:10" + actual = create -121 -5810 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex21 = verify do + labeled "Add minutes, add minutes" do + expected = "10:03" + actual = add +10 +0 +3 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex22 = verify do + labeled "Add minutes, add no minutes" do + expected = "06:41" + actual = add +6 +41 +0 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex23 = verify do + labeled "Add minutes, add to next hour" do + expected = "01:25" + actual = add +0 +45 +40 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex24 = verify do + labeled "Add minutes, add more than one hour" do + expected = "11:01" + actual = add +10 +0 +61 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex25 = verify do + labeled "Add minutes, add more than two hours with carry" do + expected = "03:25" + actual = add +0 +45 +160 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex26 = verify do + labeled "Add minutes, add across midnight" do + expected = "00:01" + actual = add +23 +59 +2 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex27 = verify do + labeled "Add minutes, add more than one day (1500 min = 25 hrs)" do + expected = "06:32" + actual = add +5 +32 +1500 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex28 = verify do + labeled "Add minutes, add more than two days" do + expected = "11:21" + actual = add +1 +1 +3500 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex29 = verify do + labeled "Subtract minutes, subtract minutes" do + expected = "10:00" + actual = subtract +10 +3 +3 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex30 = verify do + labeled "Subtract minutes, subtract to previous hour" do + expected = "09:33" + actual = subtract +10 +3 +30 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex31 = verify do + labeled "Subtract minutes, subtract more than an hour" do + expected = "08:53" + actual = subtract +10 +3 +70 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex32 = verify do + labeled "Subtract minutes, subtract across midnight" do + expected = "23:59" + actual = subtract +0 +3 +4 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex33 = verify do + labeled "Subtract minutes, subtract more than two hours" do + expected = "21:20" + actual = subtract +0 +0 +160 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex34 = verify do + labeled "Subtract minutes, subtract more than two hours with borrow" do + expected = "03:35" + actual = subtract +6 +15 +160 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex35 = verify do + labeled "Subtract minutes, subtract more than one day (1500 min = 25 hrs)" do + expected = "04:32" + actual = subtract +5 +32 +1500 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex36 = verify do + labeled "Subtract minutes, subtract more than two days" do + expected = "00:20" + actual = subtract +2 +20 +3000 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex37 = verify do + labeled "Compare two clocks for equality, clocks with same time" do + expected = true + actual = equal (+15, +37) (+15, +37) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex38 = verify do + labeled "Compare two clocks for equality, clocks a minute apart" do + expected = false + actual = equal (+15, +36) (+15, +37) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex39 = verify do + labeled "Compare two clocks for equality, clocks an hour apart" do + expected = false + actual = equal (+14, +37) (+15, +37) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex40 = verify do + labeled "Compare two clocks for equality, clocks with hour overflow" do + expected = true + actual = equal (+10, +37) (+34, +37) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex41 = verify do + labeled "Compare two clocks for equality, clocks with hour overflow by several days" do + expected = true + actual = equal (+3, +11) (+99, +11) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex42 = verify do + labeled "Compare two clocks for equality, clocks with negative hour" do + expected = true + actual = equal (+22, +40) (-2, +40) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex43 = verify do + labeled "Compare two clocks for equality, clocks with negative hour that wraps" do + expected = true + actual = equal (+17, +3) (-31, +3) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex44 = verify do + labeled "Compare two clocks for equality, clocks with negative hour that wraps multiple times" do + expected = true + actual = equal (+13, +49) (-83, +49) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex45 = verify do + labeled "Compare two clocks for equality, clocks with minute overflow" do + expected = true + actual = equal (+0, +1) (+0, +1441) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex46 = verify do + labeled "Compare two clocks for equality, clocks with minute overflow by several days" do + expected = true + actual = equal (+2, +2) (+2, +4322) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex47 = verify do + labeled "Compare two clocks for equality, clocks with negative minute" do + expected = true + actual = equal (+2, +40) (+3, -20) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex48 = verify do + labeled "Compare two clocks for equality, clocks with negative minute that wraps" do + expected = true + actual = equal (+4, +10) (+5, -1490) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex49 = verify do + labeled "Compare two clocks for equality, clocks with negative minute that wraps multiple times" do + expected = true + actual = equal (+6, +15) (+6, -4305) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex50 = verify do + labeled "Compare two clocks for equality, clocks with negative hours and minutes" do + expected = true + actual = equal (+7, +32) (-12, -268) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex51 = verify do + labeled "Compare two clocks for equality, clocks with negative hours and minutes that wrap" do + expected = true + actual = equal (+18, +7) (-54, -11513) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +clock.test.ex52 = verify do + labeled "Compare two clocks for equality, full clock and zeroed clock" do + expected = true + actual = equal (+24, +0) (+0, +0) + label "expected" expected + label "actual" actual + ensureEqual expected actual + +test> clock.tests = join [ clock.test.ex1, clock.test.ex2, clock.test.ex3, diff --git a/exercises/practice/collatz-conjecture/.meta/testAnnotation.json b/exercises/practice/collatz-conjecture/.meta/testAnnotation.json index f8a945e..fba208e 100644 --- a/exercises/practice/collatz-conjecture/.meta/testAnnotation.json +++ b/exercises/practice/collatz-conjecture/.meta/testAnnotation.json @@ -1,22 +1,22 @@ [ { "name": "zero steps for one", - "test_code": "let\n Test.label.deprecated \"zero steps for one\" <| Test.expect (steps 1 === Some 0)" + "test_code": "verify do\n labeled \"zero steps for one\" do\n expected = Some 0\n actual = steps 1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "divide if even", - "test_code": "let\n Test.label.deprecated \"divide if even\" <| Test.expect (steps 16 === Some 4)" + "test_code": "verify do\n labeled \"divide if even\" do\n expected = Some 4\n actual = steps 16\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "even and odd steps", - "test_code": "let\n Test.label.deprecated \"even and odd steps\" <| Test.expect (steps 12 === Some 9)" + "test_code": "verify do\n labeled \"even and odd steps\" do\n expected = Some 9\n actual = steps 12\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "large number of even and odd steps", - "test_code": "let\n Test.label.deprecated \"large number of even and odd steps\" <| Test.expect (steps 1000000 === Some 152)" + "test_code": "verify do\n labeled \"large number of even and odd steps\" do\n expected = Some 152\n actual = steps 1000000\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "zero is an error", - "test_code": "let\n Test.label.deprecated \"zero is an error\" <| Test.expect (steps 0 === None)" + "test_code": "verify do\n labeled \"zero is an error\" do\n expected = None\n actual = steps 0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/collatz-conjecture/collatz.test.u b/exercises/practice/collatz-conjecture/collatz.test.u index 3e0388a..5a0e459 100644 --- a/exercises/practice/collatz-conjecture/collatz.test.u +++ b/exercises/practice/collatz-conjecture/collatz.test.u @@ -1,19 +1,44 @@ -collatzConjecture.test.ex1 = let - Test.label.deprecated "zero steps for one" <| Test.expect (steps 1 === Some 0) +collatzConjecture.test.ex1 = verify do + labeled "zero steps for one" do + expected = Some 0 + actual = steps 1 + label "expected" expected + label "actual" actual + ensureEqual expected actual -collatzConjecture.test.ex2 = let - Test.label.deprecated "divide if even" <| Test.expect (steps 16 === Some 4) +collatzConjecture.test.ex2 = verify do + labeled "divide if even" do + expected = Some 4 + actual = steps 16 + label "expected" expected + label "actual" actual + ensureEqual expected actual -collatzConjecture.test.ex3 = let - Test.label.deprecated "even and odd steps" <| Test.expect (steps 12 === Some 9) +collatzConjecture.test.ex3 = verify do + labeled "even and odd steps" do + expected = Some 9 + actual = steps 12 + label "expected" expected + label "actual" actual + ensureEqual expected actual -collatzConjecture.test.ex4 = let - Test.label.deprecated "large number of even and odd steps" <| Test.expect (steps 1000000 === Some 152) +collatzConjecture.test.ex4 = verify do + labeled "large number of even and odd steps" do + expected = Some 152 + actual = steps 1000000 + label "expected" expected + label "actual" actual + ensureEqual expected actual -collatzConjecture.test.ex5 = let - Test.label.deprecated "zero is an error" <| Test.expect (steps 0 === None) +collatzConjecture.test.ex5 = verify do + labeled "zero is an error" do + expected = None + actual = steps 0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -test> collatzConjecture.tests = runAll [ +test> collatzConjecture.tests = join [ collatzConjecture.test.ex1, collatzConjecture.test.ex2, collatzConjecture.test.ex3, diff --git a/exercises/practice/crypto-square/.meta/testAnnotation.json b/exercises/practice/crypto-square/.meta/testAnnotation.json index 0f1bd20..0f4a922 100644 --- a/exercises/practice/crypto-square/.meta/testAnnotation.json +++ b/exercises/practice/crypto-square/.meta/testAnnotation.json @@ -1,30 +1,30 @@ [ { "name": "empty plaintext results in an empty ciphertext", - "test_code": "let\n Test.label.deprecated \"empty plaintext results in an empty ciphertext\" <| Test.expect (ciphertext \"\" === \"\")" + "test_code": "verify do\n labeled \"empty plaintext results in an empty ciphertext\" do\n expected = \"\"\n actual = ciphertext \"\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Lowercase", - "test_code": "let\n Test.label.deprecated \"Lowercase\" <| Test.expect (ciphertext \"A\" === \"a\")" + "test_code": "verify do\n labeled \"Lowercase\" do\n expected = \"a\"\n actual = ciphertext \"A\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Remove spaces", - "test_code": "let\n Test.label.deprecated \"Remove spaces\" <| Test.expect (ciphertext \" b \" === \"b\")" + "test_code": "verify do\n labeled \"Remove spaces\" do\n expected = \"b\"\n actual = ciphertext \" b \"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Remove punctuation", - "test_code": "let\n Test.label.deprecated \"Remove punctuation\" <| Test.expect (ciphertext \"@1,%!\" === \"1\")" + "test_code": "verify do\n labeled \"Remove punctuation\" do\n expected = \"1\"\n actual = ciphertext \"@1,%!\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "9 character plaintext results in 3 chunks of 3 characters", - "test_code": "let\n Test.label.deprecated \"9 character plaintext results in 3 chunks of 3 characters\" <| Test.expect (ciphertext \"This is fun!\" === \"tsf hiu isn\")" + "test_code": "verify do\n labeled \"9 character plaintext results in 3 chunks of 3 characters\" do\n expected = \"tsf hiu isn\"\n actual = ciphertext \"This is fun!\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "8 character plaintext results in 3 chunks, the last one with a trailing space", - "test_code": "let\n Test.label.deprecated \"8 character plaintext results in 3 chunks, the last one with a trailing space\" <| Test.expect (ciphertext \"Chill out.\" === \"clu hlt io \")" + "test_code": "verify do\n labeled \"8 character plaintext results in 3 chunks, the last one with a trailing space\" do\n expected = \"clu hlt io \"\n actual = ciphertext \"Chill out.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "54 character plaintext results in 7 chunks, the last two with trailing spaces", - "test_code": "let\n Test.label.deprecated \"54 character plaintext results in 7 chunks, the last two with trailing spaces\" <| Test.expect (ciphertext \"If man was meant to stay on the ground, god would have given us roots.\" === \"imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau \")" + "test_code": "verify do\n labeled \"54 character plaintext results in 7 chunks, the last two with trailing spaces\" do\n expected = \"imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau \"\n actual = ciphertext \"If man was meant to stay on the ground, god would have given us roots.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/crypto-square/crypto.test.u b/exercises/practice/crypto-square/crypto.test.u index fd5b3d8..5acd01a 100644 --- a/exercises/practice/crypto-square/crypto.test.u +++ b/exercises/practice/crypto-square/crypto.test.u @@ -1,25 +1,60 @@ -cryptoSquare.test.ex1 = let - Test.label.deprecated "empty plaintext results in an empty ciphertext" <| Test.expect (ciphertext "" === "") +cryptoSquare.test.ex1 = verify do + labeled "empty plaintext results in an empty ciphertext" do + expected = "" + actual = ciphertext "" + label "expected" expected + label "actual" actual + ensureEqual expected actual -cryptoSquare.test.ex2 = let - Test.label.deprecated "Lowercase" <| Test.expect (ciphertext "A" === "a") +cryptoSquare.test.ex2 = verify do + labeled "Lowercase" do + expected = "a" + actual = ciphertext "A" + label "expected" expected + label "actual" actual + ensureEqual expected actual -cryptoSquare.test.ex3 = let - Test.label.deprecated "Remove spaces" <| Test.expect (ciphertext " b " === "b") +cryptoSquare.test.ex3 = verify do + labeled "Remove spaces" do + expected = "b" + actual = ciphertext " b " + label "expected" expected + label "actual" actual + ensureEqual expected actual -cryptoSquare.test.ex4 = let - Test.label.deprecated "Remove punctuation" <| Test.expect (ciphertext "@1,%!" === "1") +cryptoSquare.test.ex4 = verify do + labeled "Remove punctuation" do + expected = "1" + actual = ciphertext "@1,%!" + label "expected" expected + label "actual" actual + ensureEqual expected actual -cryptoSquare.test.ex5 = let - Test.label.deprecated "9 character plaintext results in 3 chunks of 3 characters" <| Test.expect (ciphertext "This is fun!" === "tsf hiu isn") +cryptoSquare.test.ex5 = verify do + labeled "9 character plaintext results in 3 chunks of 3 characters" do + expected = "tsf hiu isn" + actual = ciphertext "This is fun!" + label "expected" expected + label "actual" actual + ensureEqual expected actual -cryptoSquare.test.ex6 = let - Test.label.deprecated "8 character plaintext results in 3 chunks, the last one with a trailing space" <| Test.expect (ciphertext "Chill out." === "clu hlt io ") +cryptoSquare.test.ex6 = verify do + labeled "8 character plaintext results in 3 chunks, the last one with a trailing space" do + expected = "clu hlt io " + actual = ciphertext "Chill out." + label "expected" expected + label "actual" actual + ensureEqual expected actual -cryptoSquare.test.ex7 = let - Test.label.deprecated "54 character plaintext results in 7 chunks, the last two with trailing spaces" <| Test.expect (ciphertext "If man was meant to stay on the ground, god would have given us roots." === "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ") +cryptoSquare.test.ex7 = verify do + labeled "54 character plaintext results in 7 chunks, the last two with trailing spaces" do + expected = "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau " + actual = ciphertext "If man was meant to stay on the ground, god would have given us roots." + label "expected" expected + label "actual" actual + ensureEqual expected actual -test> cryptoSquare.tests = runAll [ +test> cryptoSquare.tests = join [ cryptoSquare.test.ex1, cryptoSquare.test.ex2, cryptoSquare.test.ex3, diff --git a/exercises/practice/darts/.meta/testAnnotation.json b/exercises/practice/darts/.meta/testAnnotation.json index ef9edf3..3ddc05e 100644 --- a/exercises/practice/darts/.meta/testAnnotation.json +++ b/exercises/practice/darts/.meta/testAnnotation.json @@ -1,54 +1,54 @@ [ { "name": "Missed target", - "test_code": "let\n Test.label.deprecated \"Missed target\" <| Test.expect (score -9.0 9.0 === 0)" + "test_code": "verify do\n labeled \"Missed target\" do\n expected = 0\n actual = score -9.0 9.0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "On the outer circle", - "test_code": "let\n Test.label.deprecated \"On the outer circle\" <| Test.expect (score 0.0 10.0 === 1)" + "test_code": "verify do\n labeled \"On the outer circle\" do\n expected = 1\n actual = score 0.0 10.0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "On the middle circle", - "test_code": "let\n Test.label.deprecated \"On the middle circle\" <| Test.expect (score -5.0 0.0 === 5)" + "test_code": "verify do\n labeled \"On the middle circle\" do\n expected = 5\n actual = score -5.0 0.0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "On the inner circle", - "test_code": "let\n Test.label.deprecated \"On the inner circle\" <| Test.expect (score 0.0 -1.0 === 10)" + "test_code": "verify do\n labeled \"On the inner circle\" do\n expected = 10\n actual = score 0.0 -1.0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Exactly on centre", - "test_code": "let\n Test.label.deprecated \"Exactly on centre\" <| Test.expect (score 0.0 0.0 === 10)" + "test_code": "verify do\n labeled \"Exactly on centre\" do\n expected = 10\n actual = score 0.0 0.0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Near the centre", - "test_code": "let\n Test.label.deprecated \"Near the centre\" <| Test.expect (score -0.1 -0.1 === 10)" + "test_code": "verify do\n labeled \"Near the centre\" do\n expected = 10\n actual = score -0.1 -0.1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Just within the inner circle", - "test_code": "let\n Test.label.deprecated \"Just within the inner circle\" <| Test.expect (score 0.7 0.7 === 10)" + "test_code": "verify do\n labeled \"Just within the inner circle\" do\n expected = 10\n actual = score 0.7 0.7\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Just outside the inner circle", - "test_code": "let\n Test.label.deprecated \"Just outside the inner circle\" <| Test.expect (score 0.8 -0.8 === 5)" + "test_code": "verify do\n labeled \"Just outside the inner circle\" do\n expected = 5\n actual = score 0.8 -0.8\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Just within the middle circle", - "test_code": "let\n Test.label.deprecated \"Just within the middle circle\" <| Test.expect (score -3.5 3.5 === 5)" + "test_code": "verify do\n labeled \"Just within the middle circle\" do\n expected = 5\n actual = score -3.5 3.5\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Just outside the middle circle", - "test_code": "let\n Test.label.deprecated \"Just outside the middle circle\" <| Test.expect (score -3.6 -3.6 === 1)" + "test_code": "verify do\n labeled \"Just outside the middle circle\" do\n expected = 1\n actual = score -3.6 -3.6\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Just within the outer circle", - "test_code": "let\n Test.label.deprecated \"Just within the outer circle\" <| Test.expect (score -7.0 7.0 === 1)" + "test_code": "verify do\n labeled \"Just within the outer circle\" do\n expected = 1\n actual = score -7.0 7.0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Just outside the outer circle", - "test_code": "let\n Test.label.deprecated \"Just outside the outer circle\" <| Test.expect (score 7.1 -7.1 === 0)" + "test_code": "verify do\n labeled \"Just outside the outer circle\" do\n expected = 0\n actual = score 7.1 -7.1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Asymmetric position between the inner and middle circles", - "test_code": "let\n Test.label.deprecated \"Asymmetric position between the inner and middle circles\" <| Test.expect (score 0.5 -4.0 === 5)" + "test_code": "verify do\n labeled \"Asymmetric position between the inner and middle circles\" do\n expected = 5\n actual = score 0.5 -4.0\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/darts/darts.test.u b/exercises/practice/darts/darts.test.u index aa0d0d9..27c410c 100644 --- a/exercises/practice/darts/darts.test.u +++ b/exercises/practice/darts/darts.test.u @@ -1,43 +1,108 @@ -darts.test.ex1 = let - Test.label.deprecated "Missed target" <| Test.expect (score -9.0 9.0 === 0) +darts.test.ex1 = verify do + labeled "Missed target" do + expected = 0 + actual = score -9.0 9.0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex2 = let - Test.label.deprecated "On the outer circle" <| Test.expect (score 0.0 10.0 === 1) +darts.test.ex2 = verify do + labeled "On the outer circle" do + expected = 1 + actual = score 0.0 10.0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex3 = let - Test.label.deprecated "On the middle circle" <| Test.expect (score -5.0 0.0 === 5) +darts.test.ex3 = verify do + labeled "On the middle circle" do + expected = 5 + actual = score -5.0 0.0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex4 = let - Test.label.deprecated "On the inner circle" <| Test.expect (score 0.0 -1.0 === 10) +darts.test.ex4 = verify do + labeled "On the inner circle" do + expected = 10 + actual = score 0.0 -1.0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex5 = let - Test.label.deprecated "Exactly on centre" <| Test.expect (score 0.0 0.0 === 10) +darts.test.ex5 = verify do + labeled "Exactly on centre" do + expected = 10 + actual = score 0.0 0.0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex6 = let - Test.label.deprecated "Near the centre" <| Test.expect (score -0.1 -0.1 === 10) +darts.test.ex6 = verify do + labeled "Near the centre" do + expected = 10 + actual = score -0.1 -0.1 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex7 = let - Test.label.deprecated "Just within the inner circle" <| Test.expect (score 0.7 0.7 === 10) +darts.test.ex7 = verify do + labeled "Just within the inner circle" do + expected = 10 + actual = score 0.7 0.7 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex8 = let - Test.label.deprecated "Just outside the inner circle" <| Test.expect (score 0.8 -0.8 === 5) +darts.test.ex8 = verify do + labeled "Just outside the inner circle" do + expected = 5 + actual = score 0.8 -0.8 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex9 = let - Test.label.deprecated "Just within the middle circle" <| Test.expect (score -3.5 3.5 === 5) +darts.test.ex9 = verify do + labeled "Just within the middle circle" do + expected = 5 + actual = score -3.5 3.5 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex10 = let - Test.label.deprecated "Just outside the middle circle" <| Test.expect (score -3.6 -3.6 === 1) +darts.test.ex10 = verify do + labeled "Just outside the middle circle" do + expected = 1 + actual = score -3.6 -3.6 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex11 = let - Test.label.deprecated "Just within the outer circle" <| Test.expect (score -7.0 7.0 === 1) +darts.test.ex11 = verify do + labeled "Just within the outer circle" do + expected = 1 + actual = score -7.0 7.0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex12 = let - Test.label.deprecated "Just outside the outer circle" <| Test.expect (score 7.1 -7.1 === 0) +darts.test.ex12 = verify do + labeled "Just outside the outer circle" do + expected = 0 + actual = score 7.1 -7.1 + label "expected" expected + label "actual" actual + ensureEqual expected actual -darts.test.ex13 = let - Test.label.deprecated "Asymmetric position between the inner and middle circles" <| Test.expect (score 0.5 -4.0 === 5) +darts.test.ex13 = verify do + labeled "Asymmetric position between the inner and middle circles" do + expected = 5 + actual = score 0.5 -4.0 + label "expected" expected + label "actual" actual + ensureEqual expected actual -test> darts.tests = runAll [ +test> darts.tests = join [ darts.test.ex1, darts.test.ex2, darts.test.ex3, diff --git a/exercises/practice/diamond/.meta/testAnnotation.json b/exercises/practice/diamond/.meta/testAnnotation.json index 50d52d4..0fc43db 100644 --- a/exercises/practice/diamond/.meta/testAnnotation.json +++ b/exercises/practice/diamond/.meta/testAnnotation.json @@ -1,22 +1,22 @@ [ { "name": "Degenerate case with a single 'A' row", - "test_code": "let\n Test.label.deprecated \"Degenerate case with a single 'A' row\" <| Test.expect (rows ?A === [\"A\"])" + "test_code": "verify do\n labeled \"Degenerate case with a single 'A' row\" do\n expected = [\"A\"]\n actual = rows ?A\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Degenerate case with no row containing 3 distinct groups of spaces", - "test_code": "let\n Test.label.deprecated \"Degenerate case with no row containing 3 distinct groups of spaces\" <| Test.expect (rows ?B === [\" A \",\"B B\",\" A \"])" + "test_code": "verify do\n labeled \"Degenerate case with no row containing 3 distinct groups of spaces\" do\n expected = [\" A \",\"B B\",\" A \"]\n actual = rows ?B\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Smallest non-degenerate case with odd diamond side length", - "test_code": "let\n Test.label.deprecated \"Smallest non-degenerate case with odd diamond side length\" <| Test.expect (rows ?C === [\" A \",\" B B \",\"C C\",\" B B \",\" A \"])" + "test_code": "verify do\n labeled \"Smallest non-degenerate case with odd diamond side length\" do\n expected = [\" A \",\" B B \",\"C C\",\" B B \",\" A \"]\n actual = rows ?C\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Smallest non-degenerate case with even diamond side length", - "test_code": "let\n Test.label.deprecated \"Smallest non-degenerate case with even diamond side length\" <| Test.expect (rows ?D === [\" A \",\" B B \",\" C C \",\"D D\",\" C C \",\" B B \",\" A \"])" + "test_code": "verify do\n labeled \"Smallest non-degenerate case with even diamond side length\" do\n expected = [\" A \",\" B B \",\" C C \",\"D D\",\" C C \",\" B B \",\" A \"]\n actual = rows ?D\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Largest possible diamond", - "test_code": "let\n Test.label.deprecated \"Largest possible diamond\" <| Test.expect (rows ?Z === [\" A \",\" B B \",\" C C \",\" D D \",\" E E \",\" F F \",\" G G \",\" H H \",\" I I \",\" J J \",\" K K \",\" L L \",\" M M \",\" N N \",\" O O \",\" P P \",\" Q Q \",\" R R \",\" S S \",\" T T \",\" U U \",\" V V \",\" W W \",\" X X \",\" Y Y \",\"Z Z\",\" Y Y \",\" X X \",\" W W \",\" V V \",\" U U \",\" T T \",\" S S \",\" R R \",\" Q Q \",\" P P \",\" O O \",\" N N \",\" M M \",\" L L \",\" K K \",\" J J \",\" I I \",\" H H \",\" G G \",\" F F \",\" E E \",\" D D \",\" C C \",\" B B \",\" A \"])" + "test_code": "verify do\n labeled \"Largest possible diamond\" do\n expected = [\" A \",\" B B \",\" C C \",\" D D \",\" E E \",\" F F \",\" G G \",\" H H \",\" I I \",\" J J \",\" K K \",\" L L \",\" M M \",\" N N \",\" O O \",\" P P \",\" Q Q \",\" R R \",\" S S \",\" T T \",\" U U \",\" V V \",\" W W \",\" X X \",\" Y Y \",\"Z Z\",\" Y Y \",\" X X \",\" W W \",\" V V \",\" U U \",\" T T \",\" S S \",\" R R \",\" Q Q \",\" P P \",\" O O \",\" N N \",\" M M \",\" L L \",\" K K \",\" J J \",\" I I \",\" H H \",\" G G \",\" F F \",\" E E \",\" D D \",\" C C \",\" B B \",\" A \"]\n actual = rows ?Z\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/diamond/diamond.test.u b/exercises/practice/diamond/diamond.test.u index 74fb487..95e2d8a 100644 --- a/exercises/practice/diamond/diamond.test.u +++ b/exercises/practice/diamond/diamond.test.u @@ -1,19 +1,44 @@ -diamond.test.ex1 = let - Test.label.deprecated "Degenerate case with a single 'A' row" <| Test.expect (rows ?A === ["A"]) +diamond.test.ex1 = verify do + labeled "Degenerate case with a single 'A' row" do + expected = ["A"] + actual = rows ?A + label "expected" expected + label "actual" actual + ensureEqual expected actual -diamond.test.ex2 = let - Test.label.deprecated "Degenerate case with no row containing 3 distinct groups of spaces" <| Test.expect (rows ?B === [" A ","B B"," A "]) +diamond.test.ex2 = verify do + labeled "Degenerate case with no row containing 3 distinct groups of spaces" do + expected = [" A ","B B"," A "] + actual = rows ?B + label "expected" expected + label "actual" actual + ensureEqual expected actual -diamond.test.ex3 = let - Test.label.deprecated "Smallest non-degenerate case with odd diamond side length" <| Test.expect (rows ?C === [" A "," B B ","C C"," B B "," A "]) +diamond.test.ex3 = verify do + labeled "Smallest non-degenerate case with odd diamond side length" do + expected = [" A "," B B ","C C"," B B "," A "] + actual = rows ?C + label "expected" expected + label "actual" actual + ensureEqual expected actual -diamond.test.ex4 = let - Test.label.deprecated "Smallest non-degenerate case with even diamond side length" <| Test.expect (rows ?D === [" A "," B B "," C C ","D D"," C C "," B B "," A "]) +diamond.test.ex4 = verify do + labeled "Smallest non-degenerate case with even diamond side length" do + expected = [" A "," B B "," C C ","D D"," C C "," B B "," A "] + actual = rows ?D + label "expected" expected + label "actual" actual + ensureEqual expected actual -diamond.test.ex5 = let - Test.label.deprecated "Largest possible diamond" <| Test.expect (rows ?Z === [" A "," B B "," C C "," D D "," E E "," F F "," G G "," H H "," I I "," J J "," K K "," L L "," M M "," N N "," O O "," P P "," Q Q "," R R "," S S "," T T "," U U "," V V "," W W "," X X "," Y Y ","Z Z"," Y Y "," X X "," W W "," V V "," U U "," T T "," S S "," R R "," Q Q "," P P "," O O "," N N "," M M "," L L "," K K "," J J "," I I "," H H "," G G "," F F "," E E "," D D "," C C "," B B "," A "]) +diamond.test.ex5 = verify do + labeled "Largest possible diamond" do + expected = [" A "," B B "," C C "," D D "," E E "," F F "," G G "," H H "," I I "," J J "," K K "," L L "," M M "," N N "," O O "," P P "," Q Q "," R R "," S S "," T T "," U U "," V V "," W W "," X X "," Y Y ","Z Z"," Y Y "," X X "," W W "," V V "," U U "," T T "," S S "," R R "," Q Q "," P P "," O O "," N N "," M M "," L L "," K K "," J J "," I I "," H H "," G G "," F F "," E E "," D D "," C C "," B B "," A "] + actual = rows ?Z + label "expected" expected + label "actual" actual + ensureEqual expected actual -test> diamond.tests = runAll [ +test> diamond.tests = join [ diamond.test.ex1, diamond.test.ex2, diamond.test.ex3, diff --git a/exercises/practice/difference-of-squares/.meta/testAnnotation.json b/exercises/practice/difference-of-squares/.meta/testAnnotation.json index 57d13b4..b2b0926 100644 --- a/exercises/practice/difference-of-squares/.meta/testAnnotation.json +++ b/exercises/practice/difference-of-squares/.meta/testAnnotation.json @@ -1,38 +1,38 @@ [ { "name": "Square of sum 1", - "test_code": "let\n Test.label.deprecated \"Square of sum 1\" <| Test.expect (squareOfSum 1 === 1)" + "test_code": "verify do\n labeled \"Square of sum 1\" do\n expected = 1\n actual = squareOfSum 1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Square of sum 5", - "test_code": "let\n Test.label.deprecated \"Square of sum 5\" <| Test.expect (squareOfSum 5 === 225)" + "test_code": "verify do\n labeled \"Square of sum 5\" do\n expected = 225\n actual = squareOfSum 5\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Square of sum 100", - "test_code": "let\n Test.label.deprecated \"Square of sum 100\" <| Test.expect (squareOfSum 100 === 25502500)" + "test_code": "verify do\n labeled \"Square of sum 100\" do\n expected = 25502500\n actual = squareOfSum 100\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Sum of squares 1", - "test_code": "let\n Test.label.deprecated \"Sum of squares 1\" <| Test.expect (sumOfSquares 1 === 1)" + "test_code": "verify do\n labeled \"Sum of squares 1\" do\n expected = 1\n actual = sumOfSquares 1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Sum of squares 5", - "test_code": "let\n Test.label.deprecated \"Sum of squares 5\" <| Test.expect (sumOfSquares 5 === 55)" + "test_code": "verify do\n labeled \"Sum of squares 5\" do\n expected = 55\n actual = sumOfSquares 5\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Sum of squares 100", - "test_code": "let\n Test.label.deprecated \"Sum of squares 100\" <| Test.expect (sumOfSquares 100 === 338350)" + "test_code": "verify do\n labeled \"Sum of squares 100\" do\n expected = 338350\n actual = sumOfSquares 100\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Difference of squares 1", - "test_code": "let\n Test.label.deprecated \"Difference of squares 1\" <| Test.expect (difference 1 === 0)" + "test_code": "verify do\n labeled \"Difference of squares 1\" do\n expected = 0\n actual = difference 1\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Difference of squares 5", - "test_code": "let\n Test.label.deprecated \"Difference of squares 5\" <| Test.expect (difference 5 === 170)" + "test_code": "verify do\n labeled \"Difference of squares 5\" do\n expected = 170\n actual = difference 5\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Difference of squares 100", - "test_code": "let\n Test.label.deprecated \"Difference of squares 100\" <| Test.expect (difference 100 === 25164150)" + "test_code": "verify do\n labeled \"Difference of squares 100\" do\n expected = 25164150\n actual = difference 100\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/practice/difference-of-squares/differenceOfSquares.test.u b/exercises/practice/difference-of-squares/differenceOfSquares.test.u index 92ec970..8e840e1 100644 --- a/exercises/practice/difference-of-squares/differenceOfSquares.test.u +++ b/exercises/practice/difference-of-squares/differenceOfSquares.test.u @@ -1,31 +1,76 @@ -differenceOfSquares.test.ex1 = let - Test.label.deprecated "Square of sum 1" <| Test.expect (squareOfSum 1 === 1) +differenceOfSquares.test.ex1 = verify do + labeled "Square of sum 1" do + expected = 1 + actual = squareOfSum 1 + label "expected" expected + label "actual" actual + ensureEqual expected actual -differenceOfSquares.test.ex2 = let - Test.label.deprecated "Square of sum 5" <| Test.expect (squareOfSum 5 === 225) +differenceOfSquares.test.ex2 = verify do + labeled "Square of sum 5" do + expected = 225 + actual = squareOfSum 5 + label "expected" expected + label "actual" actual + ensureEqual expected actual -differenceOfSquares.test.ex3 = let - Test.label.deprecated "Square of sum 100" <| Test.expect (squareOfSum 100 === 25502500) +differenceOfSquares.test.ex3 = verify do + labeled "Square of sum 100" do + expected = 25502500 + actual = squareOfSum 100 + label "expected" expected + label "actual" actual + ensureEqual expected actual -differenceOfSquares.test.ex4 = let - Test.label.deprecated "Sum of squares 1" <| Test.expect (sumOfSquares 1 === 1) +differenceOfSquares.test.ex4 = verify do + labeled "Sum of squares 1" do + expected = 1 + actual = sumOfSquares 1 + label "expected" expected + label "actual" actual + ensureEqual expected actual -differenceOfSquares.test.ex5 = let - Test.label.deprecated "Sum of squares 5" <| Test.expect (sumOfSquares 5 === 55) +differenceOfSquares.test.ex5 = verify do + labeled "Sum of squares 5" do + expected = 55 + actual = sumOfSquares 5 + label "expected" expected + label "actual" actual + ensureEqual expected actual -differenceOfSquares.test.ex6 = let - Test.label.deprecated "Sum of squares 100" <| Test.expect (sumOfSquares 100 === 338350) +differenceOfSquares.test.ex6 = verify do + labeled "Sum of squares 100" do + expected = 338350 + actual = sumOfSquares 100 + label "expected" expected + label "actual" actual + ensureEqual expected actual -differenceOfSquares.test.ex7 = let - Test.label.deprecated "Difference of squares 1" <| Test.expect (difference 1 === 0) +differenceOfSquares.test.ex7 = verify do + labeled "Difference of squares 1" do + expected = 0 + actual = difference 1 + label "expected" expected + label "actual" actual + ensureEqual expected actual -differenceOfSquares.test.ex8 = let - Test.label.deprecated "Difference of squares 5" <| Test.expect (difference 5 === 170) +differenceOfSquares.test.ex8 = verify do + labeled "Difference of squares 5" do + expected = 170 + actual = difference 5 + label "expected" expected + label "actual" actual + ensureEqual expected actual -differenceOfSquares.test.ex9 = let - Test.label.deprecated "Difference of squares 100" <| Test.expect (difference 100 === 25164150) +differenceOfSquares.test.ex9 = verify do + labeled "Difference of squares 100" do + expected = 25164150 + actual = difference 100 + label "expected" expected + label "actual" actual + ensureEqual expected actual -test> differenceOfSquares.tests = runAll [ +test> differenceOfSquares.tests = join [ differenceOfSquares.test.ex1, differenceOfSquares.test.ex2, differenceOfSquares.test.ex3, @@ -35,4 +80,4 @@ test> differenceOfSquares.tests = runAll [ differenceOfSquares.test.ex7, differenceOfSquares.test.ex8, differenceOfSquares.test.ex9 -] \ No newline at end of file +] diff --git a/exercises/practice/dnd-character/.meta/testAnnotation.json b/exercises/practice/dnd-character/.meta/testAnnotation.json index ad9d5a5..44f6fbc 100644 --- a/exercises/practice/dnd-character/.meta/testAnnotation.json +++ b/exercises/practice/dnd-character/.meta/testAnnotation.json @@ -1,74 +1,74 @@ [ { "name": "computes the modifier for 18 to be 4", - "test_code": "input = 18\n expected = +4\n Test.label.deprecated \"computes the modifier for 18 to be 4\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 18 to be 4\" do\n expected = +4\n actual = modifier 18\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 17 to be 3", - "test_code": "input = 17\n expected = +3\n Test.label.deprecated \"computes the modifier for 17 to be 3\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 17 to be 3\" do\n expected = +3\n actual = modifier 17\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 16 to be 3", - "test_code": "input = 16\n expected = +3\n Test.label.deprecated \"computes the modifier for 16 to be 3\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 16 to be 3\" do\n expected = +3\n actual = modifier 16\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 15 to be 2", - "test_code": "input = 15\n expected = +2\n Test.label.deprecated \"computes the modifier for 15 to be 2\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 15 to be 2\" do\n expected = +2\n actual = modifier 15\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 14 to be 2", - "test_code": "input = 14\n expected = +2\n Test.label.deprecated \"computes the modifier for 14 to be 2\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 14 to be 2\" do\n expected = +2\n actual = modifier 14\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 13 to be 1", - "test_code": "input = 13\n expected = +1\n Test.label.deprecated \"computes the modifier for 13 to be 1\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 13 to be 1\" do\n expected = +1\n actual = modifier 13\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 12 to be 1", - "test_code": "input = 12\n expected = +1\n Test.label.deprecated \"computes the modifier for 12 to be 1\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 12 to be 1\" do\n expected = +1\n actual = modifier 12\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 11 to be 0", - "test_code": "input = 11\n expected = +0\n Test.label.deprecated \"computes the modifier for 11 to be 0\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 11 to be 0\" do\n expected = +0\n actual = modifier 11\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 10 to be 0", - "test_code": "input = 10\n expected = +0\n Test.label.deprecated \"computes the modifier for 10 to be 0\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 10 to be 0\" do\n expected = +0\n actual = modifier 10\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 9 to be -1", - "test_code": "input = 9\n expected = -1\n Test.label.deprecated \"computes the modifier for 9 to be -1\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 9 to be -1\" do\n expected = -1\n actual = modifier 9\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 8 to be -1", - "test_code": "input = 8\n expected = -1\n Test.label.deprecated \"computes the modifier for 8 to be -1\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 8 to be -1\" do\n expected = -1\n actual = modifier 8\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 7 to be -2", - "test_code": "input = 7\n expected = -2\n Test.label.deprecated \"computes the modifier for 7 to be -2\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 7 to be -2\" do\n expected = -2\n actual = modifier 7\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 6 to be -2", - "test_code": "input = 6\n expected = -2\n Test.label.deprecated \"computes the modifier for 6 to be -2\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 6 to be -2\" do\n expected = -2\n actual = modifier 6\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 5 to be -3", - "test_code": "input = 5\n expected = -3\n Test.label.deprecated \"computes the modifier for 5 to be -3\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 5 to be -3\" do\n expected = -3\n actual = modifier 5\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 4 to be -3", - "test_code": "input = 4\n expected = -3\n Test.label.deprecated \"computes the modifier for 4 to be -3\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 4 to be -3\" do\n expected = -3\n actual = modifier 4\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "computes the modifier for 3 to be -4", - "test_code": "input = 3\n expected = -4\n Test.label.deprecated \"computes the modifier for 3 to be -4\" <| expect (expected == modifier input)" + "test_code": "verify do\n labeled \"computes the modifier for 3 to be -4\" do\n expected = -4\n actual = modifier 3\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "generates value within range", - "test_code": "do\n use test.deprecated.gen nat\n seed = !nat\n calculatedAbility = Random.lcg seed ability_\n Test.label.deprecated \"generates value within range\" <| expect (Nat.inRange 3 19 calculatedAbility)" + "test_code": "verify do\n labeled \"generates value within range\" do\n Each.repeat 10\n calculatedAbility = !ability_\n label \"calculated ability\" calculatedAbility\n ensure (Nat.inRange 3 19 calculatedAbility)" }, { "name": "generates valid character", - "test_code": "do\n use test.deprecated.gen nat\n seed = !nat\n (Character strength dexterity constitution intelligence wisdom charisma hitpoints) = Random.lcg seed character\n expectedHitpoints = Int.abs (+10 Int.+ modifier constitution)\n expect ((Nat.inRange 3 19 strength) && (Nat.inRange 3 19 dexterity) && (Nat.inRange 3 19 constitution) && (Nat.inRange 3 19 intelligence) && (Nat.inRange 3 19 wisdom) && (Nat.inRange 3 19 charisma) && (hitpoints == expectedHitpoints)\n ) |> Test.label.deprecated \"generates valid character\"" + "test_code": "verify do\n generateErrorMessage attributeName value =\n use Nat toText\n attributeName ++\n \" has the wrong value. Generated value: \" ++\n toText value\n labeled \"generates valid character\" do\n Each.repeat 10\n (Character strength dexterity constitution intelligence wisdom charisma hitpoints) = !character\n expectedHitpoints = Int.abs (+10 Int.+ modifier constitution)\n ensureWith (generateErrorMessage \"Strength\" strength) (Nat.inRange 3 19 strength)\n ensureWith (generateErrorMessage \"Dexterity\" dexterity) (Nat.inRange 3 19 dexterity)\n ensureWith (generateErrorMessage \"Constitution\" constitution) (Nat.inRange 3 19 constitution)\n ensureWith (generateErrorMessage \"Intelligence\" intelligence) (Nat.inRange 3 19 intelligence)\n ensureWith (generateErrorMessage \"Wisdom\" wisdom) (Nat.inRange 3 19 wisdom)\n ensureWith (generateErrorMessage \"Charisma\" charisma) (Nat.inRange 3 19 charisma)\n ensureWith (generateErrorMessage \"Hitpoints\" hitpoints) (hitpoints == expectedHitpoints)" } ] \ No newline at end of file diff --git a/exercises/practice/dnd-character/dndCharacter.test.u b/exercises/practice/dnd-character/dndCharacter.test.u index 4b45992..12ddcd3 100644 --- a/exercises/practice/dnd-character/dndCharacter.test.u +++ b/exercises/practice/dnd-character/dndCharacter.test.u @@ -1,117 +1,173 @@ -use base.test.gen - -dndCharacter.test.testModifier.ex1 = - input = 18 - expected = +4 - Test.label.deprecated "computes the modifier for 18 to be 4" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex2 = - input = 17 - expected = +3 - Test.label.deprecated "computes the modifier for 17 to be 3" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex3 = - input = 16 - expected = +3 - Test.label.deprecated "computes the modifier for 16 to be 3" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex4 = - input = 15 - expected = +2 - Test.label.deprecated "computes the modifier for 15 to be 2" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex5 = - input = 14 - expected = +2 - Test.label.deprecated "computes the modifier for 14 to be 2" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex6 = - input = 13 - expected = +1 - Test.label.deprecated "computes the modifier for 13 to be 1" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex7 = - input = 12 - expected = +1 - Test.label.deprecated "computes the modifier for 12 to be 1" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex8 = - input = 11 - expected = +0 - Test.label.deprecated "computes the modifier for 11 to be 0" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex9 = - input = 10 - expected = +0 - Test.label.deprecated "computes the modifier for 10 to be 0" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex10 = - input = 9 - expected = -1 - Test.label.deprecated "computes the modifier for 9 to be -1" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex11 = - input = 8 - expected = -1 - Test.label.deprecated "computes the modifier for 8 to be -1" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex12 = - input = 7 - expected = -2 - Test.label.deprecated "computes the modifier for 7 to be -2" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex13 = - input = 6 - expected = -2 - Test.label.deprecated "computes the modifier for 6 to be -2" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex14 = - input = 5 - expected = -3 - Test.label.deprecated "computes the modifier for 5 to be -3" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex15 = - input = 4 - expected = -3 - Test.label.deprecated "computes the modifier for 4 to be -3" <| expect (expected == modifier input) - -dndCharacter.test.testModifier.ex16 = - input = 3 - expected = -4 - Test.label.deprecated "computes the modifier for 3 to be -4" <| expect (expected == modifier input) - - -dndCharacter.test.testAbility = do - use test.deprecated.gen nat - seed = !nat - calculatedAbility = Random.lcg seed ability_ - Test.label.deprecated "generates value within range" <| expect (Nat.inRange 3 19 calculatedAbility) - -dndCharacter.test.testCharacter = do - use test.deprecated.gen nat - seed = !nat - (Character strength dexterity constitution intelligence wisdom charisma hitpoints) = Random.lcg seed character - expectedHitpoints = Int.abs (+10 Int.+ modifier constitution) - expect ((Nat.inRange 3 19 strength) && (Nat.inRange 3 19 dexterity) && (Nat.inRange 3 19 constitution) && (Nat.inRange 3 19 intelligence) && (Nat.inRange 3 19 wisdom) && (Nat.inRange 3 19 charisma) && (hitpoints == expectedHitpoints) - ) |> Test.label.deprecated "generates valid character" +dndCharacter.modifier.test.ex1 = verify do + labeled "computes the modifier for 18 to be 4" do + expected = +4 + actual = modifier 18 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex2 = verify do + labeled "computes the modifier for 17 to be 3" do + expected = +3 + actual = modifier 17 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex3 = verify do + labeled "computes the modifier for 16 to be 3" do + expected = +3 + actual = modifier 16 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex4 = verify do + labeled "computes the modifier for 15 to be 2" do + expected = +2 + actual = modifier 15 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex5 = verify do + labeled "computes the modifier for 14 to be 2" do + expected = +2 + actual = modifier 14 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex6 = verify do + labeled "computes the modifier for 13 to be 1" do + expected = +1 + actual = modifier 13 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex7 = verify do + labeled "computes the modifier for 12 to be 1" do + expected = +1 + actual = modifier 12 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex8 = verify do + labeled "computes the modifier for 11 to be 0" do + expected = +0 + actual = modifier 11 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex9 = verify do + labeled "computes the modifier for 10 to be 0" do + expected = +0 + actual = modifier 10 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex10 = verify do + labeled "computes the modifier for 9 to be -1" do + expected = -1 + actual = modifier 9 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex11 = verify do + labeled "computes the modifier for 8 to be -1" do + expected = -1 + actual = modifier 8 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex12 = verify do + labeled "computes the modifier for 7 to be -2" do + expected = -2 + actual = modifier 7 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex13 = verify do + labeled "computes the modifier for 6 to be -2" do + expected = -2 + actual = modifier 6 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex14 = verify do + labeled "computes the modifier for 5 to be -3" do + expected = -3 + actual = modifier 5 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex15 = verify do + labeled "computes the modifier for 4 to be -3" do + expected = -3 + actual = modifier 4 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.modifier.test.ex16 = verify do + labeled "computes the modifier for 3 to be -4" do + expected = -4 + actual = modifier 3 + label "expected" expected + label "actual" actual + ensureEqual expected actual + +dndCharacter.ability_.test = verify do + labeled "generates value within range" do + Each.repeat 10 + calculatedAbility = !ability_ + label "calculated ability" calculatedAbility + ensure (Nat.inRange 3 19 calculatedAbility) + +dndCharacter.character.test = verify do + generateErrorMessage attributeName value = + use Nat toText + attributeName ++ + " has the wrong value. Generated value: " ++ + toText value + labeled "generates valid character" do + Each.repeat 10 + (Character strength dexterity constitution intelligence wisdom charisma hitpoints) = !character + expectedHitpoints = Int.abs (+10 Int.+ modifier constitution) + ensureWith (generateErrorMessage "Strength" strength) (Nat.inRange 3 19 strength) + ensureWith (generateErrorMessage "Dexterity" dexterity) (Nat.inRange 3 19 dexterity) + ensureWith (generateErrorMessage "Constitution" constitution) (Nat.inRange 3 19 constitution) + ensureWith (generateErrorMessage "Intelligence" intelligence) (Nat.inRange 3 19 intelligence) + ensureWith (generateErrorMessage "Wisdom" wisdom) (Nat.inRange 3 19 wisdom) + ensureWith (generateErrorMessage "Charisma" charisma) (Nat.inRange 3 19 charisma) + ensureWith (generateErrorMessage "Hitpoints" hitpoints) (hitpoints == expectedHitpoints) test> dndCharacter.tests = - [ runs 10 dndCharacter.test.testAbility - , runs 10 dndCharacter.test.testCharacter - , Test.run dndCharacter.test.testModifier.ex1 - , Test.run dndCharacter.test.testModifier.ex2 - , Test.run dndCharacter.test.testModifier.ex3 - , Test.run dndCharacter.test.testModifier.ex4 - , Test.run dndCharacter.test.testModifier.ex5 - , Test.run dndCharacter.test.testModifier.ex6 - , Test.run dndCharacter.test.testModifier.ex7 - , Test.run dndCharacter.test.testModifier.ex8 - , Test.run dndCharacter.test.testModifier.ex9 - , Test.run dndCharacter.test.testModifier.ex10 - , Test.run dndCharacter.test.testModifier.ex11 - , Test.run dndCharacter.test.testModifier.ex12 - , Test.run dndCharacter.test.testModifier.ex13 - , Test.run dndCharacter.test.testModifier.ex14 - , Test.run dndCharacter.test.testModifier.ex15 - , Test.run dndCharacter.test.testModifier.ex16 - ] |> List.join + [ dndCharacter.ability_.test + , dndCharacter.character.test + , dndCharacter.modifier.test.ex1 + , dndCharacter.modifier.test.ex2 + , dndCharacter.modifier.test.ex3 + , dndCharacter.modifier.test.ex4 + , dndCharacter.modifier.test.ex5 + , dndCharacter.modifier.test.ex6 + , dndCharacter.modifier.test.ex7 + , dndCharacter.modifier.test.ex8 + , dndCharacter.modifier.test.ex9 + , dndCharacter.modifier.test.ex10 + , dndCharacter.modifier.test.ex11 + , dndCharacter.modifier.test.ex12 + , dndCharacter.modifier.test.ex13 + , dndCharacter.modifier.test.ex14 + , dndCharacter.modifier.test.ex15 + , dndCharacter.modifier.test.ex16 + ] |> join