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

Update generator to swift 6.0 #782

Merged
merged 9 commits into from
Dec 25, 2024
Merged
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
13 changes: 6 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,29 @@ on:

jobs:
test:
runs-on: macos-13
runs-on: macos-15
env:
RUNALL: "true"
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Run tests
run: swift test
generator-tests:
runs-on: macos-13
runs-on: macos-15
env:
RUNALL: "true"
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Run tests
run: swift test --package-path ./generator
generator-template-tests:
runs-on: macos-13
runs-on: macos-15
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Run tests
run: ./bin/test_generator.sh
7 changes: 5 additions & 2 deletions 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
import Foundation
Expand Down Expand Up @@ -49,11 +49,13 @@ let practiceExerciseTargets: [Target] = practiceExercises.flatMap {
return [
.target(
name:"\($0.pascalCased)",
dependencies: [.product(name: "Numerics", package: "swift-numerics")],
path:"./exercises/practice/\($0)/.meta/Sources"),
.testTarget(
name:"\($0.pascalCased)Tests",
dependencies: [
.target(name:"\($0.pascalCased)")
.target(name:"\($0.pascalCased)"),
.product(name: "Numerics", package: "swift-numerics")
],
path:"./exercises/practice/\($0)/Tests")
]
Expand All @@ -68,5 +70,6 @@ let package = Package(
name: "xswift",
targets: allTargets.filter { $0.type == .regular }.map { $0.name })
],
dependencies: [.package(url: "https://github.com/apple/swift-numerics", from: "1.0.2")],
targets: allTargets
)
2 changes: 1 addition & 1 deletion concepts/dictionaries/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ As [dictionaries][dictionaries] are one of Swift's three primary collection type
```swift
var addresses: Dictionary<String, String> = ["The Munsters": "1313 Mockingbird Lane", "The Simpsons": "742 Evergreen Terrace", "Buffy Summers": "1630 Revello Drive"]
var sequences: [String: [Int]] = ["Euler's totient": [1, 1, 2, 2, 4, 2, 6, 4], "Lazy caterer": [1, 2, 4, 7, 11, 16, 22, 29, 37], "Carmichael": [561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841]]
let constants: = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e22]
let constants: = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e23]
```

- Empty dictionaries can be written by following the type name of the dictionary by a pair of parenthesis, e.g. `[Int: String]()`, or, if the type can be determined from the context, as just a pair of square brackets surrounding a colon, `[:]`.
Expand Down
2 changes: 1 addition & 1 deletion concepts/dictionaries/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Dictionary literals are written as a series of `key: value` pairs, separated by
```swift
var addresses: Dictionary<String, String> = ["The Munsters": "1313 Mockingbird Lane", "The Simpsons": "742 Evergreen Terrace", "Buffy Summers": "1630 Revello Drive"]
var sequences: [String: [Int]] = ["Euler's totient": [1, 1, 2, 2, 4, 2, 6, 4], "Lazy caterer": [1, 2, 4, 7, 11, 16, 22, 29, 37], "Carmichael": [561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841]]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e22]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e23]
var emptyDict1: [Int: Int] = [:]
var emptyDict2 = [Character: String]()
var emptyDict3 = Dictionary<Int, Double>()
Expand Down
2 changes: 1 addition & 1 deletion concepts/enumerations/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum NESButton {
}
```

This defines a new type named `NESButtons` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed. These values can then be used like any other values in Swift.
This defines a new type named `NESButton` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed. These values can then be used like any other values in Swift.

```swift
var lastPressed = NESButton.up
Expand Down
2 changes: 1 addition & 1 deletion concepts/enumerations/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum NESButton {
}
```

This defines a new type named `NESButtons` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.
This defines a new type named `NESButton` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.

## Methods

Expand Down
2 changes: 1 addition & 1 deletion concepts/numbers/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let plancksConstant : Double = 6.62607015e-34 // plancksConstant is a Double

~~~~exercism/caution
In Swift can't mix types in arithmetic operations, so you can't use any arithmetic operator on an `Int` with a `Double` or vice versa.
Thereby you have to do a type conversion first.
Therefore, you have to do a type conversion first.
~~~~

Swift does have a set of [arithmetic operators][arithmetic-operators] that can be used to perform basic mathematical operations.
Expand Down
2 changes: 1 addition & 1 deletion concepts/numbers/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let plancksConstant : Double = 6.62607015e-34 // plancksConstant is a Double

~~~~exercism/caution
In Swift can't mix types in arithmetic operations, so you can't use any arithmetic operator on an `Int` with a `Double` or vice versa.
Thereby you have to do a type conversion first.
Therefore, you have to do a type conversion first.
~~~~

Swift does have a set of [arithmetic operators][arithmetic-operators] that can be used to perform basic mathematical operations.
Expand Down
16 changes: 16 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@
"transforming"
]
},
{
"slug": "darts",
"name": "Darts",
"uuid": "bdbc6f27-bc98-4edf-9f1d-93dbe49da361",
"practices": [],
"prerequisites": [],
"difficulty": 2
},
{
"slug": "bob",
"name": "Bob",
Expand All @@ -432,6 +440,14 @@
"transforming"
]
},
{
"slug": "armstrong-numbers",
"name": "Armstrong Numbers",
"uuid": "6bd76515-cc17-4238-bc08-7fbdfea14131",
"practices": [],
"prerequisites": [],
"difficulty": 2
},
{
"slug": "grade-school",
"name": "Grade School",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
let flip = { (tuple: (String, String, String)) -> (String, String, String) in
typealias RotationClosure = @Sendable ((String, String, String)) -> (String, String, String)

let flip: RotationClosure = { (tuple: (String, String, String)) -> (String, String, String) in
let (a, b, c) = tuple
return (b, a, c)
}

let rotate = { (tuple: (String, String, String)) -> (String, String, String) in
let rotate: RotationClosure = { (tuple: (String, String, String)) -> (String, String, String) in
let (a, b, c) = tuple
return (b, c, a)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,4 @@ final class BombDefuserTests: XCTestCase {
stringify(expected), stringify(got),
"shuffle(0, (\"Brown\", \"Orange\", \"White\")): Expected \(expected), got \(got)")
}

static var allTests = [
("testFlip", testFlip),
("testRotate", testRotate),
("testShuffle1", testShuffle1),
("testShuffle2", testShuffle2),
("testShuffle3", testShuffle3),
]
}

This file was deleted.

6 changes: 0 additions & 6 deletions exercises/concept/bomb-defuser/Tests/LinuxMain.swift

This file was deleted.

2 changes: 1 addition & 1 deletion exercises/concept/freelancer-rates/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let plancksConstant : Double = 6.62607015e-34 // plancksConstant is a Double

~~~~exercism/caution
In Swift can't mix types in arithmetic operations, so you can't use any arithmetic operator on an `Int` with a `Double` or vice versa.
Thereby you have to do a type conversion first.
Therefore, you have to do a type conversion first.
~~~~

Swift does have a set of [arithmetic operators][arithmetic-operators] that can be used to perform basic mathematical operations.
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/high-score-board/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Dictionary literals are written as a series of `key: value` pairs, separated by
```swift
var addresses: Dictionary<String, String> = ["The Munsters": "1313 Mockingbird Lane", "The Simpsons": "742 Evergreen Terrace", "Buffy Summers": "1630 Revello Drive"]
var sequences: [String: [Int]] = ["Euler's totient": [1, 1, 2, 2, 4, 2, 6, 4], "Lazy caterer": [1, 2, 4, 7, 11, 16, 22, 29, 37], "Carmichael": [561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841]]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e22]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e23]
var emptyDict1: [Int: Int] = [:]
var emptyDict2 = [Character: String]()
var emptyDict3 = Dictionary<Int, Double>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,4 @@ final class HighScoreBoardTests: XCTestCase {
"Expected: \(expected)\nGot: \(got)\norderByPlayers should return the key/value pairs odered ascending by the player's score."
)
}

static var allTests = [
("testEmptyScores", testEmptyScores),
("testAddPlayerExplicit", testAddPlayerExplicit),
("testAddPlayerDefault", testAddPlayerDefault),
("testRemovePlayer", testRemovePlayer),
("testRemoveNonexistentPlayer", testRemoveNonexistentPlayer),
("testResetScore", testResetScore),
("testUpdateScore", testUpdateScore),
("testOrderByPlayers", testOrderByPlayers),
("testOrderByScores", testOrderByScores),
]
}

This file was deleted.

6 changes: 0 additions & 6 deletions exercises/concept/high-score-board/Tests/LinuxMain.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,4 @@ final class LasagnaMasterTests: XCTestCase {
layers: "sauce", "noodles", "béchamel", "meat", "mozzarella", "noodles", "sauce", "ricotta",
"eggplant", "mozzarella", "béchamel", "noodles", "meat", "sauce", "mozzarella"))
}

static var allTests = [
("testRemainingMinutesExplicit", testRemainingMinutesExplicit),
("testRemainingMinutesDefault", testRemainingMinutesDefault),
("testPreparationTime", testPreparationTime),
("testPreparationTimeEmpty", testPreparationTimeEmpty),
("testQuantities", testQuantities),
("testQuantitiesNoSauce", testQuantitiesNoSauce),
("testQuantitiesNoNoodles", testQuantitiesNoNoodles),
("testToOz", testToOz),
("testRedWineRedInequalLayerCount", testRedWineRedInequalLayerCount),
("testRedWineRedEqualLayerCount", testRedWineRedEqualLayerCount),
("testRedWineWhite", testRedWineWhite),
]
}

This file was deleted.

6 changes: 0 additions & 6 deletions exercises/concept/lasagna-master/Tests/LinuxMain.swift

This file was deleted.

2 changes: 1 addition & 1 deletion exercises/concept/log-lines/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum NESButton {
}
```

This defines a new type named `NESButtons` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.
This defines a new type named `NESButton` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.

## Methods

Expand Down
6 changes: 0 additions & 6 deletions exercises/concept/log-lines/Tests/LinuxMain.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,4 @@ final class LogLinesTests: XCTestCase {
let message = "Wha happon?"
XCTAssertEqual(LogLevel.unknown.shortFormat(message: message), "42:Wha happon?")
}

static var allTests = [
("testInitTrace", testInitTrace),
("testInitDebug", testInitDebug),
("testInitInfo", testInitInfo),
("testInitWarning", testInitWarning),
("testInitError", testInitError),
("testInitFatal", testInitFatal),
("testInitUnknownEmpty", testInitUnknownEmpty),
("testInitUnknownNonStandard", testInitUnknownNonStandard),
("testShortTrace", testShortTrace),
("testShortDebug", testShortDebug),
("testShortInfo", testShortInfo),
("testShortWarning", testShortWarning),
("testShortError", testShortError),
("testShortFatal", testShortFatal),
("testShortUnknownEmpty", testShortUnknownEmpty),
]
}

This file was deleted.

6 changes: 0 additions & 6 deletions exercises/concept/magician-in-training/Tests/LinuxMain.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,4 @@ final class MagicianInTrainingTests: XCTestCase {
let stack = [7, 3, 7, 1, 5, 5, 3, 9, 9]
XCTAssertEqual(evenCardCount(stack), 0)
}

static var allTests = [
("testGetCard", testGetCard),
("testSetCard", testSetCard),
("testSetCardIndexTooLow", testSetCardIndexTooLow),
("testSetCardIndexTooHigh", testSetCardIndexTooHigh),
("testInsertAtTop", testInsertAtTop),
("testRemoveCard", testRemoveCard),
("testRemoveCardIndexTooLow", testRemoveCardIndexTooLow),
("testRemoveCardIndexTooHigh", testRemoveCardIndexTooHigh),
("testRemoveTopCard", testRemoveTopCard),
("testRemoveTopCardFromEmptyStack", testRemoveTopCardFromEmptyStack),
("testInsertAtBottom", testInsertAtBottom),
("testRemoveBottomCard", testRemoveBottomCard),
("testRemoveBottomCardFromEmptyStack", testRemoveBottomCardFromEmptyStack),
("testCheckSizeTrue", testCheckSizeTrue),
("testCheckSizeFalse", testCheckSizeFalse),
("testEvenCardCount", testEvenCardCount),
("testEvenCardCountZero", testEvenCardCountZero),
]
}

This file was deleted.

6 changes: 0 additions & 6 deletions exercises/concept/master-mixologist/Tests/LinuxMain.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,4 @@ final class MasterMixologistTests: XCTestCase {
checkTest(e: expectedBeers, g: got.beer) && checkTest(e: expectedSodas, g: got.soda),
"Expected (beer: nil, soda: nil), got: \(got)")
}

static var allTests = [
("testTimeToPrepare", testTimeToPrepare),
("testMakeWedges", testMakeWedges),
("testMakeWedgesNoNeed", testMakeWedgesNoNeed),
("testMakeWedgesNoLimes", testMakeWedgesNoLimes),
("testMakeWedgesTooFewLimes", testMakeWedgesTooFewLimes),
("testFinishShift", testFinishShift),
("testFinishShiftJustRunOver", testFinishShiftJustRunOver),
("testFinishShiftLeaveEarly", testFinishShiftLeaveEarly),
("testOrderTracker", testOrderTracker),
("testOrderOneEach", testOrderOneEach),
("testOrderTrackerNoBeer", testOrderTrackerNoBeer),
("testOrderTrackerNoSoda", testOrderTrackerNoSoda),
("testOrderTrackerNils", testOrderTrackerNils),
]
}
Loading