Skip to content

Commit 484c784

Browse files
committed
BigInt tests
1 parent 59d0a67 commit 484c784

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,4 +830,35 @@ try test("Symbols") {
830830
try expectEqual(JSObject.global.Object.isInstanceOf(hasInstanceClass), true)
831831
}
832832

833+
try test("BigInt") {
834+
func expectPassesThrough(signed value: Int64) throws {
835+
let bigInt = JSBigInt(value)
836+
try expectEqual(bigInt.description, value.description)
837+
}
838+
839+
func expectPassesThrough(unsigned value: UInt64) throws {
840+
let bigInt = JSBigInt(unsigned: value)
841+
try expectEqual(bigInt.description, value.description)
842+
}
843+
844+
try expectPassesThrough(signed: 0)
845+
try expectPassesThrough(signed: 1 << 62)
846+
try expectPassesThrough(signed: -2305)
847+
for _ in 0 ..< 100 {
848+
try expectPassesThrough(signed: .random(in: .min ... .max))
849+
}
850+
try expectPassesThrough(signed: .min)
851+
try expectPassesThrough(signed: .max)
852+
853+
try expectPassesThrough(unsigned: 0)
854+
try expectPassesThrough(unsigned: 1 << 62)
855+
try expectPassesThrough(unsigned: 1 << 63)
856+
try expectPassesThrough(unsigned: .min)
857+
try expectPassesThrough(unsigned: .max)
858+
try expectPassesThrough(unsigned: ~0)
859+
for _ in 0 ..< 100 {
860+
try expectPassesThrough(unsigned: .random(in: .min ... .max))
861+
}
862+
}
863+
833864
Expectation.wait(expectations)

0 commit comments

Comments
 (0)