on master help sign in
Merge pull request #3859 from rbarreiro/test_for_issue_3192
edf03eeNiklas Larsson
test/README.md+1−1
@@ -132,7 +132,7 @@ for the compatible backends are:
132
132
133- `ANY`: choose this if your test will work with any code generator
133- `ANY`: choose this if your test will work with any code generator
134- `C_CG`: choose this to only test against the C code generator
134- `C_CG`: choose this to only test against the C code generator
135−- `JS_CG`: choose this to only test against the Node code generator
135+- `NODE_CG`: choose this to only test against the Node code generator
136- `NONE`: choose this if you don't want your test to be run with multiple code
136- `NONE`: choose this if you don't want your test to be run with multiple code
137generators (mainly for tests that only perform type checking)
137generators (mainly for tests that only perform type checking)
138
138
test/TestData.hs+1
@@ -127,6 +127,7 @@ testFamiliesData = [
127 , ( 7, C_CG )
127 , ( 7, C_CG )
128 , ( 8, C_CG )
128 , ( 8, C_CG )
129 , ( 9, C_CG )
129 , ( 9, C_CG )
130+ , ( 10, NODE_CG )
130 ]),
131 ]),
131 ("folding", "Folding",
132 ("folding", "Folding",
132 [ ( 1, ANY )]),
133 [ ( 1, ANY )]),
test/ffi010/expectednew file+3
@@ -0,0 +1,3 @@
1+start
2+olare
3+end
test/ffi010/ffi010.idrnew file+43
@@ -0,0 +1,43 @@
1+
2+%inline
3+public export
4+jscall : (fname : String) -> (ty : Type) ->
5+ {auto fty : FTy FFI_JS [] ty} -> ty
6+jscall fname ty = foreign FFI_JS fname ty
7+
8+export
9+data ServiceM : Type -> Type where
10+ PureServ : a -> ServiceM a
11+
12+
13+get_jsio : ServiceM a -> JS_IO (Either String a)
14+get_jsio (PureServ x) = do
15+ pure $ Right x
16+
17+export
18+mytst : String -> ServiceM String
19+mytst x = PureServ $ "end"
20+
21+call_fn : (String -> JS_IO String) -> String -> JS_IO String
22+call_fn f x = jscall
23+ "%0(%1)"
24+ ((JsFn (String -> JS_IO String)) -> String -> JS_IO String)
25+ (MkJsFn f)
26+ x
27+
28+mytstJs : String -> JS_IO String
29+mytstJs x = do
30+ r <- get_jsio $ mytst "arst"
31+ case r of
32+ Right k => pure k
33+
34+tst2 : JS_IO String
35+tst2 = call_fn mytstJs "inputmytst"
36+
37+export
38+main : JS_IO ()
39+main = do
40+ putStrLn' "start"
41+ r <- tst2
42+ putStrLn' "olare"
43+ putStrLn' r
test/ffi010/runnew file+4
@@ -0,0 +1,4 @@
1+#!/usr/bin/env bash
2+${IDRIS:-idris} $@ ffi010.idr -o ffi010
3+./ffi010
4+rm -f ffi010 *.ibc