]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/alien/parser/parser-tests.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / alien / parser / parser-tests.factor
index b9ef08e890fdd183990b8696e87fbe59f4e8fe7c..37f10722d1845e02e2d8592ad91a4075926ddbcc 100644 (file)
@@ -1,27 +1,52 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors alien.c-types alien.parser alien.syntax
-tools.test vocabs.parser ;
+tools.test vocabs.parser parser eval debugger kernel
+continuations words ;
 IN: alien.parser.tests
 
 TYPEDEF: char char2
 
-[ int ] [ "int" parse-c-type ] unit-test
-[ { int 5 } ] [ "int[5]" parse-c-type ] unit-test
-[ { int 5 10 11 } ] [ "int[5][10][11]" parse-c-type ] unit-test
-[ void* ] [ "int*" parse-c-type ] unit-test
-[ void* ] [ "int**" parse-c-type ] unit-test
-[ void* ] [ "int***" parse-c-type ] unit-test
-[ void* ] [ "int****" parse-c-type ] unit-test
-[ char* ] [ "char*" parse-c-type ] unit-test
-[ void* ] [ "char**" parse-c-type ] unit-test
-[ void* ] [ "char***" parse-c-type ] unit-test
-[ void* ] [ "char****" parse-c-type ] unit-test
-[ char2 ] [ "char2" parse-c-type ] unit-test
-[ char* ] [ "char2*" parse-c-type ] unit-test
-
 SYMBOL: not-c-type
 
-[ "not-c-type" parse-c-type ] [ no-c-type? ] must-fail-with
-! uncomment this when string C type parsing goes away
-! [ "not-word" parse-c-type ] [ error>> no-word-error? ] must-fail-with
+CONSTANT: eleven 11
+
+[
+    "alien.parser.tests" use-vocab
+    "alien.c-types" use-vocab
+
+    [ int ] [ "int" parse-c-type ] unit-test
+    [ { int 5 } ] [ "int[5]" parse-c-type ] unit-test
+    [ { int 5 10 11 } ] [ "int[5][10][11]" parse-c-type ] unit-test
+    [ { int 5 10 eleven } ] [ "int[5][10][eleven]" parse-c-type ] unit-test
+    [ pointer: void ] [ "void*" parse-c-type ] unit-test
+    [ pointer: int ] [ "int*" parse-c-type ] unit-test
+    [ pointer: int* ] [ "int**" parse-c-type ] unit-test
+    [ pointer: int** ] [ "int***" parse-c-type ] unit-test
+    [ pointer: int*** ] [ "int****" parse-c-type ] unit-test
+    [ pointer: char ] [ "char*" parse-c-type ] unit-test
+    [ char2 ] [ "char2" parse-c-type ] unit-test
+    [ pointer: char2 ] [ "char2*" parse-c-type ] unit-test
+
+    [ "not-word" parse-c-type ] [ error>> no-word-error? ] must-fail-with
+] with-file-vocabs
+
+FUNCTION: void* alien-parser-function-effect-test ( int *arg1 float arg2 ) ;
+[ (( arg1 arg2 -- void* )) ] [
+    \ alien-parser-function-effect-test "declared-effect" word-prop
+] unit-test
+
+CALLBACK: void* alien-parser-callback-effect-test ( int *arg1 float arg2 ) ;
+[ (( arg1 arg2 -- void* )) ] [
+    \ alien-parser-callback-effect-test "callback-effect" word-prop
+] unit-test
+
+! Reported by mnestic
+TYPEDEF: int alien-parser-test-int ! reasonably unique name...
 
+[ "OK!" ] [
+    [
+        "USE: specialized-arrays SPECIALIZED-ARRAY: alien-parser-test-int" eval( -- )
+        ! after restart, we end up here
+        "OK!"
+    ] [ :1 ] recover
+] unit-test