From 5e0a3931ca6e859a7792f7296879b14d0e270b00 Mon Sep 17 00:00:00 2001 From: meatball Date: Fri, 20 Dec 2024 20:49:17 +0100 Subject: [PATCH] Update Swift tools version to 6.0 and refactor tests to use new syntax --- .../practice/grains/.meta/template.swift | 30 ++++--- exercises/practice/grains/Package.swift | 2 +- .../Tests/GrainsTests/GrainsTests.swift | 86 +++++++++--------- .../practice/hamming/.docs/instructions.md | 11 --- .../practice/hamming/.docs/introduction.md | 12 +++ exercises/practice/hamming/.meta/config.json | 2 +- .../practice/hamming/.meta/template.swift | 18 ++-- exercises/practice/hamming/Package.swift | 2 +- .../Tests/HammingTests/HammingTests.swift | 59 ++++++------ .../hello-world/.docs/instructions.append.md | 5 -- .../practice/hello-world/.meta/description.md | 16 ---- exercises/practice/hello-world/Package.swift | 2 +- .../HelloWorldTests/HelloWorldTests.swift | 9 +- exercises/practice/house/.meta/template.swift | 16 ++-- exercises/practice/house/Package.swift | 2 +- .../house/Tests/HouseTests/HouseTests.swift | 89 ++++++++++--------- 16 files changed, 179 insertions(+), 182 deletions(-) create mode 100644 exercises/practice/hamming/.docs/introduction.md delete mode 100644 exercises/practice/hello-world/.docs/instructions.append.md delete mode 100644 exercises/practice/hello-world/.meta/description.md diff --git a/exercises/practice/grains/.meta/template.swift b/exercises/practice/grains/.meta/template.swift index 6c1d75dd2..fe24b10dd 100644 --- a/exercises/practice/grains/.meta/template.swift +++ b/exercises/practice/grains/.meta/template.swift @@ -1,35 +1,37 @@ -import XCTest +import Testing +import Foundation @testable import {{exercise|camelCase}} -class {{exercise|camelCase}}Tests: XCTestCase { - let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false +let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false + +@Suite struct {{exercise|camelCase}}Tests { {% outer: for case in cases %} {% ifnot case.expected %} {%- for subCases in case.cases %} {%- if forloop.outer.first and forloop.first %} - func test{{subCases.description |camelCase }}() { + @Test("{{subCases.description}}") {%- else %} - func test{{subCases.description |camelCase }}() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("{{subCases.description}}", .enabled(if: RUNALL)) {%- endif %} + func test{{subCases.description |camelCase }}() { {%- ifnot subCases.expected.error %} - XCTAssertEqual(try! Grains.square({{subCases.input.square}}), {{subCases.expected}}) + #expect(try! Grains.square({{subCases.input.square}}) == {{subCases.expected}}) {%- else %} - XCTAssertThrowsError(try Grains.square({{subCases.input.square}})) { error in + #expect(throws: {%- if subCases.input.square < 1 %} - XCTAssertEqual(error as? GrainsError, GrainsError.inputTooLow) + GrainsError.inputTooLow {%- elif subCases.input.square > 64 %} - XCTAssertEqual(error as? GrainsError, GrainsError.inputTooHigh) + GrainsError.inputTooHigh {%- endif %} - } + ){try Grains.square({{subCases.input.square}})} {%- endif -%} } {% endfor -%} {%- else %} - func test{{subCases.description |camelCase }}{{ forloop.outer.counter }}() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertEqual(try! Grains.total, {{case.expected}}) + @Test("{{subCases.description}}", .enabled(if: RUNALL)) + func test{{subCases.description |camelCase }}{{ forloop.outer.counter }}() { + #expect(try! Grains.total == {{case.expected}}) } {%- endif %} {% endfor -%} diff --git a/exercises/practice/grains/Package.swift b/exercises/practice/grains/Package.swift index b4a045070..e4d47551e 100644 --- a/exercises/practice/grains/Package.swift +++ b/exercises/practice/grains/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:6.0 import PackageDescription diff --git a/exercises/practice/grains/Tests/GrainsTests/GrainsTests.swift b/exercises/practice/grains/Tests/GrainsTests/GrainsTests.swift index 6c069e662..23960c834 100644 --- a/exercises/practice/grains/Tests/GrainsTests/GrainsTests.swift +++ b/exercises/practice/grains/Tests/GrainsTests/GrainsTests.swift @@ -1,67 +1,73 @@ -import XCTest +import Foundation +import Testing @testable import Grains -class GrainsTests: XCTestCase { - let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false +let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "true"]) ?? false +@Suite struct GrainsTests { + + @Test("grains on square 1") func testGrainsOnSquare1() { - XCTAssertEqual(try! Grains.square(1), 1) + #expect(try! Grains.square(1) == 1) } - func testGrainsOnSquare2() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertEqual(try! Grains.square(2), 2) + @Test("grains on square 2", .enabled(if: RUNALL)) + func testGrainsOnSquare2() { + #expect(try! Grains.square(2) == 2) } - func testGrainsOnSquare3() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertEqual(try! Grains.square(3), 4) + @Test("grains on square 3", .enabled(if: RUNALL)) + func testGrainsOnSquare3() { + #expect(try! Grains.square(3) == 4) } - func testGrainsOnSquare4() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertEqual(try! Grains.square(4), 8) + @Test("grains on square 4", .enabled(if: RUNALL)) + func testGrainsOnSquare4() { + #expect(try! Grains.square(4) == 8) } - func testGrainsOnSquare16() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertEqual(try! Grains.square(16), 32768) + @Test("grains on square 16", .enabled(if: RUNALL)) + func testGrainsOnSquare16() { + #expect(try! Grains.square(16) == 32768) } - func testGrainsOnSquare32() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertEqual(try! Grains.square(32), 2_147_483_648) + @Test("grains on square 32", .enabled(if: RUNALL)) + func testGrainsOnSquare32() { + #expect(try! Grains.square(32) == 2_147_483_648) } - func testGrainsOnSquare64() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertEqual(try! Grains.square(64), 9_223_372_036_854_775_808) + @Test("grains on square 64", .enabled(if: RUNALL)) + func testGrainsOnSquare64() { + #expect(try! Grains.square(64) == 9_223_372_036_854_775_808) } - func testSquare0IsInvalid() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertThrowsError(try Grains.square(0)) { error in - XCTAssertEqual(error as? GrainsError, GrainsError.inputTooLow) - } + @Test("square 0 is invalid", .enabled(if: RUNALL)) + func testSquare0IsInvalid() { + #expect( + throws: + GrainsError.inputTooLow + ) { try Grains.square(0) } } - func testNegativeSquareIsInvalid() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertThrowsError(try Grains.square(-1)) { error in - XCTAssertEqual(error as? GrainsError, GrainsError.inputTooLow) - } + @Test("negative square is invalid", .enabled(if: RUNALL)) + func testNegativeSquareIsInvalid() { + #expect( + throws: + GrainsError.inputTooLow + ) { try Grains.square(-1) } } - func testSquareGreaterThan64IsInvalid() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertThrowsError(try Grains.square(65)) { error in - XCTAssertEqual(error as? GrainsError, GrainsError.inputTooHigh) - } + @Test("square greater than 64 is invalid", .enabled(if: RUNALL)) + func testSquareGreaterThan64IsInvalid() { + #expect( + throws: + GrainsError.inputTooHigh + ) { try Grains.square(65) } } - func test2() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertEqual(try! Grains.total, 18_446_744_073_709_551_615) + @Test("", .enabled(if: RUNALL)) + func test2() { + #expect(try! Grains.total == 18_446_744_073_709_551_615) } } diff --git a/exercises/practice/hamming/.docs/instructions.md b/exercises/practice/hamming/.docs/instructions.md index b9ae6efc5..8f47a179e 100644 --- a/exercises/practice/hamming/.docs/instructions.md +++ b/exercises/practice/hamming/.docs/instructions.md @@ -2,15 +2,6 @@ Calculate the Hamming distance between two DNA strands. -Your body is made up of cells that contain DNA. -Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. -In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! - -When cells divide, their DNA replicates too. -Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. -If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred. -This is known as the "Hamming distance". - We read DNA using the letters C, A, G and T. Two strands might look like this: @@ -20,8 +11,6 @@ Two strands might look like this: They have 7 differences, and therefore the Hamming distance is 7. -The Hamming distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :) - ## Implementation notes The Hamming distance is only defined for sequences of equal length, so an attempt to calculate it between sequences of different lengths should not work. diff --git a/exercises/practice/hamming/.docs/introduction.md b/exercises/practice/hamming/.docs/introduction.md new file mode 100644 index 000000000..8419bf479 --- /dev/null +++ b/exercises/practice/hamming/.docs/introduction.md @@ -0,0 +1,12 @@ +# Introduction + +Your body is made up of cells that contain DNA. +Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. +In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! + +When cells divide, their DNA replicates too. +Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. +If we compare two strands of DNA and count the differences between them, we can see how many mistakes occurred. +This is known as the "Hamming distance". + +The Hamming distance is useful in many areas of science, not just biology, so it's a nice phrase to be familiar with :) diff --git a/exercises/practice/hamming/.meta/config.json b/exercises/practice/hamming/.meta/config.json index 880d0c789..8da47c0f2 100644 --- a/exercises/practice/hamming/.meta/config.json +++ b/exercises/practice/hamming/.meta/config.json @@ -24,7 +24,7 @@ ".meta/Sources/Hamming/HammingExample.swift" ] }, - "blurb": "Calculate the Hamming difference between two DNA strands.", + "blurb": "Calculate the Hamming distance between two DNA strands.", "source": "The Calculating Point Mutations problem at Rosalind", "source_url": "https://rosalind.info/problems/hamm/" } diff --git a/exercises/practice/hamming/.meta/template.swift b/exercises/practice/hamming/.meta/template.swift index d7cfad002..dd50793c2 100644 --- a/exercises/practice/hamming/.meta/template.swift +++ b/exercises/practice/hamming/.meta/template.swift @@ -1,21 +1,23 @@ -import XCTest +import Testing +import Foundation @testable import {{exercise|camelCase}} -class {{exercise|camelCase}}Tests: XCTestCase { - let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false +let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false + +@Suite struct {{exercise|camelCase}}Tests { {% for case in cases %} {% if forloop.first -%} - func test{{case.description |camelCase }}() { + @Test("{{case.description}}") {% else -%} - func test{{case.description |camelCase }}() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("{{case.description}}", .enabled(if: RUNALL)) {% endif -%} + func test{{case.description |camelCase }}() { {%- ifnot case.expected.error -%} let result = try! Hamming.compute("{{case.input.strand1}}", against:"{{case.input.strand2}}")! let expected = {{case.expected}} - XCTAssertEqual(expected, result) + #expect(expected == result) {%- else -%} - XCTAssertThrowsError(try Hamming.compute("{{case.input.strand1}}", against:"{{case.input.strand2}}")) + #expect(throws: (any Error).self) {try Hamming.compute("{{case.input.strand1}}", against:"{{case.input.strand2}}")} {%- endif -%} } {% endfor -%} diff --git a/exercises/practice/hamming/Package.swift b/exercises/practice/hamming/Package.swift index 1d72a39c4..095d2dda0 100644 --- a/exercises/practice/hamming/Package.swift +++ b/exercises/practice/hamming/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:6.0 import PackageDescription diff --git a/exercises/practice/hamming/Tests/HammingTests/HammingTests.swift b/exercises/practice/hamming/Tests/HammingTests/HammingTests.swift index d4ef1b21b..0094e4cb3 100644 --- a/exercises/practice/hamming/Tests/HammingTests/HammingTests.swift +++ b/exercises/practice/hamming/Tests/HammingTests/HammingTests.swift @@ -1,61 +1,64 @@ -import XCTest +import Foundation +import Testing @testable import Hamming -class HammingTests: XCTestCase { - let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false +let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false +@Suite struct HammingTests { + + @Test("empty strands") func testEmptyStrands() { let result = try! Hamming.compute("", against: "")! let expected = 0 - XCTAssertEqual(expected, result) + #expect(expected == result) } - func testSingleLetterIdenticalStrands() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("single letter identical strands", .enabled(if: RUNALL)) + func testSingleLetterIdenticalStrands() { let result = try! Hamming.compute("A", against: "A")! let expected = 0 - XCTAssertEqual(expected, result) + #expect(expected == result) } - func testSingleLetterDifferentStrands() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("single letter different strands", .enabled(if: RUNALL)) + func testSingleLetterDifferentStrands() { let result = try! Hamming.compute("G", against: "T")! let expected = 1 - XCTAssertEqual(expected, result) + #expect(expected == result) } - func testLongIdenticalStrands() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("long identical strands", .enabled(if: RUNALL)) + func testLongIdenticalStrands() { let result = try! Hamming.compute("GGACTGAAATCTG", against: "GGACTGAAATCTG")! let expected = 0 - XCTAssertEqual(expected, result) + #expect(expected == result) } - func testLongDifferentStrands() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("long different strands", .enabled(if: RUNALL)) + func testLongDifferentStrands() { let result = try! Hamming.compute("GGACGGATTCTG", against: "AGGACGGATTCT")! let expected = 9 - XCTAssertEqual(expected, result) + #expect(expected == result) } - func testDisallowFirstStrandLonger() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertThrowsError(try Hamming.compute("AATG", against: "AAA")) + @Test("disallow first strand longer", .enabled(if: RUNALL)) + func testDisallowFirstStrandLonger() { + #expect(throws: (any Error).self) { try Hamming.compute("AATG", against: "AAA") } } - func testDisallowSecondStrandLonger() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertThrowsError(try Hamming.compute("ATA", against: "AGTG")) + @Test("disallow second strand longer", .enabled(if: RUNALL)) + func testDisallowSecondStrandLonger() { + #expect(throws: (any Error).self) { try Hamming.compute("ATA", against: "AGTG") } } - func testDisallowEmptyFirstStrand() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertThrowsError(try Hamming.compute("", against: "G")) + @Test("disallow empty first strand", .enabled(if: RUNALL)) + func testDisallowEmptyFirstStrand() { + #expect(throws: (any Error).self) { try Hamming.compute("", against: "G") } } - func testDisallowEmptySecondStrand() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test - XCTAssertThrowsError(try Hamming.compute("G", against: "")) + @Test("disallow empty second strand", .enabled(if: RUNALL)) + func testDisallowEmptySecondStrand() { + #expect(throws: (any Error).self) { try Hamming.compute("G", against: "") } } } diff --git a/exercises/practice/hello-world/.docs/instructions.append.md b/exercises/practice/hello-world/.docs/instructions.append.md deleted file mode 100644 index 611d12a9a..000000000 --- a/exercises/practice/hello-world/.docs/instructions.append.md +++ /dev/null @@ -1,5 +0,0 @@ -# Hint -Check out the test cases and expected results in `HelloWorldTests.swift`. Here are some test examples. - -- Calling `hello()` returns `"Hello, World!"` -- Calling `hello("Alice")` returns `"Hello, Alice!"` \ No newline at end of file diff --git a/exercises/practice/hello-world/.meta/description.md b/exercises/practice/hello-world/.meta/description.md deleted file mode 100644 index 5b0158bc8..000000000 --- a/exercises/practice/hello-world/.meta/description.md +++ /dev/null @@ -1,16 +0,0 @@ -# Description - -The classical introductory exercise. Just say "Hello, World!". - -["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is -the traditional first program for beginning programming in a new language -or environment. - -The objectives are simple: - -- Write a function which takes a name, say Alice, and returns the string with the given name, in this case "Hello, Alice!". If no name is passed in, then the function returns the string "Hello, World!". The function should be named `hello`. -- Run the test suite and make sure that it succeeds. -- Submit your solution and check it at the website. - -If everything goes well, you will be ready to fetch your first real exercise. - diff --git a/exercises/practice/hello-world/Package.swift b/exercises/practice/hello-world/Package.swift index 5607b02b5..21f03b6ac 100644 --- a/exercises/practice/hello-world/Package.swift +++ b/exercises/practice/hello-world/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:6.0 import PackageDescription diff --git a/exercises/practice/hello-world/Tests/HelloWorldTests/HelloWorldTests.swift b/exercises/practice/hello-world/Tests/HelloWorldTests/HelloWorldTests.swift index 7e91cb290..77390f55f 100644 --- a/exercises/practice/hello-world/Tests/HelloWorldTests/HelloWorldTests.swift +++ b/exercises/practice/hello-world/Tests/HelloWorldTests/HelloWorldTests.swift @@ -1,9 +1,8 @@ -import XCTest +import Testing @testable import HelloWorld -class HelloWorldTests: XCTestCase { - func testHello() { - XCTAssertEqual(hello(), "Hello, World!") - } +@Test("Hello, World!") +func testHello() { + #expect(hello() == "Hello, World!") } diff --git a/exercises/practice/house/.meta/template.swift b/exercises/practice/house/.meta/template.swift index a29facadd..2444c3ebf 100644 --- a/exercises/practice/house/.meta/template.swift +++ b/exercises/practice/house/.meta/template.swift @@ -1,17 +1,19 @@ -import XCTest +import Testing +import Foundation @testable import {{exercise|camelCase}} -class {{exercise|camelCase}}Tests: XCTestCase { - let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false +let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false + +@Suite struct {{exercise|camelCase}}Tests { {% for case in cases %} {% if forloop.first -%} - func test{{case.description |camelCase }}() { + @Test("{{case.description}}") {% else -%} - func test{{case.description |camelCase }}() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("{{case.description}}", .enabled(if: RUNALL)) {% endif -%} + func test{{case.description |camelCase }}() { let expected = "{{case.expected | join:"\n" + ""}}" - XCTAssertEqual(House.recite(start: {{case.input.startVerse}}, end: {{case.input.endVerse}}), expected) + #expect(House.recite(start: {{case.input.startVerse}}, end: {{case.input.endVerse}}) == expected) } {% endfor -%} } diff --git a/exercises/practice/house/Package.swift b/exercises/practice/house/Package.swift index 087e4ce8f..e008e757a 100644 --- a/exercises/practice/house/Package.swift +++ b/exercises/practice/house/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:6.0 import PackageDescription diff --git a/exercises/practice/house/Tests/HouseTests/HouseTests.swift b/exercises/practice/house/Tests/HouseTests/HouseTests.swift index 6100bb1d7..e602e1f9c 100644 --- a/exercises/practice/house/Tests/HouseTests/HouseTests.swift +++ b/exercises/practice/house/Tests/HouseTests/HouseTests.swift @@ -1,103 +1,106 @@ -import XCTest +import Foundation +import Testing @testable import House -class HouseTests: XCTestCase { - let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false +let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false +@Suite struct HouseTests { + + @Test("verse one - the house that jack built") func testVerseOneTheHouseThatJackBuilt() { let expected = "This is the house that Jack built." - XCTAssertEqual(House.recite(start: 1, end: 1), expected) + #expect(House.recite(start: 1, end: 1) == expected) } - func testVerseTwoTheMaltThatLay() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse two - the malt that lay", .enabled(if: RUNALL)) + func testVerseTwoTheMaltThatLay() { let expected = "This is the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 2, end: 2), expected) + #expect(House.recite(start: 2, end: 2) == expected) } - func testVerseThreeTheRatThatAte() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse three - the rat that ate", .enabled(if: RUNALL)) + func testVerseThreeTheRatThatAte() { let expected = "This is the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 3, end: 3), expected) + #expect(House.recite(start: 3, end: 3) == expected) } - func testVerseFourTheCatThatKilled() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse four - the cat that killed", .enabled(if: RUNALL)) + func testVerseFourTheCatThatKilled() { let expected = "This is the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 4, end: 4), expected) + #expect(House.recite(start: 4, end: 4) == expected) } - func testVerseFiveTheDogThatWorried() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse five - the dog that worried", .enabled(if: RUNALL)) + func testVerseFiveTheDogThatWorried() { let expected = "This is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 5, end: 5), expected) + #expect(House.recite(start: 5, end: 5) == expected) } - func testVerseSixTheCowWithTheCrumpledHorn() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse six - the cow with the crumpled horn", .enabled(if: RUNALL)) + func testVerseSixTheCowWithTheCrumpledHorn() { let expected = "This is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 6, end: 6), expected) + #expect(House.recite(start: 6, end: 6) == expected) } - func testVerseSevenTheMaidenAllForlorn() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse seven - the maiden all forlorn", .enabled(if: RUNALL)) + func testVerseSevenTheMaidenAllForlorn() { let expected = "This is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 7, end: 7), expected) + #expect(House.recite(start: 7, end: 7) == expected) } - func testVerseEightTheManAllTatteredAndTorn() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse eight - the man all tattered and torn", .enabled(if: RUNALL)) + func testVerseEightTheManAllTatteredAndTorn() { let expected = "This is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 8, end: 8), expected) + #expect(House.recite(start: 8, end: 8) == expected) } - func testVerseNineThePriestAllShavenAndShorn() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse nine - the priest all shaven and shorn", .enabled(if: RUNALL)) + func testVerseNineThePriestAllShavenAndShorn() { let expected = "This is the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 9, end: 9), expected) + #expect(House.recite(start: 9, end: 9) == expected) } - func testVerse10TheRoosterThatCrowedInTheMorn() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse 10 - the rooster that crowed in the morn", .enabled(if: RUNALL)) + func testVerse10TheRoosterThatCrowedInTheMorn() { let expected = "This is the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 10, end: 10), expected) + #expect(House.recite(start: 10, end: 10) == expected) } - func testVerse11TheFarmerSowingHisCorn() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse 11 - the farmer sowing his corn", .enabled(if: RUNALL)) + func testVerse11TheFarmerSowingHisCorn() { let expected = "This is the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 11, end: 11), expected) + #expect(House.recite(start: 11, end: 11) == expected) } - func testVerse12TheHorseAndTheHoundAndTheHorn() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("verse 12 - the horse and the hound and the horn", .enabled(if: RUNALL)) + func testVerse12TheHorseAndTheHoundAndTheHorn() { let expected = "This is the horse and the hound and the horn that belonged to the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 12, end: 12), expected) + #expect(House.recite(start: 12, end: 12) == expected) } - func testMultipleVerses() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("multiple verses", .enabled(if: RUNALL)) + func testMultipleVerses() { let expected = "This is the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" + "This is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" + "This is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" + "This is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" + "This is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 4, end: 8), expected) + #expect(House.recite(start: 4, end: 8) == expected) } - func testFullRhyme() throws { - try XCTSkipIf(true && !runAll) // change true to false to run this test + @Test("full rhyme", .enabled(if: RUNALL)) + func testFullRhyme() { let expected = "This is the house that Jack built.\n" + "This is the malt that lay in the house that Jack built.\n" @@ -111,6 +114,6 @@ class HouseTests: XCTestCase { + "This is the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" + "This is the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" + "This is the horse and the hound and the horn that belonged to the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built." - XCTAssertEqual(House.recite(start: 1, end: 12), expected) + #expect(House.recite(start: 1, end: 12) == expected) } }