Skip to content

Commit

Permalink
BigInt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Apr 9, 2022
1 parent 59d0a67 commit 484c784
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions IntegrationTests/TestSuites/Sources/PrimaryTests/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -830,4 +830,35 @@ try test("Symbols") {
try expectEqual(JSObject.global.Object.isInstanceOf(hasInstanceClass), true)
}

try test("BigInt") {
func expectPassesThrough(signed value: Int64) throws {
let bigInt = JSBigInt(value)
try expectEqual(bigInt.description, value.description)
}

func expectPassesThrough(unsigned value: UInt64) throws {
let bigInt = JSBigInt(unsigned: value)
try expectEqual(bigInt.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))
}
}

Expectation.wait(expectations)

0 comments on commit 484c784

Please sign in to comment.