-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
wasi.time.test.gr
46 lines (37 loc) 路 1.15 KB
/
wasi.time.test.gr
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
module TimeTest
from "int64" include Int64
use Int64.{ (<), (<=) }
from "wasi/time" include Time
let mt1 = Time.monotonicTime()
let mt2 = Time.monotonicTime()
// Just a smoke test, there's a chance this could fail
match ((mt1, mt2)) {
(Ok(x), Ok(y)) => assert x < y,
(Err(err), _) => throw err,
(_, Err(err)) => throw err,
}
let pct1 = Time.processCpuTime()
let pct2 = Time.processCpuTime()
// Just a smoke test, there's a chance this could fail
// This is using `<=` because time resolutions on Windows is not fine-grained enough
match ((pct1, pct2)) {
(Ok(x), Ok(y)) => assert x <= y,
(Err(err), _) => throw err,
(_, Err(err)) => throw err,
}
let tct1 = Time.threadCpuTime()
let tct2 = Time.threadCpuTime()
// Just a smoke test, there's a chance this could fail
// This is using `<=` because time resolutions on Windows is not fine-grained enough
match ((tct1, tct2)) {
(Ok(x), Ok(y)) => assert x <= y,
(Err(err), _) => throw err,
(_, Err(err)) => throw err,
}
let epoch = 0L
let rt = Time.realTime()
// Just a smoke test, there's a chance this could fail if system dates are bad
match (rt) {
Ok(now) => assert epoch < now,
Err(err) => throw err,
}