-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Swift tools version to 6.0 and refactor test templates for con…
…sistency
- Loading branch information
1 parent
30f8e4c
commit 7233261
Showing
13 changed files
with
409 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import XCTest | ||
@testable import Bob | ||
class BobTests: XCTestCase { | ||
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
|
||
import Testing | ||
import Foundation | ||
@testable import {{exercise|camelCase}} | ||
|
||
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 }}() { | ||
{% else -%} | ||
func test{{case.description | camelCase }}() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
{% endif -%} | ||
XCTAssertEqual("{{case.expected}}", Bob.response("{{case.input.heyBob | inspect}}")) | ||
{% if forloop.first -%} | ||
@Test("{{case.description}}") | ||
{% else -%} | ||
@Test("{{case.description}}", .enabled(if: RUNALL)) | ||
{% endif -%} | ||
func test{{case.description |camelCase }}() { | ||
#expect("{{case.expected}}" == Bob.response("{{case.input.heyBob | inspect}}")) | ||
} | ||
{% endfor %} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// swift-tools-version:5.3 | ||
// swift-tools-version:6.0 | ||
|
||
import PackageDescription | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,134 +1,135 @@ | ||
import XCTest | ||
import Foundation | ||
import Testing | ||
|
||
@testable import Bob | ||
|
||
class BobTests: XCTestCase { | ||
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
|
||
@Suite struct BobTests { | ||
|
||
@Test("stating something") | ||
func testStatingSomething() { | ||
XCTAssertEqual("Whatever.", Bob.response("Tom-ay-to, tom-aaaah-to.")) | ||
#expect("Whatever." == Bob.response("Tom-ay-to, tom-aaaah-to.")) | ||
} | ||
|
||
func testShouting() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whoa, chill out!", Bob.response("WATCH OUT!")) | ||
@Test("shouting", .enabled(if: RUNALL)) | ||
func testShouting() { | ||
#expect("Whoa, chill out!" == Bob.response("WATCH OUT!")) | ||
} | ||
|
||
func testShoutingGibberish() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whoa, chill out!", Bob.response("FCECDFCAAB")) | ||
@Test("shouting gibberish", .enabled(if: RUNALL)) | ||
func testShoutingGibberish() { | ||
#expect("Whoa, chill out!" == Bob.response("FCECDFCAAB")) | ||
} | ||
|
||
func testAskingAQuestion() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Sure.", Bob.response("Does this cryogenic chamber make me look fat?")) | ||
@Test("asking a question", .enabled(if: RUNALL)) | ||
func testAskingAQuestion() { | ||
#expect("Sure." == Bob.response("Does this cryogenic chamber make me look fat?")) | ||
} | ||
|
||
func testAskingANumericQuestion() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Sure.", Bob.response("You are, what, like 15?")) | ||
@Test("asking a numeric question", .enabled(if: RUNALL)) | ||
func testAskingANumericQuestion() { | ||
#expect("Sure." == Bob.response("You are, what, like 15?")) | ||
} | ||
|
||
func testAskingGibberish() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Sure.", Bob.response("fffbbcbeab?")) | ||
@Test("asking gibberish", .enabled(if: RUNALL)) | ||
func testAskingGibberish() { | ||
#expect("Sure." == Bob.response("fffbbcbeab?")) | ||
} | ||
|
||
func testTalkingForcefully() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whatever.", Bob.response("Hi there!")) | ||
@Test("talking forcefully", .enabled(if: RUNALL)) | ||
func testTalkingForcefully() { | ||
#expect("Whatever." == Bob.response("Hi there!")) | ||
} | ||
|
||
func testUsingAcronymsInRegularSpeech() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whatever.", Bob.response("It's OK if you don't want to go work for NASA.")) | ||
@Test("using acronyms in regular speech", .enabled(if: RUNALL)) | ||
func testUsingAcronymsInRegularSpeech() { | ||
#expect("Whatever." == Bob.response("It's OK if you don't want to go work for NASA.")) | ||
} | ||
|
||
func testForcefulQuestion() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Calm down, I know what I'm doing!", Bob.response("WHAT'S GOING ON?")) | ||
@Test("forceful question", .enabled(if: RUNALL)) | ||
func testForcefulQuestion() { | ||
#expect("Calm down, I know what I'm doing!" == Bob.response("WHAT'S GOING ON?")) | ||
} | ||
|
||
func testShoutingNumbers() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whoa, chill out!", Bob.response("1, 2, 3 GO!")) | ||
@Test("shouting numbers", .enabled(if: RUNALL)) | ||
func testShoutingNumbers() { | ||
#expect("Whoa, chill out!" == Bob.response("1, 2, 3 GO!")) | ||
} | ||
|
||
func testNoLetters() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whatever.", Bob.response("1, 2, 3")) | ||
@Test("no letters", .enabled(if: RUNALL)) | ||
func testNoLetters() { | ||
#expect("Whatever." == Bob.response("1, 2, 3")) | ||
} | ||
|
||
func testQuestionWithNoLetters() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Sure.", Bob.response("4?")) | ||
@Test("question with no letters", .enabled(if: RUNALL)) | ||
func testQuestionWithNoLetters() { | ||
#expect("Sure." == Bob.response("4?")) | ||
} | ||
|
||
func testShoutingWithSpecialCharacters() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual( | ||
"Whoa, chill out!", Bob.response("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")) | ||
@Test("shouting with special characters", .enabled(if: RUNALL)) | ||
func testShoutingWithSpecialCharacters() { | ||
#expect("Whoa, chill out!" == Bob.response("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")) | ||
} | ||
|
||
func testShoutingWithNoExclamationMark() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whoa, chill out!", Bob.response("I HATE THE DENTIST")) | ||
@Test("shouting with no exclamation mark", .enabled(if: RUNALL)) | ||
func testShoutingWithNoExclamationMark() { | ||
#expect("Whoa, chill out!" == Bob.response("I HATE THE DENTIST")) | ||
} | ||
|
||
func testStatementContainingQuestionMark() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whatever.", Bob.response("Ending with ? means a question.")) | ||
@Test("statement containing question mark", .enabled(if: RUNALL)) | ||
func testStatementContainingQuestionMark() { | ||
#expect("Whatever." == Bob.response("Ending with ? means a question.")) | ||
} | ||
|
||
func testNonLettersWithQuestion() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Sure.", Bob.response(":) ?")) | ||
@Test("non-letters with question", .enabled(if: RUNALL)) | ||
func testNonLettersWithQuestion() { | ||
#expect("Sure." == Bob.response(":) ?")) | ||
} | ||
|
||
func testPrattlingOn() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Sure.", Bob.response("Wait! Hang on. Are you going to be OK?")) | ||
@Test("prattling on", .enabled(if: RUNALL)) | ||
func testPrattlingOn() { | ||
#expect("Sure." == Bob.response("Wait! Hang on. Are you going to be OK?")) | ||
} | ||
|
||
func testSilence() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Fine. Be that way!", Bob.response("")) | ||
@Test("silence", .enabled(if: RUNALL)) | ||
func testSilence() { | ||
#expect("Fine. Be that way!" == Bob.response("")) | ||
} | ||
|
||
func testProlongedSilence() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Fine. Be that way!", Bob.response(" ")) | ||
@Test("prolonged silence", .enabled(if: RUNALL)) | ||
func testProlongedSilence() { | ||
#expect("Fine. Be that way!" == Bob.response(" ")) | ||
} | ||
|
||
func testAlternateSilence() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Fine. Be that way!", Bob.response("\t\t\t\t\t\t\t\t\t\t")) | ||
@Test("alternate silence", .enabled(if: RUNALL)) | ||
func testAlternateSilence() { | ||
#expect("Fine. Be that way!" == Bob.response("\t\t\t\t\t\t\t\t\t\t")) | ||
} | ||
|
||
func testMultipleLineQuestion() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual( | ||
"Whatever.", Bob.response("\nDoes this cryogenic chamber make me look fat?\nNo.")) | ||
@Test("starting with whitespace", .enabled(if: RUNALL)) | ||
func testStartingWithWhitespace() { | ||
#expect("Whatever." == Bob.response(" hmmmmmmm...")) | ||
} | ||
|
||
func testStartingWithWhitespace() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whatever.", Bob.response(" hmmmmmmm...")) | ||
@Test("ending with whitespace", .enabled(if: RUNALL)) | ||
func testEndingWithWhitespace() { | ||
#expect("Sure." == Bob.response("Okay if like my spacebar quite a bit? ")) | ||
} | ||
|
||
func testEndingWithWhitespace() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Sure.", Bob.response("Okay if like my spacebar quite a bit? ")) | ||
@Test("other whitespace", .enabled(if: RUNALL)) | ||
func testOtherWhitespace() { | ||
#expect("Fine. Be that way!" == Bob.response("\n\r \t")) | ||
} | ||
|
||
func testOtherWhitespace() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Fine. Be that way!", Bob.response("\n\r \t")) | ||
@Test("non-question ending with whitespace", .enabled(if: RUNALL)) | ||
func testNonQuestionEndingWithWhitespace() { | ||
#expect("Whatever." == Bob.response("This is a statement ending with whitespace ")) | ||
} | ||
|
||
func testNonQuestionEndingWithWhitespace() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("Whatever.", Bob.response("This is a statement ending with whitespace ")) | ||
@Test("multiple line question", .enabled(if: RUNALL)) | ||
func testMultipleLineQuestion() { | ||
#expect("Sure." == Bob.response("\nDoes this cryogenic chamber make\n me look fat?")) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// swift-tools-version:5.3 | ||
// swift-tools-version:6.0 | ||
|
||
import PackageDescription | ||
|
||
|
Oops, something went wrong.