From d45997547f8fbc869911e8e8e13d0f93b7fb2991 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 19 Jul 2013 07:28:33 -0400 Subject: [PATCH] tests: adds an FFI test with simple callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- tests/sav/test_ffi_c_callbacks.sav | 2 ++ tests/test_ffi_c_callbacks.nit | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/sav/test_ffi_c_callbacks.sav create mode 100644 tests/test_ffi_c_callbacks.nit diff --git a/tests/sav/test_ffi_c_callbacks.sav b/tests/sav/test_ffi_c_callbacks.sav new file mode 100644 index 0000000..3bd1f0e --- /dev/null +++ b/tests/sav/test_ffi_c_callbacks.sav @@ -0,0 +1,2 @@ +foo +bar diff --git a/tests/test_ffi_c_callbacks.nit b/tests/test_ffi_c_callbacks.nit new file mode 100644 index 0000000..b4b7cd5 --- /dev/null +++ b/tests/test_ffi_c_callbacks.nit @@ -0,0 +1,34 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2013 Alexis Laferrière +# +# 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. + +class A + fun bar do print "bar" +end + +fun foo do print "foo" + +fun call_a_fun import foo `{ + Object_foo(recv); +`} + +fun call_a_constructor import A, A::bar `{ + A a = new_A(); + A_bar(a); +`} + + +call_a_fun +call_a_constructor -- 1.7.9.5