apple / swift-async-algorithms

Async Algorithms for Swift
Apache License 2.0
3.06k stars 151 forks source link

Debounce behaving weirdly in proposed unit test #299

Open pyrtsa opened 1 year ago

pyrtsa commented 1 year ago

I'd like to propose this additional unit test for debounce, which I think should be fixed before the final 1.0.0 release:

  func test_debounce() throws {
    guard #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) else { throw XCTSkip("Skipped due to Clock/Instant/Duration availability") }
    validate {
      "ab--cd-e-f---gh|"
      $0.inputs[0].debounce(for: .steps(3), clock: $0.clock)
      "------------f--[h|]"
    }
  }

The test currently fails as:

failed - Validation failure:
Expected:
------------f--[h|]
Actual:
----b-------c--[dh|]

That actual output can't possibly be right, can it?

Side note, if it helps to debug this… Curiously, the test passes if _only slightly_ tweaking the **input**: ```diff -"ab--cd-e-f---gh|" +"ab-c-d-e-f---gh|" ```