1
1
import JavaScriptKit
2
2
3
- test ( " Literal Conversion " ) {
3
+ try test ( " Literal Conversion " ) {
4
4
let global = JSObject . global
5
5
let inputs : [ JSValue ] = [
6
6
. boolean( true ) ,
@@ -29,7 +29,7 @@ test("Literal Conversion") {
29
29
}
30
30
}
31
31
32
- test ( " Object Conversion " ) {
32
+ try test ( " Object Conversion " ) {
33
33
// Notes: globalObject1 is defined in JavaScript environment
34
34
//
35
35
// ```js
@@ -70,7 +70,7 @@ test("Object Conversion") {
70
70
try expectEqual ( getJSValue ( this: globalObject1Ref, name: " undefined_prop " ) , . undefined)
71
71
}
72
72
73
- test ( " Value Construction " ) {
73
+ try test ( " Value Construction " ) {
74
74
let globalObject1 = getJSValue ( this: . global, name: " globalObject1 " )
75
75
let globalObject1Ref = try expectObject ( globalObject1)
76
76
let prop_2 = getJSValue ( this: globalObject1Ref, name: " prop_2 " )
@@ -82,7 +82,7 @@ test("Value Construction") {
82
82
try expectEqual ( Float . construct ( from: prop_7) , 3.14 )
83
83
}
84
84
85
- test ( " Array Iterator " ) {
85
+ try test ( " Array Iterator " ) {
86
86
let globalObject1 = getJSValue ( this: . global, name: " globalObject1 " )
87
87
let globalObject1Ref = try expectObject ( globalObject1)
88
88
let prop_4 = getJSValue ( this: globalObject1Ref, name: " prop_4 " )
@@ -93,7 +93,7 @@ test("Array Iterator") {
93
93
try expectEqual ( Array ( array) , expectedProp_4)
94
94
}
95
95
96
- test ( " Array RandomAccessCollection " ) {
96
+ try test ( " Array RandomAccessCollection " ) {
97
97
let globalObject1 = getJSValue ( this: . global, name: " globalObject1 " )
98
98
let globalObject1Ref = try expectObject ( globalObject1)
99
99
let prop_4 = getJSValue ( this: globalObject1Ref, name: " prop_4 " )
@@ -104,7 +104,7 @@ test("Array RandomAccessCollection") {
104
104
try expectEqual ( [ array [ 0 ] , array [ 1 ] , array [ 2 ] , array [ 3 ] ] , expectedProp_4)
105
105
}
106
106
107
- test ( " Value Decoder " ) {
107
+ try test ( " Value Decoder " ) {
108
108
struct GlobalObject1 : Codable {
109
109
struct Prop1 : Codable {
110
110
let nested_prop : Int
@@ -124,7 +124,7 @@ test("Value Decoder") {
124
124
try expectEqual ( globalObject1. prop_7, 3.14 )
125
125
}
126
126
127
- test ( " Function Call " ) {
127
+ try test ( " Function Call " ) {
128
128
// Notes: globalObject1 is defined in JavaScript environment
129
129
//
130
130
// ```js
@@ -168,7 +168,7 @@ test("Function Call") {
168
168
try expectEqual ( func6 ( true , " OK " , 2 ) , . string( " OK " ) )
169
169
}
170
170
171
- test ( " Host Function Registration " ) {
171
+ try test ( " Host Function Registration " ) {
172
172
// ```js
173
173
// global.globalObject1 = {
174
174
// ...
@@ -213,7 +213,7 @@ test("Host Function Registration") {
213
213
hostFunc2. release ( )
214
214
}
215
215
216
- test ( " New Object Construction " ) {
216
+ try test ( " New Object Construction " ) {
217
217
// ```js
218
218
// global.Animal = function(name, age, isCat) {
219
219
// this.name = name
@@ -237,7 +237,7 @@ test("New Object Construction") {
237
237
try expectEqual ( dog1Bark ( ) , . string( " wan " ) )
238
238
}
239
239
240
- test ( " Call Function With This " ) {
240
+ try test ( " Call Function With This " ) {
241
241
// ```js
242
242
// global.Animal = function(name, age, isCat) {
243
243
// this.name = name
@@ -263,7 +263,7 @@ test("Call Function With This") {
263
263
try expectEqual ( gotIsCat, . boolean( true ) )
264
264
}
265
265
266
- test ( " Object Conversion " ) {
266
+ try test ( " Object Conversion " ) {
267
267
let array1 = [ 1 , 2 , 3 ]
268
268
let jsArray1 = array1. jsValue ( ) . object!
269
269
try expectEqual ( jsArray1. length, . number( 3 ) )
@@ -292,7 +292,7 @@ test("Object Conversion") {
292
292
try expectEqual ( jsDict1. prop2, . string( " foo " ) )
293
293
}
294
294
295
- test ( " ObjectRef Lifetime " ) {
295
+ try test ( " ObjectRef Lifetime " ) {
296
296
// ```js
297
297
// global.globalObject1 = {
298
298
// "prop_1": {
@@ -322,7 +322,7 @@ func closureScope() -> ObjectIdentifier {
322
322
return result
323
323
}
324
324
325
- test ( " Closure Identifiers " ) {
325
+ try test ( " Closure Identifiers " ) {
326
326
let oid1 = closureScope ( )
327
327
let oid2 = closureScope ( )
328
328
try expectEqual ( oid1, oid2)
0 commit comments