GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaScriptKit/Tests/JavaScriptEventLoopTests/JSTimerTests.swift at main · t089/JavaScriptKit Expand file tree/ Copy pathJSTimerTests.swiftMore file actions 55 lines (47 loc) · 1.7 KB / Copy pathJSTimerTests.swiftFile metadata and controls55 lines (47 loc) · 1.7 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 import XCTest @testable import JavaScriptKit final class JSTimerTests: XCTestCase { func testOneshotTimerCancelled() { let timeoutMilliseconds = 5.0 var timeout: JSTimer! timeout = JSTimer(millisecondsDelay: timeoutMilliseconds, isRepeating: false) { XCTFail("timer should be cancelled") } _ = timeout timeout = nil } func testRepeatingTimerCancelled() async throws { var count = 0.0 let maxCount = 5.0 var interval: JSTimer? let start = JSDate().valueOf() let timeoutMilliseconds = 5.0 await withCheckedContinuation { continuation in interval = JSTimer(millisecondsDelay: 5, isRepeating: true) { // ensure that JSTimer is living XCTAssertNotNil(interval) // verify that at least `timeoutMilliseconds * count` passed since the `timeout` // timer started XCTAssertTrue(start + timeoutMilliseconds * count <= JSDate().valueOf()) guard count < maxCount else { // stop the timer after `maxCount` reached interval = nil continuation.resume() return } count += 1 } } withExtendedLifetime(interval) {} } func testTimer() async throws { let timeoutMilliseconds = 5.0 var timeout: JSTimer! await withCheckedContinuation { continuation in timeout = JSTimer(millisecondsDelay: timeoutMilliseconds, isRepeating: false) { continuation.resume() } } withExtendedLifetime(timeout) {} } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |