Skip to content

Commit adbed6f

Browse files
Migrate BigInt support tests to XCTest
1 parent 53ad139 commit adbed6f

File tree

4 files changed

+54
-40
lines changed

4 files changed

+54
-40
lines changed

Diff for: IntegrationTests/TestSuites/Sources/PrimaryTests/I64.swift

-39
This file was deleted.

Diff for: IntegrationTests/TestSuites/Sources/PrimaryTests/main.swift

-1
Original file line numberDiff line numberDiff line change
@@ -914,5 +914,4 @@ try test("JSValueDecoder") {
914914
try expectEqual(decodedTama.isCat, true)
915915
}
916916

917-
try testI64()
918917
Expectation.wait(expectations)

Diff for: Package.swift

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ let package = Package(
4242
dependencies: ["_CJavaScriptBigIntSupport", "JavaScriptKit"]
4343
),
4444
.target(name: "_CJavaScriptBigIntSupport", dependencies: ["_CJavaScriptKit"]),
45+
.testTarget(
46+
name: "JavaScriptBigIntSupportTests",
47+
dependencies: ["JavaScriptBigIntSupport", "JavaScriptKit"]
48+
),
4549

4650
.target(
4751
name: "JavaScriptEventLoop",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import XCTest
2+
import JavaScriptBigIntSupport
3+
import JavaScriptKit
4+
5+
class JavaScriptBigIntSupportTests: XCTestCase {
6+
func testBigIntSupport() {
7+
// Test signed values
8+
func testSignedValue(_ value: Int64, file: StaticString = #filePath, line: UInt = #line) {
9+
let bigInt = JSBigInt(value)
10+
XCTAssertEqual(bigInt.description, value.description, file: file, line: line)
11+
let bigInt2 = JSBigInt(_slowBridge: value)
12+
XCTAssertEqual(bigInt2.description, value.description, file: file, line: line)
13+
}
14+
15+
// Test unsigned values
16+
func testUnsignedValue(_ value: UInt64, file: StaticString = #filePath, line: UInt = #line) {
17+
let bigInt = JSBigInt(unsigned: value)
18+
XCTAssertEqual(bigInt.description, value.description, file: file, line: line)
19+
let bigInt2 = JSBigInt(_slowBridge: value)
20+
XCTAssertEqual(bigInt2.description, value.description, file: file, line: line)
21+
}
22+
23+
// Test specific signed values
24+
testSignedValue(0)
25+
testSignedValue(1 << 62)
26+
testSignedValue(-2305)
27+
28+
// Test random signed values
29+
for _ in 0..<100 {
30+
testSignedValue(.random(in: .min ... .max))
31+
}
32+
33+
// Test edge signed values
34+
testSignedValue(.min)
35+
testSignedValue(.max)
36+
37+
// Test specific unsigned values
38+
testUnsignedValue(0)
39+
testUnsignedValue(1 << 62)
40+
testUnsignedValue(1 << 63)
41+
testUnsignedValue(.min)
42+
testUnsignedValue(.max)
43+
testUnsignedValue(~0)
44+
45+
// Test random unsigned values
46+
for _ in 0..<100 {
47+
testUnsignedValue(.random(in: .min ... .max))
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)