Skip to content

Commit 9d066f9

Browse files
committed
BigInt tests
1 parent 203844f commit 9d066f9

File tree

1 file changed

+31
-0
lines changed
  • IntegrationTests/TestSuites/Sources/PrimaryTests

1 file changed

+31
-0
lines changed

IntegrationTests/TestSuites/Sources/PrimaryTests/main.swift

+31
Original file line numberDiff line numberDiff line change
@@ -853,4 +853,35 @@ try test("JSValueDecoder") {
853853
}
854854

855855

856+
try test("BigInt") {
857+
func expectPassesThrough(signed value: Int64) throws {
858+
let bigInt = JSBigInt(value)
859+
try expectEqual(bigInt.description, value.description)
860+
}
861+
862+
func expectPassesThrough(unsigned value: UInt64) throws {
863+
let bigInt = JSBigInt(unsigned: value)
864+
try expectEqual(bigInt.description, value.description)
865+
}
866+
867+
try expectPassesThrough(signed: 0)
868+
try expectPassesThrough(signed: 1 << 62)
869+
try expectPassesThrough(signed: -2305)
870+
for _ in 0 ..< 100 {
871+
try expectPassesThrough(signed: .random(in: .min ... .max))
872+
}
873+
try expectPassesThrough(signed: .min)
874+
try expectPassesThrough(signed: .max)
875+
876+
try expectPassesThrough(unsigned: 0)
877+
try expectPassesThrough(unsigned: 1 << 62)
878+
try expectPassesThrough(unsigned: 1 << 63)
879+
try expectPassesThrough(unsigned: .min)
880+
try expectPassesThrough(unsigned: .max)
881+
try expectPassesThrough(unsigned: ~0)
882+
for _ in 0 ..< 100 {
883+
try expectPassesThrough(unsigned: .random(in: .min ... .max))
884+
}
885+
}
886+
856887
Expectation.wait(expectations)

0 commit comments

Comments
 (0)