Skip to content

Commit 2ac1785

Browse files
authored
[Swift 6] Depricate exercises (#805)
* Depricate exercises * Format config
1 parent 0379936 commit 2ac1785

File tree

4 files changed

+136
-131
lines changed

4 files changed

+136
-131
lines changed

config.json

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -257,42 +257,6 @@
257257
}
258258
],
259259
"practice": [
260-
{
261-
"slug": "binary",
262-
"name": "Binary",
263-
"uuid": "0930d019-2ccb-48f9-9ee7-467b683d9901",
264-
"practices": [],
265-
"prerequisites": [],
266-
"difficulty": 1,
267-
"status": "deprecated"
268-
},
269-
{
270-
"slug": "hexadecimal",
271-
"name": "Hexadecimal",
272-
"uuid": "3a9f0e4d-a569-40ea-adb8-ded8d240c949",
273-
"practices": [],
274-
"prerequisites": [],
275-
"difficulty": 1,
276-
"status": "deprecated"
277-
},
278-
{
279-
"slug": "octal",
280-
"name": "Octal",
281-
"uuid": "128bcbc1-18b3-45e7-9590-c71d8f57c5c1",
282-
"practices": [],
283-
"prerequisites": [],
284-
"difficulty": 1,
285-
"status": "deprecated"
286-
},
287-
{
288-
"slug": "trinary",
289-
"name": "Trinary",
290-
"uuid": "8b376ef9-ad94-4623-8d0f-e2d7bb6c364a",
291-
"practices": [],
292-
"prerequisites": [],
293-
"difficulty": 1,
294-
"status": "deprecated"
295-
},
296260
{
297261
"slug": "difference-of-squares",
298262
"name": "Difference of Squares",
@@ -396,18 +360,6 @@
396360
"prerequisites": [],
397361
"difficulty": 1
398362
},
399-
{
400-
"slug": "accumulate",
401-
"name": "Accumulate",
402-
"uuid": "cb5bc145-8249-4b3b-bcb3-b8d7805f2a14",
403-
"practices": [],
404-
"prerequisites": [],
405-
"difficulty": 2,
406-
"topics": [
407-
"recursion",
408-
"transforming"
409-
]
410-
},
411363
{
412364
"slug": "darts",
413365
"name": "Darts",
@@ -724,19 +676,6 @@
724676
"tuples"
725677
]
726678
},
727-
{
728-
"slug": "scale-generator",
729-
"name": "Scale Generator",
730-
"uuid": "1c9dfe22-de66-4437-862b-8921dc7eb25e",
731-
"practices": [],
732-
"prerequisites": [],
733-
"difficulty": 3,
734-
"topics": [
735-
"loops",
736-
"pattern_matching",
737-
"strings"
738-
]
739-
},
740679
{
741680
"slug": "scrabble-score",
742681
"name": "Scrabble Score",
@@ -1341,6 +1280,69 @@
13411280
"sorting"
13421281
]
13431282
},
1283+
{
1284+
"slug": "binary",
1285+
"name": "Binary",
1286+
"uuid": "0930d019-2ccb-48f9-9ee7-467b683d9901",
1287+
"practices": [],
1288+
"prerequisites": [],
1289+
"difficulty": 1,
1290+
"status": "deprecated"
1291+
},
1292+
{
1293+
"slug": "hexadecimal",
1294+
"name": "Hexadecimal",
1295+
"uuid": "3a9f0e4d-a569-40ea-adb8-ded8d240c949",
1296+
"practices": [],
1297+
"prerequisites": [],
1298+
"difficulty": 1,
1299+
"status": "deprecated"
1300+
},
1301+
{
1302+
"slug": "octal",
1303+
"name": "Octal",
1304+
"uuid": "128bcbc1-18b3-45e7-9590-c71d8f57c5c1",
1305+
"practices": [],
1306+
"prerequisites": [],
1307+
"difficulty": 1,
1308+
"status": "deprecated"
1309+
},
1310+
{
1311+
"slug": "trinary",
1312+
"name": "Trinary",
1313+
"uuid": "8b376ef9-ad94-4623-8d0f-e2d7bb6c364a",
1314+
"practices": [],
1315+
"prerequisites": [],
1316+
"difficulty": 1,
1317+
"status": "deprecated"
1318+
},
1319+
{
1320+
"slug": "accumulate",
1321+
"name": "Accumulate",
1322+
"uuid": "cb5bc145-8249-4b3b-bcb3-b8d7805f2a14",
1323+
"practices": [],
1324+
"prerequisites": [],
1325+
"difficulty": 2,
1326+
"status": "deprecated",
1327+
"topics": [
1328+
"recursion",
1329+
"transforming"
1330+
]
1331+
},
1332+
{
1333+
"slug": "scale-generator",
1334+
"name": "Scale Generator",
1335+
"uuid": "1c9dfe22-de66-4437-862b-8921dc7eb25e",
1336+
"practices": [],
1337+
"prerequisites": [],
1338+
"difficulty": 3,
1339+
"status": "deprecated",
1340+
"topics": [
1341+
"loops",
1342+
"pattern_matching",
1343+
"strings"
1344+
]
1345+
},
13441346
{
13451347
"slug": "beer-song",
13461348
"name": "Beer Song",

exercises/practice/scale-generator/.meta/template.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import XCTest
1+
import Testing
2+
import Foundation
23
@testable import {{exercise|camelCase}}
3-
class {{exercise|camelCase}}Tests: XCTestCase {
4-
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false
54

5+
let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false
6+
7+
@Suite struct {{exercise|camelCase}}Tests {
68
{% outer: for case in cases %}
79
{%- for subCases in case.cases %}
810
{%- if forloop.outer.first and forloop.first %}
9-
func test{{subCases.description |camelCase }}() {
11+
@Test("{{subCases.description}}")
1012
{%- else %}
11-
func test{{subCases.description |camelCase }}() throws {
12-
try XCTSkipIf(true && !runAll) // change true to false to run this test
13+
@Test("{{subCases.description}}", .enabled(if: RUNALL))
1314
{%- endif %}
15+
func test{{subCases.description |camelCase }}() {
1416
let scaleGenerator = ScaleGenerator(tonic: "{{subCases.input.tonic}}")
1517
{%- if subCases.property == "chromatic" %}
16-
XCTAssertEqual(scaleGenerator.{{subCases.property}}(), {{subCases.expected | toStringArray }})
18+
#expect(scaleGenerator.{{subCases.property}}() == {{subCases.expected | toStringArray }})
1719
{%- else %}
18-
XCTAssertEqual(scaleGenerator.{{subCases.property}}("{{subCases.input.intervals}}"), {{subCases.expected | toStringArray }})
20+
#expect(scaleGenerator.{{subCases.property}}("{{subCases.input.intervals}}") == {{subCases.expected | toStringArray }})
1921
{%- endif %}
2022
}
2123
{% endfor -%}

exercises/practice/scale-generator/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.3
1+
// swift-tools-version:6.0
22

33
import PackageDescription
44

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,118 @@
1-
import XCTest
1+
import Foundation
2+
import Testing
23

34
@testable import ScaleGenerator
45

5-
class ScaleGeneratorTests: XCTestCase {
6-
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false
6+
let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false
77

8+
@Suite struct ScaleGeneratorTests {
9+
10+
@Test("Chromatic scale with sharps")
811
func testChromaticScaleWithSharps() {
912
let scaleGenerator = ScaleGenerator(tonic: "C")
10-
XCTAssertEqual(
11-
scaleGenerator.chromatic(), ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"])
13+
#expect(
14+
scaleGenerator.chromatic() == [
15+
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B",
16+
])
1217
}
1318

14-
func testChromaticScaleWithFlats() throws {
15-
try XCTSkipIf(true && !runAll) // change true to false to run this test
19+
@Test("Chromatic scale with flats", .enabled(if: RUNALL))
20+
func testChromaticScaleWithFlats() {
1621
let scaleGenerator = ScaleGenerator(tonic: "F")
17-
XCTAssertEqual(
18-
scaleGenerator.chromatic(), ["F", "Gb", "G", "Ab", "A", "Bb", "B", "C", "Db", "D", "Eb", "E"])
22+
#expect(
23+
scaleGenerator.chromatic() == [
24+
"F", "Gb", "G", "Ab", "A", "Bb", "B", "C", "Db", "D", "Eb", "E",
25+
])
1926
}
2027

21-
func testSimpleMajorScale() throws {
22-
try XCTSkipIf(true && !runAll) // change true to false to run this test
28+
@Test("Simple major scale", .enabled(if: RUNALL))
29+
func testSimpleMajorScale() {
2330
let scaleGenerator = ScaleGenerator(tonic: "C")
24-
XCTAssertEqual(scaleGenerator.interval("MMmMMMm"), ["C", "D", "E", "F", "G", "A", "B", "C"])
31+
#expect(scaleGenerator.interval("MMmMMMm") == ["C", "D", "E", "F", "G", "A", "B", "C"])
2532
}
2633

27-
func testMajorScaleWithSharps() throws {
28-
try XCTSkipIf(true && !runAll) // change true to false to run this test
34+
@Test("Major scale with sharps", .enabled(if: RUNALL))
35+
func testMajorScaleWithSharps() {
2936
let scaleGenerator = ScaleGenerator(tonic: "G")
30-
XCTAssertEqual(scaleGenerator.interval("MMmMMMm"), ["G", "A", "B", "C", "D", "E", "F#", "G"])
37+
#expect(scaleGenerator.interval("MMmMMMm") == ["G", "A", "B", "C", "D", "E", "F#", "G"])
3138
}
3239

33-
func testMajorScaleWithFlats() throws {
34-
try XCTSkipIf(true && !runAll) // change true to false to run this test
40+
@Test("Major scale with flats", .enabled(if: RUNALL))
41+
func testMajorScaleWithFlats() {
3542
let scaleGenerator = ScaleGenerator(tonic: "F")
36-
XCTAssertEqual(scaleGenerator.interval("MMmMMMm"), ["F", "G", "A", "Bb", "C", "D", "E", "F"])
43+
#expect(scaleGenerator.interval("MMmMMMm") == ["F", "G", "A", "Bb", "C", "D", "E", "F"])
3744
}
3845

39-
func testMinorScaleWithSharps() throws {
40-
try XCTSkipIf(true && !runAll) // change true to false to run this test
46+
@Test("Minor scale with sharps", .enabled(if: RUNALL))
47+
func testMinorScaleWithSharps() {
4148
let scaleGenerator = ScaleGenerator(tonic: "f#")
42-
XCTAssertEqual(
43-
scaleGenerator.interval("MmMMmMM"), ["F#", "G#", "A", "B", "C#", "D", "E", "F#"])
49+
#expect(scaleGenerator.interval("MmMMmMM") == ["F#", "G#", "A", "B", "C#", "D", "E", "F#"])
4450
}
4551

46-
func testMinorScaleWithFlats() throws {
47-
try XCTSkipIf(true && !runAll) // change true to false to run this test
52+
@Test("Minor scale with flats", .enabled(if: RUNALL))
53+
func testMinorScaleWithFlats() {
4854
let scaleGenerator = ScaleGenerator(tonic: "bb")
49-
XCTAssertEqual(
50-
scaleGenerator.interval("MmMMmMM"), ["Bb", "C", "Db", "Eb", "F", "Gb", "Ab", "Bb"])
55+
#expect(scaleGenerator.interval("MmMMmMM") == ["Bb", "C", "Db", "Eb", "F", "Gb", "Ab", "Bb"])
5156
}
5257

53-
func testDorianMode() throws {
54-
try XCTSkipIf(true && !runAll) // change true to false to run this test
58+
@Test("Dorian mode", .enabled(if: RUNALL))
59+
func testDorianMode() {
5560
let scaleGenerator = ScaleGenerator(tonic: "d")
56-
XCTAssertEqual(scaleGenerator.interval("MmMMMmM"), ["D", "E", "F", "G", "A", "B", "C", "D"])
61+
#expect(scaleGenerator.interval("MmMMMmM") == ["D", "E", "F", "G", "A", "B", "C", "D"])
5762
}
5863

59-
func testMixolydianMode() throws {
60-
try XCTSkipIf(true && !runAll) // change true to false to run this test
64+
@Test("Mixolydian mode", .enabled(if: RUNALL))
65+
func testMixolydianMode() {
6166
let scaleGenerator = ScaleGenerator(tonic: "Eb")
62-
XCTAssertEqual(
63-
scaleGenerator.interval("MMmMMmM"), ["Eb", "F", "G", "Ab", "Bb", "C", "Db", "Eb"])
67+
#expect(scaleGenerator.interval("MMmMMmM") == ["Eb", "F", "G", "Ab", "Bb", "C", "Db", "Eb"])
6468
}
6569

66-
func testLydianMode() throws {
67-
try XCTSkipIf(true && !runAll) // change true to false to run this test
70+
@Test("Lydian mode", .enabled(if: RUNALL))
71+
func testLydianMode() {
6872
let scaleGenerator = ScaleGenerator(tonic: "a")
69-
XCTAssertEqual(
70-
scaleGenerator.interval("MMMmMMm"), ["A", "B", "C#", "D#", "E", "F#", "G#", "A"])
73+
#expect(scaleGenerator.interval("MMMmMMm") == ["A", "B", "C#", "D#", "E", "F#", "G#", "A"])
7174
}
7275

73-
func testPhrygianMode() throws {
74-
try XCTSkipIf(true && !runAll) // change true to false to run this test
76+
@Test("Phrygian mode", .enabled(if: RUNALL))
77+
func testPhrygianMode() {
7578
let scaleGenerator = ScaleGenerator(tonic: "e")
76-
XCTAssertEqual(scaleGenerator.interval("mMMMmMM"), ["E", "F", "G", "A", "B", "C", "D", "E"])
79+
#expect(scaleGenerator.interval("mMMMmMM") == ["E", "F", "G", "A", "B", "C", "D", "E"])
7780
}
7881

79-
func testLocrianMode() throws {
80-
try XCTSkipIf(true && !runAll) // change true to false to run this test
82+
@Test("Locrian mode", .enabled(if: RUNALL))
83+
func testLocrianMode() {
8184
let scaleGenerator = ScaleGenerator(tonic: "g")
82-
XCTAssertEqual(
83-
scaleGenerator.interval("mMMmMMM"), ["G", "Ab", "Bb", "C", "Db", "Eb", "F", "G"])
85+
#expect(scaleGenerator.interval("mMMmMMM") == ["G", "Ab", "Bb", "C", "Db", "Eb", "F", "G"])
8486
}
8587

86-
func testHarmonicMinor() throws {
87-
try XCTSkipIf(true && !runAll) // change true to false to run this test
88+
@Test("Harmonic minor", .enabled(if: RUNALL))
89+
func testHarmonicMinor() {
8890
let scaleGenerator = ScaleGenerator(tonic: "d")
89-
XCTAssertEqual(scaleGenerator.interval("MmMMmAm"), ["D", "E", "F", "G", "A", "Bb", "Db", "D"])
91+
#expect(scaleGenerator.interval("MmMMmAm") == ["D", "E", "F", "G", "A", "Bb", "Db", "D"])
9092
}
9193

92-
func testOctatonic() throws {
93-
try XCTSkipIf(true && !runAll) // change true to false to run this test
94+
@Test("Octatonic", .enabled(if: RUNALL))
95+
func testOctatonic() {
9496
let scaleGenerator = ScaleGenerator(tonic: "C")
95-
XCTAssertEqual(
96-
scaleGenerator.interval("MmMmMmMm"), ["C", "D", "D#", "F", "F#", "G#", "A", "B", "C"])
97+
#expect(
98+
scaleGenerator.interval("MmMmMmMm") == ["C", "D", "D#", "F", "F#", "G#", "A", "B", "C"])
9799
}
98100

99-
func testHexatonic() throws {
100-
try XCTSkipIf(true && !runAll) // change true to false to run this test
101+
@Test("Hexatonic", .enabled(if: RUNALL))
102+
func testHexatonic() {
101103
let scaleGenerator = ScaleGenerator(tonic: "Db")
102-
XCTAssertEqual(scaleGenerator.interval("MMMMMM"), ["Db", "Eb", "F", "G", "A", "B", "Db"])
104+
#expect(scaleGenerator.interval("MMMMMM") == ["Db", "Eb", "F", "G", "A", "B", "Db"])
103105
}
104106

105-
func testPentatonic() throws {
106-
try XCTSkipIf(true && !runAll) // change true to false to run this test
107+
@Test("Pentatonic", .enabled(if: RUNALL))
108+
func testPentatonic() {
107109
let scaleGenerator = ScaleGenerator(tonic: "A")
108-
XCTAssertEqual(scaleGenerator.interval("MMAMA"), ["A", "B", "C#", "E", "F#", "A"])
110+
#expect(scaleGenerator.interval("MMAMA") == ["A", "B", "C#", "E", "F#", "A"])
109111
}
110112

111-
func testEnigmatic() throws {
112-
try XCTSkipIf(true && !runAll) // change true to false to run this test
113+
@Test("Enigmatic", .enabled(if: RUNALL))
114+
func testEnigmatic() {
113115
let scaleGenerator = ScaleGenerator(tonic: "G")
114-
XCTAssertEqual(
115-
scaleGenerator.interval("mAMMMmm"), ["G", "G#", "B", "C#", "D#", "F", "F#", "G"])
116+
#expect(scaleGenerator.interval("mAMMMmm") == ["G", "G#", "B", "C#", "D#", "F", "F#", "G"])
116117
}
117118
}

0 commit comments

Comments
 (0)