From c286074fe56c53a19f16c20bc5778bdc7e5a739d Mon Sep 17 00:00:00 2001 From: Jeremy Hughes Date: Fri, 3 Jul 2009 11:35:46 +1200 Subject: [PATCH] Unit tests for alien.inline --- basis/alien/inline/tests/tests.factor | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 basis/alien/inline/tests/tests.factor diff --git a/basis/alien/inline/tests/tests.factor b/basis/alien/inline/tests/tests.factor new file mode 100644 index 0000000000..aea41ea8b8 --- /dev/null +++ b/basis/alien/inline/tests/tests.factor @@ -0,0 +1,47 @@ +! Copyright (C) 2009 Jeremy Hughes. +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test alien.inline alien.inline.private io.files io.directories kernel ; +IN: alien.inline.tests + +C-LIBRARY: const + +C-FUNCTION: const-int add ( int a, int b ) + return a + b; +; + +;C-LIBRARY + +{ 2 1 } [ add ] must-infer-as +[ 5 ] [ 2 3 add ] unit-test + +<< library-path dup exists? [ delete-file ] [ drop ] if >> + + +C-LIBRARY: cpplib + +COMPILE-AS-C++ + +C-INCLUDE: + +C-FUNCTION: const-char* hello ( ) + std::string s("hello world"); + return s.c_str(); +; + +;C-LIBRARY + +{ 0 1 } [ hello ] must-infer-as +[ "hello world" ] [ hello ] unit-test + +<< library-path dup exists? [ delete-file ] [ drop ] if >> + + +C-LIBRARY: compile-error + +C-FUNCTION: char* breakme ( ) + return not a string; +; + +<< [ (;C-LIBRARY) ] must-fail >> + +<< library-path dup exists? [ delete-file ] [ drop ] if >>