Skip to content

Commit ebef35d

Browse files
committed
Improve naming in unit test
1 parent 58deb53 commit ebef35d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Tests/PropertyBasedTests/GenTests+Frequency.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import Testing
1111

1212
@Suite struct GenFrequencyTests {
1313
enum Choice: Hashable {
14-
case first
15-
case second(Int)
16-
case third(String)
14+
case plain
15+
case number(Int)
16+
case text(String)
1717
}
1818

1919
let gen = Gen.oneOf(
20-
Gen.always(Choice.first),
21-
Gen.int().map(Choice.second),
22-
Gen.lowercaseLetter.string(of: 8).map(Choice.third),
20+
Gen.always(Choice.plain),
21+
Gen.int().map(Choice.number),
22+
Gen.lowercaseLetter.string(of: 8).map(Choice.text),
2323
)
2424

2525
@Test func testGenerateEnum() async {
@@ -30,11 +30,11 @@ import Testing
3030
await confirmation(expectedCount: 1...) { confirm3 in
3131
await propertyCheck(count: 200, input: gen) { item in
3232
switch item {
33-
case .first:
33+
case .plain:
3434
confirm1()
35-
case .second:
35+
case .number:
3636
confirm2()
37-
case .third:
37+
case .text:
3838
confirm3()
3939
}
4040
}
@@ -44,11 +44,11 @@ import Testing
4444
}
4545

4646
@Test func testShrinkChoice() async throws {
47-
let value = (index: 1, value: 500)
48-
let results = Array(gen._shrinker(value))
47+
let value = (index: 1, value: 500 as Any)
48+
let results = gen._shrinker(value).compactMap(gen._mapFilter)
4949
try #require(results.count > 1)
50-
#expect(results.first?.value as? Int == 0)
51-
#expect(!results.contains { $0.value as? Int == 500 })
50+
#expect(results.first == .number(0))
51+
#expect(!results.contains(.number(500)))
5252
}
5353
}
5454
#endif // compiler(>=6.2)

0 commit comments

Comments
 (0)