File tree Expand file tree Collapse file tree 2 files changed +25
-9
lines changed
Tests/EnumeratorMacroTests Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change 16
16
- swift:6.0-noble
17
17
- swiftlang/swift:nightly-main-jammy
18
18
config :
19
- - args : " --enable-code-coverage"
19
+ - mode : " debug"
20
+ args : " --enable-code-coverage"
20
21
with_codecov : true
21
- - args : " -c release -Xswiftc -enable-testing"
22
+ - mode : " release"
23
+ args : " -c release -Xswiftc -enable-testing"
22
24
with_codecov : false
23
25
24
26
runs-on : ubuntu-latest
37
39
with :
38
40
path : .build
39
41
# e.g. 'enumerator-macro-debug-build-swiftlang/swift:nightly-6.0-jammy-Linux-c7008df8062ac4d5887ead9e59aa05829e'
40
- key : " ${{ github.event.repository.name }}-debug -build-${{ matrix.swift-image }}-${{ runner.os }}-${{ hashFiles('./Package.resolved') }}"
41
- restore-keys : " ${{ github.event.repository.name }}-debug -build-${{ matrix.swift-image }}-${{ runner.os }}-"
42
+ key : " ${{ github.event.repository.name }}-${{ matrix.config.mode }} -build-${{ matrix.swift-image }}-${{ runner.os }}-${{ hashFiles('./Package.resolved') }}"
43
+ restore-keys : " ${{ github.event.repository.name }}-${{ matrix.config.mode }} -build-${{ matrix.swift-image }}-${{ runner.os }}-"
42
44
43
45
- name : Build ${{ github.event.repository.name }}
44
46
run : swift build --build-tests
48
50
uses : actions/cache/save@v4
49
51
with :
50
52
path : .build
51
- key : " ${{ github.event.repository.name }}-debug -build-${{ matrix.swift-image }}-${{ runner.os }}-${{ hashFiles('./Package.resolved') }}"
53
+ key : " ${{ github.event.repository.name }}-${{ matrix.config.mode }} -build-${{ matrix.swift-image }}-${{ runner.os }}-${{ hashFiles('./Package.resolved') }}"
52
54
53
55
- name : Run tests
54
56
run : swift test ${{ matrix.config.args }} --parallel
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ final class EnumeratorMacroTests: XCTestCase {
69
69
enum TestEnum {
70
70
case aBcD
71
71
case eFgH
72
-
72
+
73
73
var caseCode: Int {
74
74
switch self {
75
75
case .aBcD:
@@ -108,7 +108,7 @@ final class EnumeratorMacroTests: XCTestCase {
108
108
enum TestEnum {
109
109
case aBcD
110
110
case eFgH
111
-
111
+
112
112
var caseCode: Int {
113
113
switch self {
114
114
case .aBcD:
@@ -273,7 +273,7 @@ final class EnumeratorMacroTests: XCTestCase {
273
273
assertMacroExpansion (
274
274
#"""
275
275
@Enumerator("""
276
- {{#cases}}
276
+ {{#cases}}
277
277
{{^isEmpty(parameters)}}
278
278
func get{{capitalized(name)}}() -> ({{joined(tupleValue(parameters))}})? {
279
279
switch self {
@@ -283,7 +283,7 @@ final class EnumeratorMacroTests: XCTestCase {
283
283
return nil
284
284
}
285
285
}
286
- {{/isEmpty(parameters)}}
286
+ {{/isEmpty(parameters)}}
287
287
{{/cases}}
288
288
""")
289
289
enum TestEnum {
@@ -1230,6 +1230,10 @@ final class EnumeratorMacroTests: XCTestCase {
1230
1230
)
1231
1231
}
1232
1232
1233
+ func testRealEnumGeneratesCode( ) throws {
1234
+ XCTAssertEqual ( TestEnum . b. caseName, " b " )
1235
+ }
1236
+
1233
1237
/// FixItApplier not available in older versions of SwiftSyntax.
1234
1238
#if canImport(SwiftSyntax600)
1235
1239
/// Test name is referenced in the README.
@@ -1285,6 +1289,16 @@ var isTestCase2: Bool {
1285
1289
}
1286
1290
}
1287
1291
""" )
1292
+ @Enumerator ( """
1293
+ var caseName: Bool {
1294
+ switch self {
1295
+ {{#cases}}
1296
+ case .{{name}}:
1297
+ return " {{name}} "
1298
+ {{/cases}}
1299
+ }
1300
+ }
1301
+ """ )
1288
1302
enum TestEnum {
1289
1303
case a( val1: String , val2: Int )
1290
1304
case b
You can’t perform that action at this time.
0 commit comments