tagged release 0.6.4
[parrot.git] / t / compilers / tge / basic.t
blob14174eee63371f5183303ae3fce2577dda54d659
1 #!perl
2 # Copyright (C) 2005-2006, The Perl Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw(t . lib ../lib ../../lib ../../../lib);
8 use Test::More;
9 use Parrot::Test tests => 3;
11 =head1 NAME
13 t/basic.t - testing a few basic components of TGE::Grammar and TGE::Tree
15 =head1 SYNOPSIS
17         $ prove t/compilers/tge/basic.t
19 =cut
21 pir_output_is( <<'CODE', <<'OUT', 'build up a basic rule in a grammar' );
23 .sub _main :main
24     load_bytecode 'TGE.pbc'
26     .local pmc AG
27     AG = new 'TGE::Grammar'
28     AG.add_rule('Leaf', 'min', '.', '.return(1)')
30     $P1 = getattribute AG, 'rules'
31     .local pmc rule_obj
32     rule_obj = $P1[0]
33     $P2 = getattribute rule_obj, 'type'
34     print $P2
35     print "\n"
36     $P3 = getattribute rule_obj, 'name'
37     print $P3
38     print "\n"
39     $P4 = getattribute rule_obj, 'parent'
40     print $P4
41     print "\n"
42     end
43 .end
45 CODE
46 Leaf
47 min
49 OUT
51 pir_output_is( <<'CODE', <<'OUT', 'agid hash' );
52 .sub _main :main
53     load_bytecode 'compilers/tge/TGE/Tree.pir'
54     .local pmc tree
55     tree = new 'TGE::Tree'
56     .local int id
58     $P0 = new 'Integer'
59     id = tree.'_lookup_id'($P0)
60     print id
61     print "\n"
62     $P1 = new 'Integer'
63     id = tree.'_lookup_id'($P1)
64     print id
65     print "\n"
66     id = tree.'_lookup_id'($P0)
67     print id
68     print "\n"
69     $P2 = new 'Integer'
70     id = tree.'_lookup_id'($P2)
71     print id
72     print "\n"
73     id = tree.'_lookup_id'($P0)
74     print id
75     print "\n"
76     id = tree.'_lookup_id'($P1)
77     print id
78     print "\n"
79     id = tree.'_lookup_id'($P2)
80     print id
81     print "\n"
82     end
83 .end
85 CODE
93 OUT
95 pir_output_is( <<'CODE', <<'OUT', '"Malformed string" in r11890 under Linux i386' );
97 .sub test
98   load_bytecode "TGE.pbc"
99   print "1\n"
100 .end
101 CODE
105 # Local Variables:
106 #   mode: cperl
107 #   cperl-indent-level: 4
108 #   fill-column: 100
109 # End:
110 # vim: expandtab shiftwidth=4: