3 # Copyright (C) 2006-2008, The Perl Foundation.
8 use lib qw(t . lib ../lib ../../lib ../../../lib);
10 use Parrot::Test tests => 10;
12 foreach my $name (qw(Node Val Var Op Block Stmts)) {
13 my $module = "PAST::$name";
16 load_bytecode 'PCT.pbc'
17 load_bytecode 'library/dumper.pbc'
23 $code .= " node = new '$module'\n";
24 $code .= " node2 = new '$module'\n";
26 node.'init'('name' => 'foo')
27 node2.'init'('name' => 'bar')
32 "_dumper"(node, "ast")
38 pir_output_is( $code, <<"OUT", "set attributes for $module via method" );
40 "ast" => PMC '$module' {
42 [0] => PMC '$module' {
50 pir_output_is( <<'CODE', <<'OUT', 'dump PAST::Val node in visual format' );
52 load_bytecode 'PCT.pbc'
53 load_bytecode 'library/dumper.pbc'
55 node = new 'PAST::Val'
57 node.'returns'('Integer')
60 $P1 = node.'returns'()
62 "_dumper"(node, "ast")
68 "ast" => PMC 'PAST::Val' {
70 <returns> => "Integer"
74 ## TODO: test that return() is taken from the type of value when not specified
76 ## TODO: check the rest of the PAST::Var attributes
77 pir_output_is( <<'CODE', <<'OUT', 'dump PAST::Var node in visual format' );
79 load_bytecode 'PCT.pbc'
80 load_bytecode 'library/dumper.pbc'
82 node = new 'PAST::Var'
84 node.'viviself'('baz')
86 "_dumper"(node, "ast")
90 "ast" => PMC 'PAST::Var' {
97 pir_output_is( <<'CODE', <<'OUT', 'dump PAST::Op node in visual format' );
99 load_bytecode 'PCT.pbc'
100 load_bytecode 'library/dumper.pbc'
102 node = new 'PAST::Op'
103 node.'pasttype'('pirop')
106 node.'inline'('%r = add %0, %1')
107 "_dumper"(node, "ast")
111 "ast" => PMC 'PAST::Op' {
112 <pasttype> => "pirop"
115 <inline> => "%r = add %0, %1"
119 pir_output_is( <<'CODE', <<'OUT', 'dump PAST::Block node in visual format' );
121 load_bytecode 'PCT.pbc'
122 load_bytecode 'library/dumper.pbc'
124 node = new 'PAST::Block'
125 node.'blocktype'('declaration')
126 "_dumper"(node, "ast")
130 "ast" => PMC 'PAST::Block' {
131 <blocktype> => "declaration"
137 # cperl-indent-level: 4
140 # vim: expandtab shiftwidth=4: