tagged release 0.7.1
[parrot.git] / t / op / debuginfo.t
blob824994b98ff1dd7147af757f2f8d370aeec90da2
1 #!perl
2 # Copyright (C) 2001-2007, The Perl Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( . lib ../lib ../../lib );
8 use Test::More;
9 use Parrot::Test tests => 8;
11 =head1 NAME
13 t/op/debuginfo.t - Debugging Info
15 =head1 SYNOPSIS
17         % prove t/op/debuginfo.t
19 =head1 DESCRIPTION
21 Tests the various set and get operations for line, package and file info,
22 as well as backtrace tests.
24 =cut
26 pasm_output_like( <<'CODE', <<'OUTPUT', "getline, getfile" );
27 .pcc_sub main:
28     getfile S0
29     getline I0
30     print S0
31     print "\n"
32     print I0
33     print "\n"
34     end
35 CODE
36 /debuginfo_\d+\.pasm
37 \d/
38 OUTPUT
40 pir_error_output_like( <<'CODE', <<'OUTPUT', "debug backtrace - Null PMC access" );
41 .sub main
42     print "ok 1\n"
43     a()
44     print "not ok 10\n"
45 .end
46 .sub a
47     print "ok 2\n"
48     b()
49     print "not ok 9\n"
50 .end
51 .sub b
52     print "ok 3\n"
53     c()
54     print "not ok 8\n"
55 .end
56 .sub c
57     print "ok 4\n"
58     d()
59     print "not ok 7\n"
60 .end
61 .sub d
62     print "ok 5\n"
63     $P0 = null
64     $P0()
65     print "not ok 6\n"
66 .end
67 CODE
68 /^ok 1
69 ok 2
70 ok 3
71 ok 4
72 ok 5
73 Null PMC access in invoke\(\)
74 current instr\.: 'd' pc (\d+|-1) \(.*?:(\d+|-1)\)
75 called from Sub 'c' pc (\d+|-1) \(.*?:(\d+|-1)\)
76 called from Sub 'b' pc (\d+|-1) \(.*?:(\d+|-1)\)
77 called from Sub 'a' pc (\d+|-1) \(.*?:(\d+|-1)\)
78 called from Sub 'main' pc (\d+|-1) \(.*?:(\d+|-1)\)$/
79 OUTPUT
81 pir_error_output_like( <<'CODE', <<'OUTPUT', "debug backtrace - method not found" );
82 .namespace ["Test1"]
83 .sub main
84     print "ok 1\n"
85     foo()
86     print "not ok 5\n"
87 .end
88 .sub foo
89     print "ok 2\n"
90     $P0 = new 'Integer'
91     print "ok 3\n"
92     $P0."nosuchmethod"()
93     print "not ok 4\n"
94 .end
95 CODE
96 /^ok 1
97 ok 2
98 ok 3
99 Method 'nosuchmethod' not found for invocant of class 'Integer'
100 current instr.: 'parrot;Test1;foo' pc (\d+|-1) \(.*?:(\d+|-1)\)
101 called from Sub 'parrot;Test1;main' pc (\d+|-1) \(.*?:(\d+|-1)\)$/
102 OUTPUT
104 pir_error_output_like( <<'CODE', <<'OUTPUT', "debug backtrace - fetch of unknown lexical" );
105 .namespace ["Test2"]
106 .sub main
107     print "ok 1\n"
108     foo()
109     print "not ok 3\n"
110 .end
111 .sub foo :lex
112     print "ok 2\n"
113     find_lex $P0, "nosuchlex"
114     print "not ok 3\n"
115 .end
116 CODE
117 /^ok 1
118 ok 2
119 Lexical 'nosuchlex' not found
120 current instr.: 'parrot;Test2;foo' pc (\d+|-1) \(.*?:(\d+|-1)\)
121 called from Sub 'parrot;Test2;main' pc (\d+|-1) \(.*?:(\d+|-1)\)$/
122 OUTPUT
124 # RT#46895
125 # in plain functional run-loop result is 999
126 # other run-loops report 998
127 # investigate this after interpreter strtup is done
128 # see also todo item in src/embed.c
129 pir_error_output_like( <<'CODE', <<'OUTPUT', "debug backtrace - recursion 1" );
130 .sub main
131     main()
132 .end
133 CODE
134 /^maximum recursion depth exceeded
135 current instr\.: 'main' pc (\d+|-1) \(.*?:(\d+|-1)\)
136 called from Sub 'main' pc (\d+|-1) \(.*?:(\d+|-1)\)
137 \.\.\. call repeated 1000 times/
138 OUTPUT
140 pir_error_output_like( <<'CODE', <<'OUTPUT', "debug backtrace - recursion 2" );
141 .sub main
142     rec(91)
143 .end
144 .sub rec
145     .param int i
146     if i == 0 goto END
147     dec i
148     rec(i)
149     .return()
150 END:
151     $P0 = null
152     $P0()
153 .end
154 CODE
155 /^Null PMC access in invoke\(\)
156 current instr\.: 'rec' pc (\d+|-1) \(.*?:(\d+|-1)\)
157 called from Sub 'rec' pc (\d+|-1) \(.*?:(\d+|-1)\)
158 \.\.\. call repeated 90 times
159 called from Sub 'main' pc (\d+|-1) \(.*?:(\d+|-1)\)$/
160 OUTPUT
162 pir_error_output_like( <<'CODE', <<'OUTPUT', "setfile and setline", todo => "#RT43269" );
163 .sub main :main
164     setfile "xyz.pir"
165     setline 123
166     $S0 = 'hello'
167     $I0 = 456
168     'no_such_function'($S0, $I0)
169 .end
170 CODE
171 /\(xyz.foo:123\)/
172 OUTPUT
174 pir_error_output_like( <<'CODE', <<'OUTPUT', "setfile and setline", todo => "#RT43269" );
175 .sub main :main
176     setfile "foo.p6"
177     setline 123
178     $P0 = new 'Integer'
179     assign $P0, 9876
180     set_global '$a', $P0
182     setline 124
183     $P0 = get_global '$a'
184     $P1 = clone $P0
185     add $P1, 1
186     'nsf'($P1)
187 .end
188 CODE
189 /\(foo.p6:124\)/
190 OUTPUT
192 # Local Variables:
193 #   mode: cperl
194 #   cperl-indent-level: 4
195 #   fill-column: 100
196 # End:
197 # vim: expandtab shiftwidth=4: