-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathImportAPITests.swift
More file actions
37 lines (32 loc) · 973 Bytes
/
ImportAPITests.swift
File metadata and controls
37 lines (32 loc) · 973 Bytes
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
import XCTest
import JavaScriptKit
class ImportAPITests: XCTestCase {
func testRoundTripVoid() {
jsRoundTripVoid()
}
func testRoundTripNumber() {
for v in [
0, 1, -1,
Double(Int32.max), Double(Int32.min),
Double(Int64.max), Double(Int64.min),
Double(UInt32.max), Double(UInt32.min),
Double(UInt64.max), Double(UInt64.min),
Double.greatestFiniteMagnitude, Double.leastNonzeroMagnitude,
Double.infinity,
Double.pi,
] {
XCTAssertEqual(jsRoundTripNumber(v), v)
}
XCTAssert(jsRoundTripNumber(Double.nan).isNaN)
}
func testRoundTripBool() {
for v in [true, false] {
XCTAssertEqual(jsRoundTripBool(v), v)
}
}
func testRoundTripString() {
for v in ["", "Hello, world!", "🧑🧑🧒"] {
XCTAssertEqual(jsRoundTripString(v), v)
}
}
}