tests: add test for the interpreter interpreting the interpreter with its FFI
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 18 Apr 2016 17:48:14 +0000 (13:48 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 20 Apr 2016 12:02:52 +0000 (08:02 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

tests/nit.args
tests/sav/nit_args7.res [new file with mode: 0644]
tests/sav/test_ffi_c_interpreter.res [new file with mode: 0644]
tests/test_ffi_c_interpreter.nit [new file with mode: 0644]

index 9327c80..cbaafd9 100644 (file)
@@ -4,3 +4,4 @@ base_simple3.nit
 -D text=hello -D num=42 -D flag test_define.nit
 -e 'print "hello world"'
 -n -e 'print line' test_prog/README.md test_prog/test_prog.nit
+test_ffi_c_interpreter.nit
diff --git a/tests/sav/nit_args7.res b/tests/sav/nit_args7.res
new file mode 100644 (file)
index 0000000..1d55c4e
--- /dev/null
@@ -0,0 +1,4 @@
+FOO
+BAR 1
+BAZ
+BAR 43
diff --git a/tests/sav/test_ffi_c_interpreter.res b/tests/sav/test_ffi_c_interpreter.res
new file mode 100644 (file)
index 0000000..1d55c4e
--- /dev/null
@@ -0,0 +1,4 @@
+FOO
+BAR 1
+BAZ
+BAR 43
diff --git a/tests/test_ffi_c_interpreter.nit b/tests/test_ffi_c_interpreter.nit
new file mode 100644 (file)
index 0000000..f3dd600
--- /dev/null
@@ -0,0 +1,23 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import core::kernel
+
+fun foo `{ printf("FOO\n"); `}
+fun bar(i: Int) `{ printf("BAR %ld\n", i); `}
+fun baz: Int `{ printf("BAZ\n"); return 42; `}
+
+foo
+bar(1)
+bar(baz+1)