diff --git t/compilers/pge/04-compile.t t/compilers/pge/04-compile.t
index 1c9475b..404d1e6 100644
|
|
|
1 | | #! perl |
| 1 | #!parrot |
2 | 2 | # $Id$ |
3 | 3 | |
4 | | # Copyright (C) 2007, Parrot Foundation. |
5 | | |
6 | | use strict; |
7 | | use warnings; |
8 | | use lib qw( t . lib ../lib ../../lib ../../../lib ); |
9 | | use Test::More; |
10 | | use Parrot::Test tests => 4; |
| 4 | # Copyright (C) 2007-2009, Parrot Foundation. |
11 | 5 | |
12 | 6 | =head1 NAME |
13 | 7 | |
… |
… |
|
22 | 16 | Tests various arguments to the compiler. |
23 | 17 | |
24 | 18 | =cut |
25 | | |
26 | | pir_output_is( <<'CODE', <<'OUTPUT', 'basic compile, no name/grammar' ); |
27 | 19 | .namespace [] |
28 | 20 | |
29 | 21 | .sub main :main |
| 22 | .include 'test_more.pir' |
| 23 | plan(4) |
| 24 | |
| 25 | test_basic_compile_no_name_grammar() |
| 26 | test_compile_into_current_namespace() |
| 27 | test_compile_into_a_new_grammar() |
| 28 | test_compile_into_a_new_grammar_2x() |
| 29 | .end |
| 30 | |
| 31 | .sub test_basic_compile_no_name_grammar |
30 | 32 | load_bytecode 'PGE.pbc' |
31 | 33 | |
32 | 34 | .local pmc p6compiler |
33 | 35 | p6compiler = compreg 'PGE::Perl6Regex' |
34 | 36 | $P1 = p6compiler('.+') |
35 | 37 | $P2 = $P1('ok 1') |
36 | | say $P2 |
| 38 | is($P2, 'ok 1', 'basic compile, no name/grammar') |
37 | 39 | .end |
38 | | CODE |
39 | | ok 1 |
40 | | OUTPUT |
41 | 40 | |
42 | | pir_output_is( <<'CODE', <<'OUTPUT', 'compile into current namespace' ); |
43 | | .namespace [] |
44 | | |
45 | | .sub main :main |
| 41 | .sub test_compile_into_current_namespace |
46 | 42 | load_bytecode 'PGE.pbc' |
47 | 43 | |
48 | 44 | .local pmc p6compiler |
49 | 45 | p6compiler = compreg 'PGE::Perl6Regex' |
50 | 46 | $P1 = p6compiler('.+', 'name'=>'xyz', 'grammar'=>'') |
51 | 47 | $P2 = 'xyz'('ok 1') |
52 | | say $P2 |
| 48 | is($P2, 'ok 1', 'compile into current namespace') |
53 | 49 | .end |
54 | | CODE |
55 | | ok 1 |
56 | | OUTPUT |
57 | 50 | |
58 | | pir_output_is( <<'CODE', <<'OUTPUT', 'compile into a new grammar' ); |
59 | | .sub main :main |
| 51 | .sub test_compile_into_a_new_grammar |
60 | 52 | load_bytecode 'PGE.pbc' |
61 | 53 | |
62 | 54 | .local pmc p6compiler |
63 | 55 | p6compiler = compreg 'PGE::Perl6Regex' |
64 | | $P1 = p6compiler('.+', 'name'=>'xyz', 'grammar'=>'PGE::Test') |
65 | | $P2 = get_hll_global ['PGE';'Test'], 'xyz' |
| 56 | $P1 = p6compiler('.+', 'name'=>'xyz1', 'grammar'=>'PGE::Test') |
| 57 | $P2 = get_hll_global ['PGE';'Test'], 'xyz1' |
66 | 58 | $P3 = $P2('ok 1') |
67 | | say $P3 |
| 59 | is($P3, 'ok 1', 'compile into a new grammar') |
68 | 60 | .end |
69 | | CODE |
70 | | ok 1 |
71 | | OUTPUT |
72 | 61 | |
73 | | pir_output_is( <<'CODE', <<'OUTPUT', 'compile into a new grammar, 2x' ); |
74 | | .sub main :main |
| 62 | .sub test_compile_into_a_new_grammar_2x |
75 | 63 | load_bytecode 'PGE.pbc' |
76 | 64 | |
77 | 65 | .local pmc p6compiler |
78 | 66 | p6compiler = compreg 'PGE::Perl6Regex' |
79 | 67 | $P1 = p6compiler('.+', 'name'=>'abc', 'grammar'=>'PGE::Test') |
80 | | $P1 = p6compiler('.+', 'name'=>'xyz', 'grammar'=>'PGE::Test') |
| 68 | $P1 = p6compiler('.+', 'name'=>'xyz2', 'grammar'=>'PGE::Test') |
81 | 69 | $P2 = get_hll_global ['PGE';'Test'], 'abc' |
82 | 70 | $P3 = $P2('ok 1') |
83 | | say $P3 |
| 71 | is($P3, 'ok 1', 'compile into a new grammar, 2x') |
84 | 72 | .end |
85 | | CODE |
86 | | ok 1 |
87 | | OUTPUT |
88 | 73 | |
89 | 74 | # Local Variables: |
90 | 75 | # mode: cperl |
91 | 76 | # cperl-indent-level: 4 |
92 | 77 | # fill-column: 100 |
93 | 78 | # End: |
94 | | # vim: expandtab shiftwidth=4: |
95 | | |
| 79 | # vim: expandtab shiftwidth=4 filetype=pir: |