]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/parser/parser-tests.factor
e405f499959d5ba19a228d7d2bb6bc6daca1920a
[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 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 ! Reported by mnestic
38 TYPEDEF: int alien-parser-test-int ! reasonably unique name...
39
40 [ "OK!" ] [
41     [
42         "USE: specialized-arrays SPECIALIZED-ARRAY: alien-parser-test-int" eval( -- )
43         ! after restart, we end up here
44         "OK!"
45     ] [ :1 ] recover
46 ] unit-test