Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Swift 6]: Update Exercises batch 2 #786

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading