Files
wehub-resource-sync e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:29:30 +08:00

124 lines
3.9 KiB
Plaintext

pub fn main(world: World) -> Void raises {
var ok: Bool = true
let duration: Duration = std.time.add(std.time.us(2500_i64), std.time.ms(1))
let window: Duration = std.time.add(std.time.minutes(1), std.time.seconds(30))
let clamped: Duration = std.time.clamp(std.time.seconds(3), std.time.seconds(1), std.time.seconds(2))
if std.time.asNs(std.time.ns(42_i64)) != 42_i64 {
ok = false
}
if std.time.asUsFloor(std.time.ns(1999_i64)) != 1_i64 {
ok = false
}
if std.time.asMsFloor(duration) != 3 {
ok = false
}
if std.time.asSecondsFloor(window) != 90_i64 {
ok = false
}
if std.time.asSecondsFloor(clamped) != 2_i64 {
ok = false
}
let negative_tick: Duration = std.time.sub(std.time.zero(), std.time.ns(1_i64))
if std.time.asUsFloor(negative_tick) != 0_i64 - 1_i64 {
ok = false
}
if std.time.asMsFloor(negative_tick) != 0 - 1 {
ok = false
}
if std.time.asSecondsFloor(negative_tick) != 0_i64 - 1_i64 {
ok = false
}
if !std.time.lessThan(std.time.zero(), duration) {
ok = false
}
if !std.time.isZero(std.time.zero()) {
ok = false
}
if std.time.asNs(std.time.abs(negative_tick)) != 1_i64 {
ok = false
}
if std.time.asSecondsFloor(std.time.between(std.time.seconds(5), std.time.seconds(2))) != 3_i64 {
ok = false
}
if !std.time.hasElapsed(std.time.seconds(10), std.time.seconds(13), std.time.seconds(3)) {
ok = false
}
if std.time.hasElapsed(std.time.seconds(10), std.time.seconds(12), std.time.seconds(3)) {
ok = false
}
var rng: RandSource = std.rand.seed(7_u32)
let first: u32 = std.rand.nextU32(&mut rng)
let bit: Bool = std.rand.nextBool(&mut rng)
let third: u32 = std.rand.nextU32(&mut rng)
if first != 1025555898_u32 || !bit || third != 2630631676_u32 {
ok = false
}
var bool_rng: RandSource = std.rand.seed(7_u32)
let bit_one: Bool = std.rand.nextBool(&mut bool_rng)
let bit_two: Bool = std.rand.nextBool(&mut bool_rng)
let bit_three: Bool = std.rand.nextBool(&mut bool_rng)
if bit_one || !bit_two || !bit_three {
ok = false
}
var bounded_rng: RandSource = std.rand.seed(99_u32)
let below_ten: Maybe<u32> = std.rand.nextBelow(&mut bounded_rng, 10_u32)
if below_ten.has {
if below_ten.value >= 10_u32 {
ok = false
}
} else {
ok = false
}
let in_range: Maybe<u32> = std.rand.rangeU32(&mut bounded_rng, 40_u32, 50_u32)
if in_range.has {
if in_range.value < 40_u32 || in_range.value >= 50_u32 {
ok = false
}
} else {
ok = false
}
let empty_below: Maybe<u32> = std.rand.nextBelow(&mut bounded_rng, 0_u32)
let empty_range: Maybe<u32> = std.rand.rangeU32(&mut bounded_rng, 4_u32, 4_u32)
if empty_below.has || empty_range.has {
ok = false
}
let factorial: Maybe<u32> = std.math.factorialU32(5_u32)
if factorial.has {
if factorial.value != 120_u32 {
ok = false
}
} else {
ok = false
}
let binomial: Maybe<u32> = std.math.binomialU32(6_u32, 2_u32)
if binomial.has {
if binomial.value != 15_u32 {
ok = false
}
} else {
ok = false
}
let larger_binomial: Maybe<u32> = std.math.binomialU32(31_u32, 15_u32)
if larger_binomial.has {
if larger_binomial.value != 300540195_u32 {
ok = false
}
} else {
ok = false
}
let checked: Maybe<u32> = std.math.checkedPowU32(2_u32, 10_u32)
if checked.has {
if checked.value != 1024_u32 {
ok = false
}
} else {
ok = false
}
if std.math.sqrtFloorU32(99) != 9 || std.math.saturatingAddU32(4294967295_u32, 1_u32) != 4294967295_u32 {
ok = false
}
if ok {
check world.out.write("std numeric random time ok\n")
}
}