Skip to content

Commit

Permalink
Update Swift tools version to 6.0 and modify test templates for consi…
Browse files Browse the repository at this point in the history
…stency
  • Loading branch information
meatball133 committed Dec 18, 2024
1 parent 30f8e4c commit ceca707
Show file tree
Hide file tree
Showing 15 changed files with 382 additions and 342 deletions.
20 changes: 11 additions & 9 deletions exercises/practice/allergies/.meta/template.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
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 %}
{%- for subCases in case.cases %}
{%- if forloop.outer.first and forloop.first %}
func test{{subCases.description |camelCase }}{{ forloop.outer.counter }}() {
@Test("{{subCases.description}}")
{%- else %}
func test{{subCases.description |camelCase }}{{ forloop.outer.counter }}() 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 }}{{ forloop.outer.counter }}() {
let allergies = Allergies({{subCases.input.score}})
{%- if subCases.property == "allergicTo" %}
{%- if subCases.expected %}
XCTAssertTrue(allergies.{{subCases.property}}(item: "{{subCases.input.item}}"))
#expect(allergies.{{subCases.property}}(item: "{{subCases.input.item}}"))
{%- else %}
XCTAssertFalse(allergies.{{subCases.property}}(item: "{{subCases.input.item}}"))
#expect(!allergies.{{subCases.property}}(item: "{{subCases.input.item}}"))
{%- endif %}
{%- else %}
{%- if subCases.expected %}
XCTAssertEqual(allergies.{{subCases.property}}(), {{subCases.expected | toStringArray }})
#expect(allergies.{{subCases.property}}() == {{subCases.expected | toStringArray }})
{%- endif %}
{%- endif %}
}
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/allergies/Package.swift
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

Expand Down
Loading

0 comments on commit ceca707

Please sign in to comment.