File tree 5 files changed +30
-2
lines changed
IntegrationTests/TestSuites
5 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,11 @@ let package = Package(
23
23
] ,
24
24
dependencies: [ . package ( name: " JavaScriptKit " , path: " ../../ " ) ] ,
25
25
targets: [
26
- . target( name: " PrimaryTests " , dependencies: [ " JavaScriptKit " ] ) ,
26
+ . target( name: " CHelpers " ) ,
27
+ . target( name: " PrimaryTests " , dependencies: [
28
+ " JavaScriptKit " ,
29
+ " CHelpers " ,
30
+ ] ) ,
27
31
. target(
28
32
name: " ConcurrencyTests " ,
29
33
dependencies: [
Original file line number Diff line number Diff line change
1
+ int growMemory (int pages ) {
2
+ return __builtin_wasm_memory_grow (0 , pages );
3
+ }
4
+
Original file line number Diff line number Diff line change
1
+ /// Ask host to grow WebAssembly module's allocated memory
2
+ ///
3
+ /// @param pages Number of memory pages to increase memory by.
4
+ int growMemory (int pages );
5
+
Original file line number Diff line number Diff line change
1
+ module CHelpers {
2
+ header "helpers.h"
3
+ export *
4
+ }
Original file line number Diff line number Diff line change 1
1
import JavaScriptKit
2
-
2
+ import CHelpers
3
3
4
4
try test ( " Literal Conversion " ) {
5
5
let global = JSObject . global
@@ -735,4 +735,15 @@ try test("Exception") {
735
735
try expectNotNil ( errorObject3)
736
736
}
737
737
738
+ /// If WebAssembly.Memory is not accessed correctly (i.e. creating a new view each time),
739
+ /// this test will fail with `TypeError: Cannot perform Construct on a detached ArrayBuffer`,
740
+ /// since asking to grow memory will detach the backing ArrayBuffer.
741
+ /// See https://github.com/swiftwasm/JavaScriptKit/pull/153
742
+ try test ( " Grow Memory " ) {
743
+ let string = " Hello "
744
+ let jsString = JSValue . string ( string)
745
+ growMemory ( 1 )
746
+ try expectEqual ( string, jsString. description)
747
+ }
748
+
738
749
Expectation . wait ( expectations)
You can’t perform that action at this time.
0 commit comments