]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/parser/parser-tests.factor
merge project-euler.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 vocabs.parser debugger
4 continuations ;
5 IN: alien.parser.tests
6
7 TYPEDEF: char char2
8
9 SYMBOL: not-c-type
10
11 [
12     "alien.parser.tests" use-vocab
13     "alien.c-types" use-vocab
14
15     [ int ] [ "int" parse-c-type ] unit-test
16     [ { int 5 } ] [ "int[5]" parse-c-type ] unit-test
17     [ { int 5 10 11 } ] [ "int[5][10][11]" parse-c-type ] unit-test
18     [ void* ] [ "int*" parse-c-type ] unit-test
19     [ void* ] [ "int**" parse-c-type ] unit-test
20     [ void* ] [ "int***" parse-c-type ] unit-test
21     [ void* ] [ "int****" parse-c-type ] unit-test
22     [ char* ] [ "char*" parse-c-type ] unit-test
23     [ void* ] [ "char**" parse-c-type ] unit-test
24     [ void* ] [ "char***" parse-c-type ] unit-test
25     [ void* ] [ "char****" parse-c-type ] unit-test
26     [ char2 ] [ "char2" parse-c-type ] unit-test
27     [ char* ] [ "char2*" parse-c-type ] unit-test
28
29     [ "not-c-type" parse-c-type ] [ no-c-type? ] must-fail-with
30     [ "not-word" parse-c-type ] [ error>> no-word-error? ] must-fail-with
31
32 ] with-file-vocabs
33
34 ! Reported by mnestic
35 TYPEDEF: int alien-parser-test-int ! reasonably unique name...
36
37 [ "OK!" ] [
38     [
39         "USE: specialized-arrays SPECIALIZED-ARRAY: alien-parser-test-int" eval( -- )
40         ! after restart, we end up here
41         "OK!"
42     ] [ :1 ] recover
43 ] unit-test