@@ -17,8 +17,8 @@ final class JSTypedArrayTests: XCTestCase {
17
17
}
18
18
19
19
func testTypedArray( ) {
20
- func checkArray< T> ( _ array: [ T ] ) where T: TypedArrayElement & Equatable {
21
- XCTAssertEqual ( toString ( JSTypedArray ( array) . jsValue. object!) , jsStringify ( array) )
20
+ func checkArray< T> ( _ array: [ T ] ) where T: TypedArrayElement & Equatable , T . Element == T {
21
+ XCTAssertEqual ( toString ( JSTypedArray < T > ( array) . jsValue. object!) , jsStringify ( array) )
22
22
checkArrayUnsafeBytes ( array)
23
23
}
24
24
@@ -30,20 +30,20 @@ final class JSTypedArrayTests: XCTestCase {
30
30
array. map ( { String ( describing: $0) } ) . joined ( separator: " , " )
31
31
}
32
32
33
- func checkArrayUnsafeBytes< T> ( _ array: [ T ] ) where T: TypedArrayElement & Equatable {
34
- let copyOfArray : [ T ] = JSTypedArray ( array) . withUnsafeBytes { buffer in
33
+ func checkArrayUnsafeBytes< T> ( _ array: [ T ] ) where T: TypedArrayElement & Equatable , T . Element == T {
34
+ let copyOfArray : [ T ] = JSTypedArray < T > ( array) . withUnsafeBytes { buffer in
35
35
Array ( buffer)
36
36
}
37
37
XCTAssertEqual ( copyOfArray, array)
38
38
}
39
39
40
40
let numbers = [ UInt8] ( 0 ... 255 )
41
- let typedArray = JSTypedArray ( numbers)
41
+ let typedArray = JSTypedArray < UInt8 > ( numbers)
42
42
XCTAssertEqual ( typedArray [ 12 ] , 12 )
43
43
XCTAssertEqual ( numbers. count, typedArray. lengthInBytes)
44
44
45
45
let numbersSet = Set ( 0 ... 255 )
46
- let typedArrayFromSet = JSTypedArray ( numbersSet)
46
+ let typedArrayFromSet = JSTypedArray < Int > ( numbersSet)
47
47
XCTAssertEqual ( typedArrayFromSet. jsObject. length, 256 )
48
48
XCTAssertEqual ( typedArrayFromSet. lengthInBytes, 256 * MemoryLayout< Int> . size)
49
49
@@ -63,7 +63,7 @@ final class JSTypedArrayTests: XCTestCase {
63
63
0 , 1 , . pi, . greatestFiniteMagnitude, . infinity, . leastNonzeroMagnitude,
64
64
. leastNormalMagnitude, 42 ,
65
65
]
66
- let jsFloat32Array = JSTypedArray ( float32Array)
66
+ let jsFloat32Array = JSTypedArray < Float32 > ( float32Array)
67
67
for (i, num) in float32Array. enumerated ( ) {
68
68
XCTAssertEqual ( num, jsFloat32Array [ i] )
69
69
}
@@ -72,7 +72,7 @@ final class JSTypedArrayTests: XCTestCase {
72
72
0 , 1 , . pi, . greatestFiniteMagnitude, . infinity, . leastNonzeroMagnitude,
73
73
. leastNormalMagnitude, 42 ,
74
74
]
75
- let jsFloat64Array = JSTypedArray ( float64Array)
75
+ let jsFloat64Array = JSTypedArray < Float64 > ( float64Array)
76
76
for (i, num) in float64Array. enumerated ( ) {
77
77
XCTAssertEqual ( num, jsFloat64Array [ i] )
78
78
}
0 commit comments