Skip to content

Fix GraphHost/setTime(_ time:) guard should be not equal. #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/Core/Graph/GraphHost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class GraphHost {
final var graphInputs: _GraphInputs { data.inputs }

final func setTime(_ time: Time) {
guard data.time == time else {
guard data.time != time else {
return
}
data.time = time
Expand Down
24 changes: 24 additions & 0 deletions Tests/OpenSwiftUITests/Core/Graph/GraphHostTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// GraphHostTests.swift
// OpenSwiftUITests

@testable import OpenSwiftUI
import Testing

struct GraphHostTests {
@Test
func setTimeTest() {
let graphHost = GraphHost(data: .init())
#expect(graphHost.data.time.seconds == 0.0)

graphHost.setTime(Time.zero)
#expect(graphHost.data.time.seconds == 0.0)

graphHost.setTime(Time.infinity)
#expect(graphHost.data.time.seconds == Time.infinity.seconds)

let timeNow = Time.now
graphHost.setTime(timeNow)
#expect(graphHost.data.time.seconds == timeNow.seconds)
}
}