Skip to content

Commit

Permalink
Update swift-clocks to v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DevYeom committed Jan 7, 2024
1 parent 35cbeb4 commit 9460b14
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] "
title: ''
labels: bug
assignees: DevYeom

Expand Down
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-clocks",
"state" : {
"revision" : "d1fd837326aa719bee979bdde1f53cd5797443eb",
"version" : "1.0.0"
"revision" : "a8421d68068d8f45fbceb418fbf22c5dad4afd33",
"version" : "1.0.2"
}
},
{
"identity" : "swift-concurrency-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "ea631ce892687f5432a833312292b80db238186a",
"version" : "1.0.0"
"revision" : "bb5059bde9022d69ac516803f4f227d8ac967f71",
"version" : "1.1.0"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion Tests/OneWayTests/EffectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import OneWay
import XCTest

@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
@MainActor
final class EffectTests: XCTestCase {
enum Action: Sendable {
case first
Expand Down
52 changes: 35 additions & 17 deletions Tests/OneWayTests/ViewStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,40 +45,58 @@ final class ViewStoreTests: XCTestCase {
}

func test_sensitiveState() async {
var counts: [Int] = []
var sensitiveCounts: [Int] = []
actor Result {
var counts: [Int] = []
var sensitiveCounts: [Int] = []
func appendCount(_ count: Int) {
counts.append(count)
}
func appendSensitiveCount(_ count: Int) {
sensitiveCounts.append(count)
}
}
let result = Result()

Task {
Task { @MainActor in
for await state in sut.states {
counts.append(state.count)
await result.appendCount(state.count)
}
}
Task {
Task { @MainActor in
for await sensitiveCount in sut.states.sensitiveCount {
sensitiveCounts.append(sensitiveCount)
await result.appendSensitiveCount(sensitiveCount)
}
}

sut.send(.setSensitiveCount(10))
sut.send(.setSensitiveCount(10))
sut.send(.setSensitiveCount(10))

await expect { counts == [0, 0, 0, 0] }
await expect { sensitiveCounts == [0, 10, 10, 10] }
await sendableExpect { await result.counts == [0, 0, 0, 0] }
await sendableExpect { await result.sensitiveCounts == [0, 10, 10, 10] }
}

func test_insensitiveState() async {
var counts: [Int] = []
var insensitiveCounts: [Int] = []
actor Result {
var counts: [Int] = []
var insensitiveCounts: [Int] = []
func appendCount(_ count: Int) {
counts.append(count)
}
func appendInsensitiveCount(_ count: Int) {
insensitiveCounts.append(count)
}
}
let result = Result()

Task {
Task { @MainActor in
for await state in sut.states {
counts.append(state.count)
await result.appendCount(state.count)
}
}
Task {
Task { @MainActor in
for await insensitiveCount in sut.states.insensitiveCount {
insensitiveCounts.append(insensitiveCount)
await result.appendInsensitiveCount(insensitiveCount)
}
}

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

// only initial value
await expect { counts == [0] }
await expect { insensitiveCounts == [0] }
await sendableExpect { await result.counts == [0] }
await sendableExpect { await result.insensitiveCounts == [0] }
}

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

let result = Result(expectation, expectedCount: 15)
Task {
Task { @MainActor in
await withTaskGroup(of: Void.self) { group in
group.addTask { await self.consumeAsyncViewStateSequence1(result) }
group.addTask { await self.consumeAsyncViewStateSequence2(result) }
Expand Down

0 comments on commit 9460b14

Please sign in to comment.