File tree Expand file tree Collapse file tree 5 files changed +30
-2
lines changed
IntegrationTests/TestSuites Expand file tree Collapse file tree 5 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,11 @@ let package = Package(
2323 ] ,
2424 dependencies: [ . package ( name: " JavaScriptKit " , path: " ../../ " ) ] ,
2525 targets: [
26- . target( name: " PrimaryTests " , dependencies: [ " JavaScriptKit " ] ) ,
26+ . target( name: " CHelpers " ) ,
27+ . target( name: " PrimaryTests " , dependencies: [
28+ " JavaScriptKit " ,
29+ " CHelpers " ,
30+ ] ) ,
2731 . target(
2832 name: " ConcurrencyTests " ,
2933 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 11import JavaScriptKit
2-
2+ import CHelpers
33
44try test ( " Literal Conversion " ) {
55 let global = JSObject . global
@@ -735,4 +735,15 @@ try test("Exception") {
735735 try expectNotNil ( errorObject3)
736736}
737737
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+
738749Expectation . wait ( expectations)
You can’t perform that action at this time.
0 commit comments