Skip to content

Commit b151fb8

Browse files
Add construction test cases
1 parent 0323f8f commit b151fb8

File tree

1 file changed

+13
-1
lines changed
  • IntegrationTests/JavaScriptKitExec/Sources/JavaScriptKitExec

1 file changed

+13
-1
lines changed

Diff for: IntegrationTests/JavaScriptKitExec/Sources/JavaScriptKitExec/main.swift

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@ Literal_Conversion: do {
1010
.number(0),
1111
.number(Double(Int32.max)),
1212
.number(Double(Int32.min)),
13+
.number(Double.infinity),
14+
.number(Double.nan),
1315
.null,
1416
.undefined,
1517
]
1618
for (index, input) in inputs.enumerated() {
1719
let prop = "prop_\(index)"
1820
setJSValue(this: global, name: prop, value: input)
1921
let got = getJSValue(this: global, name: prop)
20-
try expectEqual(got, input)
22+
switch (got, input) {
23+
case let (.number(lhs), .number(rhs)):
24+
// Compare bitPattern because nan == nan is always false
25+
try expectEqual(lhs.bitPattern, rhs.bitPattern)
26+
default:
27+
try expectEqual(got, input)
28+
}
2129
}
2230
} catch {
2331
print(error)
@@ -70,6 +78,10 @@ Object_Conversion: do {
7078
Value_Construction: do {
7179
let globalObject1 = getJSValue(this: .global, name: "globalObject1")
7280
let globalObject1Ref = try expectObject(globalObject1)
81+
let prop_2 = getJSValue(this: globalObject1Ref, name: "prop_2")
82+
try expectEqual(Int.construct(from: prop_2), 2)
83+
let prop_3 = getJSValue(this: globalObject1Ref, name: "prop_3")
84+
try expectEqual(Bool.construct(from: prop_3), true)
7385
let prop_7 = getJSValue(this: globalObject1Ref, name: "prop_7")
7486
try expectEqual(Double.construct(from: prop_7), 3.14)
7587
try expectEqual(Float.construct(from: prop_7), 3.14)

0 commit comments

Comments
 (0)