Skip to content
Snippets Groups Projects
Commit b7dce5cd authored by Cheng Shao's avatar Cheng Shao :beach:
Browse files

testsuite: test wasm backend JSFFI sync exports

This commit repurposes some existing JSFFI test cases to make them
cover JSFFI sync exports as well.

(cherry picked from commit b6ae908b)
parent 8cefd046
No related branches found
No related tags found
No related merge requests found
...@@ -10,17 +10,16 @@ import System.Mem ...@@ -10,17 +10,16 @@ import System.Mem
type BinOp a = a -> a -> a type BinOp a = a -> a -> a
foreign import javascript "wrapper" foreign import javascript "wrapper sync"
js_from_hs :: BinOp Int -> IO JSVal js_from_hs :: BinOp Int -> IO JSVal
-- This must be safe since we intend to call back into Haskell again. foreign import javascript unsafe "dynamic"
foreign import javascript safe "dynamic"
js_to_hs :: JSVal -> BinOp Int js_to_hs :: JSVal -> BinOp Int
foreign import javascript "wrapper" foreign import javascript "wrapper"
js_mk_cont :: IO () -> IO JSVal js_mk_cont :: IO () -> IO JSVal
foreign export javascript "testDynExportFree" foreign export javascript "testDynExportFree sync"
testDynExportFree :: Int -> Int -> Int -> IO () testDynExportFree :: Int -> Int -> Int -> IO ()
-- JSVal uses Weak# under the hood for garbage collection support, -- JSVal uses Weak# under the hood for garbage collection support,
......
...@@ -8,7 +8,7 @@ async function reallyGC() { ...@@ -8,7 +8,7 @@ async function reallyGC() {
} }
export default async (__exports) => { export default async (__exports) => {
await __exports.testDynExportFree(114, 514, 1919810); __exports.testDynExportFree(114, 514, 1919810);
const cont = await __exports.testDynExportGC(114, 514, 1919810); const cont = await __exports.testDynExportGC(114, 514, 1919810);
await reallyGC(); await reallyGC();
......
...@@ -45,7 +45,7 @@ textToJSString (Text (ByteArray ba#) (I# off#) (I# len#)) = unsafeDupablePerform ...@@ -45,7 +45,7 @@ textToJSString (Text (ByteArray ba#) (I# off#) (I# len#)) = unsafeDupablePerform
(# s1, mba# #) -> case copyByteArray# ba# off# mba# 0# len# s1 of (# s1, mba# #) -> case copyByteArray# ba# off# mba# 0# len# s1 of
s2 -> keepAlive# mba# s2 $ unIO $ js_to_str (Ptr (mutableByteArrayContents# mba#)) $ I# len# s2 -> keepAlive# mba# s2 $ unIO $ js_to_str (Ptr (mutableByteArrayContents# mba#)) $ I# len#
foreign export javascript "main" foreign export javascript "main sync"
main :: IO () main :: IO ()
main :: IO () main :: IO ()
......
export default async (__exports) => { export default (__exports) => {
await __exports.main(); __exports.main();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment