]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/parser/parser-tests.factor
Merge branch 'master' of git://github.com/slavapestov/factor
[factor.git] / basis / alien / parser / parser-tests.factor
1 ! (c)2009 Joe Groff bsd license
2 USING: accessors alien.c-types alien.parser alien.syntax
3 tools.test vocabs.parser parser eval debugger kernel
4 continuations words ;
5 IN: alien.parser.tests
6
7 TYPEDEF: char char2
8
9 SYMBOL: not-c-type
10
11 CONSTANT: eleven 11
12
13 [
14     "alien.parser.tests" use-vocab
15     "alien.c-types" use-vocab
16
17     [ int ] [ "int" parse-c-type ] unit-test
18     [ { int 5 } ] [ "int[5]" parse-c-type ] unit-test
19     [ { int 5 10 11 } ] [ "int[5][10][11]" parse-c-type ] unit-test
20     [ { int 5 10 eleven } ] [ "int[5][10][eleven]" parse-c-type ] unit-test
21     [ void* ] [ "int*" parse-c-type ] unit-test
22     [ void* ] [ "int**" parse-c-type ] unit-test
23     [ void* ] [ "int***" parse-c-type ] unit-test
24     [ void* ] [ "int****" parse-c-type ] unit-test
25     [ char* ] [ "char*" parse-c-type ] unit-test
26     [ void* ] [ "char**" parse-c-type ] unit-test
27     [ void* ] [ "char***" parse-c-type ] unit-test
28     [ void* ] [ "char****" parse-c-type ] unit-test
29     [ char2 ] [ "char2" parse-c-type ] unit-test
30     [ char* ] [ "char2*" parse-c-type ] unit-test
31
32     [ "not-c-type" parse-c-type ] [ no-c-type? ] must-fail-with
33     [ "not-word" parse-c-type ] [ error>> no-word-error? ] must-fail-with
34
35 ] with-file-vocabs
36
37 FUNCTION: void* alien-parser-function-effect-test ( int *arg1 float arg2 ) ;
38 [ (( arg1 arg2 -- void* )) ] [
39     \ alien-parser-function-effect-test "declared-effect" word-prop
40 ] unit-test
41
42 CALLBACK: void* alien-parser-callback-effect-test ( int *arg1 float arg2 ) ;
43 [ (( arg1 arg2 -- void* )) ] [
44     \ alien-parser-callback-effect-test "callback-effect" word-prop
45 ] unit-test
46
47 ! Reported by mnestic
48 TYPEDEF: int alien-parser-test-int ! reasonably unique name...
49
50 [ "OK!" ] [
51     [
52         "USE: specialized-arrays SPECIALIZED-ARRAY: alien-parser-test-int" eval( -- )
53         ! after restart, we end up here
54         "OK!"
55     ] [ :1 ] recover
56 ] unit-test