|
1 |
| -import XCTest |
| 1 | +import Foundation |
| 2 | +import Testing |
2 | 3 |
|
3 | 4 | @testable import ScaleGenerator
|
4 | 5 |
|
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 |
7 | 7 |
|
| 8 | +@Suite struct ScaleGeneratorTests { |
| 9 | + |
| 10 | + @Test("Chromatic scale with sharps") |
8 | 11 | func testChromaticScaleWithSharps() {
|
9 | 12 | 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 | + ]) |
12 | 17 | }
|
13 | 18 |
|
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() { |
16 | 21 | 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 | + ]) |
19 | 26 | }
|
20 | 27 |
|
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() { |
23 | 30 | 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"]) |
25 | 32 | }
|
26 | 33 |
|
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() { |
29 | 36 | 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"]) |
31 | 38 | }
|
32 | 39 |
|
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() { |
35 | 42 | 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"]) |
37 | 44 | }
|
38 | 45 |
|
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() { |
41 | 48 | 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#"]) |
44 | 50 | }
|
45 | 51 |
|
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() { |
48 | 54 | 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"]) |
51 | 56 | }
|
52 | 57 |
|
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() { |
55 | 60 | 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"]) |
57 | 62 | }
|
58 | 63 |
|
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() { |
61 | 66 | 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"]) |
64 | 68 | }
|
65 | 69 |
|
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() { |
68 | 72 | 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"]) |
71 | 74 | }
|
72 | 75 |
|
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() { |
75 | 78 | 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"]) |
77 | 80 | }
|
78 | 81 |
|
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() { |
81 | 84 | 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"]) |
84 | 86 | }
|
85 | 87 |
|
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() { |
88 | 90 | 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"]) |
90 | 92 | }
|
91 | 93 |
|
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() { |
94 | 96 | 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"]) |
97 | 99 | }
|
98 | 100 |
|
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() { |
101 | 103 | 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"]) |
103 | 105 | }
|
104 | 106 |
|
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() { |
107 | 109 | 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"]) |
109 | 111 | }
|
110 | 112 |
|
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() { |
113 | 115 | 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"]) |
116 | 117 | }
|
117 | 118 | }
|
0 commit comments