-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathI64.swift
39 lines (35 loc) · 1.44 KB
/
I64.swift
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
import JavaScriptBigIntSupport
import JavaScriptKit
func testI64() throws {
try test("BigInt") {
func expectPassesThrough(signed value: Int64) throws {
let bigInt = JSBigInt(value)
try expectEqual(bigInt.description, value.description)
let bigInt2 = JSBigInt(_slowBridge: value)
try expectEqual(bigInt2.description, value.description)
}
func expectPassesThrough(unsigned value: UInt64) throws {
let bigInt = JSBigInt(unsigned: value)
try expectEqual(bigInt.description, value.description)
let bigInt2 = JSBigInt(_slowBridge: value)
try expectEqual(bigInt2.description, value.description)
}
try expectPassesThrough(signed: 0)
try expectPassesThrough(signed: 1 << 62)
try expectPassesThrough(signed: -2305)
for _ in 0 ..< 100 {
try expectPassesThrough(signed: .random(in: .min ... .max))
}
try expectPassesThrough(signed: .min)
try expectPassesThrough(signed: .max)
try expectPassesThrough(unsigned: 0)
try expectPassesThrough(unsigned: 1 << 62)
try expectPassesThrough(unsigned: 1 << 63)
try expectPassesThrough(unsigned: .min)
try expectPassesThrough(unsigned: .max)
try expectPassesThrough(unsigned: ~0)
for _ in 0 ..< 100 {
try expectPassesThrough(unsigned: .random(in: .min ... .max))
}
}
}