Skip to content

Commit 3da71ee

Browse files
authored
Update swift-clocks to v1.0.2 (#66)
1 parent 35cbeb4 commit 3da71ee

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
title: "[BUG] "
4+
title: ''
55
labels: bug
66
assignees: DevYeom
77

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/OneWayTests/EffectTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import OneWay
1010
import XCTest
1111

1212
@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
13-
@MainActor
1413
final class EffectTests: XCTestCase {
1514
enum Action: Sendable {
1615
case first

Tests/OneWayTests/ViewStoreTests.swift

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,58 @@ final class ViewStoreTests: XCTestCase {
4545
}
4646

4747
func test_sensitiveState() async {
48-
var counts: [Int] = []
49-
var sensitiveCounts: [Int] = []
48+
actor Result {
49+
var counts: [Int] = []
50+
var sensitiveCounts: [Int] = []
51+
func appendCount(_ count: Int) {
52+
counts.append(count)
53+
}
54+
func appendSensitiveCount(_ count: Int) {
55+
sensitiveCounts.append(count)
56+
}
57+
}
58+
let result = Result()
5059

51-
Task {
60+
Task { @MainActor in
5261
for await state in sut.states {
53-
counts.append(state.count)
62+
await result.appendCount(state.count)
5463
}
5564
}
56-
Task {
65+
Task { @MainActor in
5766
for await sensitiveCount in sut.states.sensitiveCount {
58-
sensitiveCounts.append(sensitiveCount)
67+
await result.appendSensitiveCount(sensitiveCount)
5968
}
6069
}
6170

6271
sut.send(.setSensitiveCount(10))
6372
sut.send(.setSensitiveCount(10))
6473
sut.send(.setSensitiveCount(10))
6574

66-
await expect { counts == [0, 0, 0, 0] }
67-
await expect { sensitiveCounts == [0, 10, 10, 10] }
75+
await sendableExpect { await result.counts == [0, 0, 0, 0] }
76+
await sendableExpect { await result.sensitiveCounts == [0, 10, 10, 10] }
6877
}
6978

7079
func test_insensitiveState() async {
71-
var counts: [Int] = []
72-
var insensitiveCounts: [Int] = []
80+
actor Result {
81+
var counts: [Int] = []
82+
var insensitiveCounts: [Int] = []
83+
func appendCount(_ count: Int) {
84+
counts.append(count)
85+
}
86+
func appendInsensitiveCount(_ count: Int) {
87+
insensitiveCounts.append(count)
88+
}
89+
}
90+
let result = Result()
7391

74-
Task {
92+
Task { @MainActor in
7593
for await state in sut.states {
76-
counts.append(state.count)
94+
await result.appendCount(state.count)
7795
}
7896
}
79-
Task {
97+
Task { @MainActor in
8098
for await insensitiveCount in sut.states.insensitiveCount {
81-
insensitiveCounts.append(insensitiveCount)
99+
await result.appendInsensitiveCount(insensitiveCount)
82100
}
83101
}
84102

@@ -87,8 +105,8 @@ final class ViewStoreTests: XCTestCase {
87105
sut.send(.setInsensitiveCount(30))
88106

89107
// only initial value
90-
await expect { counts == [0] }
91-
await expect { insensitiveCounts == [0] }
108+
await sendableExpect { await result.counts == [0] }
109+
await sendableExpect { await result.insensitiveCounts == [0] }
92110
}
93111

94112
func test_asyncViewStateSequence() async {
@@ -107,7 +125,7 @@ final class ViewStoreTests: XCTestCase {
107125
let expectation = expectation(description: #function)
108126

109127
let result = Result(expectation, expectedCount: 15)
110-
Task {
128+
Task { @MainActor in
111129
await withTaskGroup(of: Void.self) { group in
112130
group.addTask { await self.consumeAsyncViewStateSequence1(result) }
113131
group.addTask { await self.consumeAsyncViewStateSequence2(result) }

0 commit comments

Comments
 (0)