Skip to content

Commit e449dd2

Browse files
authored
Fix GraphHost/setTime(_ time:) guard should be not equal. (#74)
* Fix GraphHost/setTime(_ time:) guard should be not equal. * Add tests for GraphHost/setTime(_:) * Fix GraphHostTests/setTime(_:) on Ubuntu * Fix GraphHostTests on Ubuntu
1 parent 3f405bf commit e449dd2

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Sources/OpenSwiftUI/Core/Graph/GraphHost.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class GraphHost {
118118
final var graphInputs: _GraphInputs { data.inputs }
119119

120120
final func setTime(_ time: Time) {
121-
guard data.time == time else {
121+
guard data.time != time else {
122122
return
123123
}
124124
data.time = time
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// GraphHostTests.swift
3+
// OpenSwiftUITests
4+
5+
@testable import OpenSwiftUI
6+
import Testing
7+
8+
struct GraphHostTests {
9+
@Test
10+
func setTimeTest() {
11+
#if canImport(Darwin)
12+
let graphHost = GraphHost(data: .init())
13+
#expect(graphHost.data.time.seconds == 0.0)
14+
15+
graphHost.setTime(Time.zero)
16+
#expect(graphHost.data.time.seconds == 0.0)
17+
18+
graphHost.setTime(Time.infinity)
19+
#expect(graphHost.data.time.seconds == Time.infinity.seconds)
20+
21+
let timeNow = Time.now
22+
graphHost.setTime(timeNow)
23+
#expect(graphHost.data.time.seconds == timeNow.seconds)
24+
#endif
25+
}
26+
}
27+

0 commit comments

Comments
 (0)