From 55d64a225c76eec0eb56ed7beea2e0275cdb0746 Mon Sep 17 00:00:00 2001 From: SimaDovakin Date: Tue, 12 Nov 2024 21:48:54 +0200 Subject: [PATCH] [concept-exercises-test-upgrades]: Updated tests in the concept exercises using not deprecated functionality. --- .../concept/lasagna/.meta/testAnnotation.json | 14 +-- exercises/concept/lasagna/lasagna.test.u | 28 +++-- .../pacman-rules/.meta/testAnnotation.json | 24 ++-- .../concept/pacman-rules/pacmanRules.test.u | 110 ++++++++++++++---- 4 files changed, 125 insertions(+), 51 deletions(-) diff --git a/exercises/concept/lasagna/.meta/testAnnotation.json b/exercises/concept/lasagna/.meta/testAnnotation.json index d7a5cff..20cc737 100644 --- a/exercises/concept/lasagna/.meta/testAnnotation.json +++ b/exercises/concept/lasagna/.meta/testAnnotation.json @@ -1,14 +1,14 @@ [ { - "name": "lasagna.test.ex1", - "test_code": "let\n Test.expect (expectedMinutesInOven === 40)" + "name": "expected minutes in oven", + "test_code": "verify do\n labeled \"expected minutes in oven\" do\n expected = 40\n label \"expected\" expected\n label \"actual\" expectedMinutesInOven\n ensureEqual expected expectedMinutesInOven" }, { - "name": "lasagna.test.ex2", - "test_code": "let\n Test.expect (preparationTimeInMinutes 5 === 10)" + "name": "preparation time in minutes", + "test_code": "verify do\n labeled \"preparation time in minutes\" do\n expected = 10\n actual = preparationTimeInMinutes 5\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { - "name": "lasagna.test.ex3", - "test_code": "let\n Test.expect (elapsedTimeInMinutes 3 20 === 26)" + "name": "elapsed time in minutes", + "test_code": "verify do\n labeled \"elapsed time in minutes\" do\n expected = 26\n actual = elapsedTimeInMinutes 3 20\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } -] \ No newline at end of file +] diff --git a/exercises/concept/lasagna/lasagna.test.u b/exercises/concept/lasagna/lasagna.test.u index 60eaf3d..f22bc85 100644 --- a/exercises/concept/lasagna/lasagna.test.u +++ b/exercises/concept/lasagna/lasagna.test.u @@ -1,13 +1,27 @@ -lasagna.test.ex1 = let - Test.expect (expectedMinutesInOven === 40) +lasagna.test.ex1 = verify do + labeled "expected minutes in oven" do + expected = 40 + label "expected" expected + label "actual" expectedMinutesInOven + ensureEqual expected expectedMinutesInOven -lasagna.test.ex2 = let - Test.expect (preparationTimeInMinutes 5 === 10) +lasagna.test.ex2 = verify do + labeled "preparation time in minutes" do + expected = 10 + actual = preparationTimeInMinutes 5 + label "expected" expected + label "actual" actual + ensureEqual expected actual -lasagna.test.ex3 = let - Test.expect (elapsedTimeInMinutes 3 20 === 26) +lasagna.test.ex3 = verify do + labeled "elapsed time in minutes" do + expected = 26 + actual = elapsedTimeInMinutes 3 20 + label "expected" expected + label "actual" actual + ensureEqual expected actual -test> lasagna.tests = runAll [ +test> lasagna.tests = join [ lasagna.test.ex1, lasagna.test.ex2, lasagna.test.ex3 diff --git a/exercises/concept/pacman-rules/.meta/testAnnotation.json b/exercises/concept/pacman-rules/.meta/testAnnotation.json index b676f88..3ad34a6 100644 --- a/exercises/concept/pacman-rules/.meta/testAnnotation.json +++ b/exercises/concept/pacman-rules/.meta/testAnnotation.json @@ -1,50 +1,50 @@ [ { "name": "eatGhost, ghost gets eaten", - "test_code": "let\n Test.label.deprecated \"eatGhost, ghost gets eaten\" <| expect (eatGhost true true)" + "test_code": "verify do\n labeled \"eatGhost, ghost gets eaten\" do\n expected = true\n actual = eatGhost true true\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "eatGhost, ghost does not get eaten because no power pellet active", - "test_code": "let\n Test.label.deprecated \"eatGhost, ghost does not get eaten because no power pellet active\" <| expect (eatGhost false true === false)" + "test_code": "verify do\n labeled \"eatGhost, ghost does not get eaten because no power pellet active\" do\n expected = false\n actual = eatGhost false true\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "eatGhost, ghost does not get eaten because not touching ghost", - "test_code": "let\n Test.label.deprecated \"eatGhost, ghost does not get eaten because not touching ghost\" <| expect (eatGhost true false === false)" + "test_code": "verify do\n labeled \"eatGhost, ghost does not get eaten because not touching ghost\" do\n expected = false\n actual = eatGhost true false\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "score, score when eating dot", - "test_code": "let\n Test.label.deprecated \"score, score when eating dot\" <| expect (score false true)" + "test_code": "verify do\n labeled \"score, score when eating dot\" do\n expected = true\n actual = score false true\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "score, score when eating power pellet", - "test_code": "let\n Test.label.deprecated \"score, score when eating power pellet\" <| expect (score true false)" + "test_code": "verify do\n labeled \"score, score when eating power pellet\" do\n expected = true\n actual = score true false\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "score, no score when nothing eaten", - "test_code": "let\n Test.label.deprecated \"score, no score when nothing eaten\" <| expect (score false false === false )" + "test_code": "verify do\n labeled \"score, no score when nothing eaten\" do\n expected = false\n actual = score false false\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "lose if touching a ghost without a power pellet active", - "test_code": "let\n Test.label.deprecated \"lose if touching a ghost without a power pellet active\" <| expect (lose false true)" + "test_code": "verify do\n labeled \"lose if touching a ghost without a power pellet active\" do\n expected = true\n actual = lose false true\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "don't lose if touching a ghost with a power pellet active", - "test_code": "let\n Test.label.deprecated \"don't lose if touching a ghost with a power pellet active\" <| expect (lose true true === false)" + "test_code": "verify do\n labeled \"don't lose if touching a ghost with a power pellet active\" do\n expected = false\n actual = lose true true\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "don't lose if not touching a ghost", - "test_code": "let\n Test.label.deprecated \"don't lose if not touching a ghost\" <| expect (lose true false === false)" + "test_code": "verify do\n labeled \"don't lose if not touching a ghost\" do\n expected = false\n actual = lose true false\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "win if all dots eaten", - "test_code": "let\n Test.label.deprecated \"win if all dots eaten\" <| expect (win true false false)" + "test_code": "verify do\n labeled \"win if all dots eaten\" do\n expected = true\n actual = win true false false\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "don't win if all dots eaten, but touching a ghost", - "test_code": "let\n Test.label.deprecated \"don't win if all dots eaten, but touching a ghost\" <| expect (win true false true === false)" + "test_code": "verify do\n labeled \"don't win if all dots eaten, but touching a ghost\" do\n expected = false\n actual = win true false true\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "win if all dots eaten and touching a ghost with a power pellet active", - "test_code": "let\n Test.label.deprecated \"win if all dots eaten and touching a ghost with a power pellet active\" <| expect (win true true true)" + "test_code": "verify do\n labeled \"win if all dots eaten and touching a ghost with a power pellet active\" do\n expected = true\n actual = win true true true\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } ] \ No newline at end of file diff --git a/exercises/concept/pacman-rules/pacmanRules.test.u b/exercises/concept/pacman-rules/pacmanRules.test.u index 10481cb..5b6a637 100644 --- a/exercises/concept/pacman-rules/pacmanRules.test.u +++ b/exercises/concept/pacman-rules/pacmanRules.test.u @@ -1,40 +1,100 @@ -pacmanRules.test.ex1 = let - Test.label.deprecated "eatGhost, ghost gets eaten" <| expect (eatGhost true true) +pacmanRules.test.ex1 = verify do + labeled "eatGhost, ghost gets eaten" do + expected = true + actual = eatGhost true true + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex2 = let - Test.label.deprecated "eatGhost, ghost does not get eaten because no power pellet active" <| expect (eatGhost false true === false) +pacmanRules.test.ex2 = verify do + labeled "eatGhost, ghost does not get eaten because no power pellet active" do + expected = false + actual = eatGhost false true + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex3 = let - Test.label.deprecated "eatGhost, ghost does not get eaten because not touching ghost" <| expect (eatGhost true false === false) +pacmanRules.test.ex3 = verify do + labeled "eatGhost, ghost does not get eaten because not touching ghost" do + expected = false + actual = eatGhost true false + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex4 = let - Test.label.deprecated "score, score when eating dot" <| expect (score false true) +pacmanRules.test.ex4 = verify do + labeled "score, score when eating dot" do + expected = true + actual = score false true + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex5 = let - Test.label.deprecated "score, score when eating power pellet" <| expect (score true false) +pacmanRules.test.ex5 = verify do + labeled "score, score when eating power pellet" do + expected = true + actual = score true false + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex6 = let - Test.label.deprecated "score, no score when nothing eaten" <| expect (score false false === false ) +pacmanRules.test.ex6 = verify do + labeled "score, no score when nothing eaten" do + expected = false + actual = score false false + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex7 = let - Test.label.deprecated "lose if touching a ghost without a power pellet active" <| expect (lose false true) +pacmanRules.test.ex7 = verify do + labeled "lose if touching a ghost without a power pellet active" do + expected = true + actual = lose false true + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex8 = let - Test.label.deprecated "don't lose if touching a ghost with a power pellet active" <| expect (lose true true === false) +pacmanRules.test.ex8 = verify do + labeled "don't lose if touching a ghost with a power pellet active" do + expected = false + actual = lose true true + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex9 = let - Test.label.deprecated "don't lose if not touching a ghost" <| expect (lose true false === false) +pacmanRules.test.ex9 = verify do + labeled "don't lose if not touching a ghost" do + expected = false + actual = lose true false + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex10 = let - Test.label.deprecated "win if all dots eaten" <| expect (win true false false) +pacmanRules.test.ex10 = verify do + labeled "win if all dots eaten" do + expected = true + actual = win true false false + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex11 = let - Test.label.deprecated "don't win if all dots eaten, but touching a ghost" <| expect (win true false true === false) +pacmanRules.test.ex11 = verify do + labeled "don't win if all dots eaten, but touching a ghost" do + expected = false + actual = win true false true + label "expected" expected + label "actual" actual + ensureEqual expected actual -pacmanRules.test.ex12 = let - Test.label.deprecated "win if all dots eaten and touching a ghost with a power pellet active" <| expect (win true true true) +pacmanRules.test.ex12 = verify do + labeled "win if all dots eaten and touching a ghost with a power pellet active" do + expected = true + actual = win true true true + label "expected" expected + label "actual" actual + ensureEqual expected actual -test> pacmanRules.tests = runAll [ +test> pacmanRules.tests = join [ pacmanRules.test.ex1, pacmanRules.test.ex2, pacmanRules.test.ex3,