1 | error:imcc:syntax error, unexpected STRINGC, expecting '(' ('"expired"') |
---|
2 | in file '/tmp/GRUElNDml_.pir' line 11 |
---|
3 | error:imcc:syntax error, unexpected STRINGC, expecting '(' ('"timer"') |
---|
4 | in file '/tmp/GRUElNDml_.pir' line 17 |
---|
5 | |
---|
6 | # Failed test 'docs/user/pir/pmcs.pod |
---|
7 | # |
---|
8 | # |
---|
9 | # .include "timer.pasm" \# for the timer constants |
---|
10 | # |
---|
11 | # .sub expired |
---|
12 | # print "Timer has expired!\n" |
---|
13 | # .end |
---|
14 | # |
---|
15 | # .sub _ :main |
---|
16 | # $P0 = new 'Timer' |
---|
17 | # $P1 = global "expired" |
---|
18 | # |
---|
19 | # $P0[.PARROT_TIMER_HANDLER] = $P1 \# call sub in $P1 when timer goes off |
---|
20 | # $P0[.PARROT_TIMER_SEC] = 2 \# trigger every 2 seconds |
---|
21 | # $P0[.PARROT_TIMER_REPEAT] = -1 \# repeat indefinitely |
---|
22 | # $P0[.PARROT_TIMER_RUNNING] = 1 \# start timer immediately |
---|
23 | # global "timer" = $P0 \# keep the timer around |
---|
24 | # |
---|
25 | # $I0 = 0 |
---|
26 | # loop: |
---|
27 | # print $I0 |
---|
28 | # print ": running...\n" |
---|
29 | # inc $I0 |
---|
30 | # sleep 1 \# wait a second |
---|
31 | # goto loop |
---|
32 | # .end |
---|
33 | # |
---|
34 | # ' |
---|
35 | # at t/examples/pod.t line 49. |
---|
36 | # got: '256' |
---|
37 | # expected: '0' |
---|
38 | error:imcc:syntax error, unexpected STRINGC, expecting IDENTIFIER ('"name"') |
---|
39 | in file '/tmp/skIgUDa8Uf.pir' line 4 |
---|
40 | |
---|
41 | # Failed test 'docs/user/pir/intro.pod |
---|
42 | # |
---|
43 | # |
---|
44 | # .sub foo |
---|
45 | # .param string "name" => a |
---|
46 | # .param int "age" => b |
---|
47 | # .param string "gender" => c |
---|
48 | # \# ... |
---|
49 | # .end |
---|
50 | # |
---|
51 | # ' |
---|
52 | # at t/examples/pod.t line 49. |
---|
53 | # got: '256' |
---|
54 | # expected: '0' |
---|
55 | error:imcc:The opcode 'fact_i' (fact<1>) was not found. Check the type and number of the arguments |
---|
56 | in file '/tmp/ru8S8tvE2C.pir' line 10 |
---|
57 | |
---|
58 | # Failed test 'docs/book/ch04_pir_subroutines.pod |
---|
59 | # |
---|
60 | # |
---|
61 | # \# factorial.pir |
---|
62 | # .sub main |
---|
63 | # .local int count |
---|
64 | # .local int product |
---|
65 | # count = 5 |
---|
66 | # product = 1 |
---|
67 | # |
---|
68 | # $I0 = fact(count, product) |
---|
69 | # |
---|
70 | # print $I0 |
---|
71 | # print "\n" |
---|
72 | # end |
---|
73 | # .end |
---|
74 | # |
---|
75 | # .sub fact |
---|
76 | # .param int c |
---|
77 | # .param int p |
---|
78 | # |
---|
79 | # loop: |
---|
80 | # if c <= 1 goto fin |
---|
81 | # p = c * p |
---|
82 | # dec c |
---|
83 | # branch loop |
---|
84 | # fin: |
---|
85 | # .return p |
---|
86 | # .end |
---|
87 | # |
---|
88 | # ' |
---|
89 | # at t/examples/pod.t line 49. |
---|
90 | # got: '512' |
---|
91 | # expected: '0' |
---|
92 | error:imcc:The opcode 'concat_s_sc_i' (concat<3>) was not found. Check the type and number of the arguments |
---|
93 | in file '/tmp/Z_hwkKboI2.pir' line 7 |
---|
94 | |
---|
95 | # Failed test 'docs/book/ch04_pir_subroutines.pod |
---|
96 | # |
---|
97 | # |
---|
98 | # .sub 'MySub' |
---|
99 | # .param int yrs :named("age") |
---|
100 | # .param string call :named("name") |
---|
101 | # $S0 = "Hello " . call |
---|
102 | # $S1 = "You are " . yrs |
---|
103 | # $S1 = $S1 . " years old |
---|
104 | # print $S0 |
---|
105 | # print $S1 |
---|
106 | # .end |
---|
107 | # |
---|
108 | # .sub main :main |
---|
109 | # 'MySub'("age" => 42, "name" => "Bob") |
---|
110 | # .end |
---|
111 | # |
---|
112 | # ' |
---|
113 | # at t/examples/pod.t line 49. |
---|
114 | # got: '512' |
---|
115 | # expected: '0' |
---|
116 | error:imcc:syntax error, unexpected '\n', expecting COMMA or ')' |
---|
117 | in file '/tmp/hkz2AHEQyU.pir' line 12 |
---|
118 | error:imcc:syntax error, unexpected VAR, expecting '(' ('b') |
---|
119 | in file '/tmp/hkz2AHEQyU.pir' line 20 |
---|
120 | |
---|
121 | # Failed test 'docs/book/ch04_pir_subroutines.pod |
---|
122 | # |
---|
123 | # |
---|
124 | # .sub main :main |
---|
125 | # .local int value |
---|
126 | # value = add_two(5) |
---|
127 | # say value |
---|
128 | # .end |
---|
129 | # |
---|
130 | # .sub add_two |
---|
131 | # .param int value |
---|
132 | # .local int val2 |
---|
133 | # val2 = add_one(value |
---|
134 | # .tailcall add_one(val2) |
---|
135 | # .end |
---|
136 | # |
---|
137 | # .sub add_one |
---|
138 | # .param int a |
---|
139 | # .local int b |
---|
140 | # b = a + 1 |
---|
141 | # return b |
---|
142 | # .end |
---|
143 | # |
---|
144 | # ' |
---|
145 | # at t/examples/pod.t line 49. |
---|
146 | # got: '256' |
---|
147 | # expected: '0' |
---|
148 | error:imcc:syntax error, unexpected INTV, expecting STRINGC ('int') |
---|
149 | in file '/tmp/AlxDUmQMdv.pir' line 4 |
---|
150 | error:imcc:syntax error, unexpected INTV, expecting STRINGC ('int') |
---|
151 | in file '/tmp/AlxDUmQMdv.pir' line 5 |
---|
152 | error:imcc:syntax error, unexpected INTV, expecting STRINGC ('int') |
---|
153 | in file '/tmp/AlxDUmQMdv.pir' line 11 |
---|
154 | |
---|
155 | # Failed test 'docs/book/ch04_pir_subroutines.pod |
---|
156 | # |
---|
157 | # |
---|
158 | # .sub 'MyOuter' |
---|
159 | # .lex int x |
---|
160 | # .lex int y |
---|
161 | # 'MyInner'() |
---|
162 | # \# only x and y are visible here |
---|
163 | # .end |
---|
164 | # |
---|
165 | # .sub 'MyInner' :outer('MyOuter') |
---|
166 | # .lex int z |
---|
167 | # \#x, y, and z are all "visible" here |
---|
168 | # .end |
---|
169 | # |
---|
170 | # ' |
---|
171 | # at t/examples/pod.t line 49. |
---|
172 | # got: '256' |
---|
173 | # expected: '0' |
---|
174 | error:imcc:syntax error, unexpected PARROT_OP, expecting '(' ('fact') |
---|
175 | in file '/tmp/7ortoAd1yh.pir' line 5 |
---|
176 | error:imcc:syntax error, unexpected PARROT_OP, expecting '(' ('fact') |
---|
177 | in file '/tmp/7ortoAd1yh.pir' line 9 |
---|
178 | |
---|
179 | # Failed test 'docs/book/ch04_pir_subroutines.pod |
---|
180 | # |
---|
181 | # |
---|
182 | # .sub main |
---|
183 | # $I1 = 5 \# counter |
---|
184 | # call fact \# same as "bsr fact" |
---|
185 | # print $I0 |
---|
186 | # print "\n" |
---|
187 | # $I1 = 6 \# counter |
---|
188 | # call fact |
---|
189 | # print $I0 |
---|
190 | # print "\n" |
---|
191 | # end |
---|
192 | # |
---|
193 | # fact: |
---|
194 | # $I0 = 1 \# product |
---|
195 | # L1: |
---|
196 | # $I0 = $I0 * $I1 |
---|
197 | # dec $I1 |
---|
198 | # if $I1 > 0 goto L1 |
---|
199 | # ret |
---|
200 | # .end |
---|
201 | # |
---|
202 | # ' |
---|
203 | # at t/examples/pod.t line 49. |
---|
204 | # got: '256' |
---|
205 | # expected: '0' |
---|
206 | error:imcc:syntax error, unexpected ADV_INVOCANT, expecting '\n' (':invocant') |
---|
207 | in file '/tmp/d6kHkhnWOY.pir' line 9 |
---|
208 | |
---|
209 | # Failed test 'docs/book/ch04_pir_subroutines.pod |
---|
210 | # |
---|
211 | # |
---|
212 | # .sub "MyMethod" :method |
---|
213 | # $S0 = self \# Already defined as "self" |
---|
214 | # say $S0 |
---|
215 | # .end |
---|
216 | # |
---|
217 | # .sub "MyMethod2" :method |
---|
218 | # .param pmc item :invocant \# "self" is now called "item" |
---|
219 | # $S0 = item |
---|
220 | # say $S0 |
---|
221 | # .end |
---|
222 | # |
---|
223 | # ' |
---|
224 | # at t/examples/pod.t line 49. |
---|
225 | # got: '256' |
---|
226 | # expected: '0' |
---|
227 | # Looks like you failed 8 tests of 50. |
---|
228 | t/examples/pod.t .. |
---|
229 | ok 1 - docs/book/ch03_pir_basics.pod |
---|
230 | # |
---|
231 | # .sub main |
---|
232 | # $S0 = "hello " |
---|
233 | # print $S0 |
---|
234 | # $S1 = "world!" |
---|
235 | # print $S1 |
---|
236 | # .end |
---|
237 | # |
---|
238 | ok 2 - docs/book/ch03_pir_basics.pod |
---|
239 | # |
---|
240 | # .sub main |
---|
241 | # $S0 = "hello " |
---|
242 | # print $S0 |
---|
243 | # $S0 = "world!" |
---|
244 | # print $S0 |
---|
245 | # .end |
---|
246 | # |
---|
247 | ok 3 - docs/book/ch03_pir_basics.pod |
---|
248 | # |
---|
249 | # .sub main |
---|
250 | # print "Hello, Polly.\n" |
---|
251 | # .end |
---|
252 | # |
---|
253 | ok 4 - docs/book/ch03_pir_basics.pod |
---|
254 | # |
---|
255 | # .sub first |
---|
256 | # print "Polly want a cracker?\n" |
---|
257 | # .end |
---|
258 | # |
---|
259 | # .sub second :main |
---|
260 | # print "Hello, Polly.\n" |
---|
261 | # .end |
---|
262 | # |
---|
263 | ok 5 - docs/book/ch03_pir_basics.pod |
---|
264 | # |
---|
265 | # .sub first :main |
---|
266 | # print "Polly want a cracker?\n" |
---|
267 | # .end |
---|
268 | # |
---|
269 | # .sub second |
---|
270 | # print "Hello, Polly.\n" |
---|
271 | # .end |
---|
272 | # |
---|
273 | ok 6 - docs/book/ch03_pir_basics.pod |
---|
274 | # |
---|
275 | # .sub _main |
---|
276 | # goto L1 |
---|
277 | # print "never printed" |
---|
278 | # L1: |
---|
279 | # print "after branch\n" |
---|
280 | # end |
---|
281 | # .end |
---|
282 | # |
---|
283 | ok 7 - docs/book/ch03_pir_basics.pod |
---|
284 | # |
---|
285 | # .sub _main |
---|
286 | # $I0 = 42 |
---|
287 | # if $I0 goto L1 |
---|
288 | # print "never printed" |
---|
289 | # L1: print "after branch\n" |
---|
290 | # end |
---|
291 | # .end |
---|
292 | # |
---|
293 | ok 8 - docs/book/ch03_pir_basics.pod |
---|
294 | # |
---|
295 | # .sub _main |
---|
296 | # $I0 = 42 |
---|
297 | # $I1 = 43 |
---|
298 | # if $I0 < $I1 goto L1 |
---|
299 | # print "never printed" |
---|
300 | # L1: |
---|
301 | # print "after branch\n" |
---|
302 | # end |
---|
303 | # .end |
---|
304 | # |
---|
305 | ok 9 - docs/book/ch03_pir_basics.pod |
---|
306 | # |
---|
307 | # .sub _main |
---|
308 | # $I0 = 1 \# product |
---|
309 | # $I1 = 5 \# counter |
---|
310 | # |
---|
311 | # REDO: \# start of loop |
---|
312 | # $I0 = $I0 * $I1 |
---|
313 | # dec $I1 |
---|
314 | # if $I1 > 0 goto REDO \# end of loop |
---|
315 | # |
---|
316 | # print $I0 |
---|
317 | # print "\n" |
---|
318 | # end |
---|
319 | # .end |
---|
320 | # |
---|
321 | ok 10 - docs/book/ch03_pir_basics.pod |
---|
322 | # |
---|
323 | # .sub _main |
---|
324 | # $I0 = 1 \# product |
---|
325 | # $I1 = 5 \# counter |
---|
326 | # |
---|
327 | # REDO: \# start of loop |
---|
328 | # if $I1 <= 0 goto LAST |
---|
329 | # $I0 = $I0 * $I1 |
---|
330 | # dec $I1 |
---|
331 | # goto REDO |
---|
332 | # LAST: \# end of loop |
---|
333 | # |
---|
334 | # print $I0 |
---|
335 | # print "\n" |
---|
336 | # end |
---|
337 | # .end |
---|
338 | # |
---|
339 | ok 11 - docs/book/ch03_pir_basics.pod |
---|
340 | # |
---|
341 | # .sub main |
---|
342 | # loop_top: |
---|
343 | # $S0 = read 10 |
---|
344 | # print $S0 |
---|
345 | # goto loop_top |
---|
346 | # .end |
---|
347 | # |
---|
348 | ok 12 - docs/book/ch03_pir_basics.pod |
---|
349 | # |
---|
350 | # .sub main |
---|
351 | # $P0 = getstdout |
---|
352 | # $P1 = open "myfile.txt", "r" |
---|
353 | # loop_top: |
---|
354 | # $S0 = readline $P1 |
---|
355 | # print $P0, $S0 |
---|
356 | # if $P1 goto loop_top |
---|
357 | # close $P1 |
---|
358 | # .end |
---|
359 | # |
---|
360 | ok 13 - docs/user/pir/pmcs.pod |
---|
361 | # |
---|
362 | # |
---|
363 | # .sub _ :main |
---|
364 | # .param pmc args |
---|
365 | # loop: |
---|
366 | # unless args goto end_loop \# line 4 |
---|
367 | # $S0 = shift args |
---|
368 | # print $S0 |
---|
369 | # print "\n" |
---|
370 | # goto loop |
---|
371 | # end_loop: |
---|
372 | # .end |
---|
373 | # |
---|
374 | # |
---|
375 | ok 14 - docs/user/pir/pmcs.pod |
---|
376 | # |
---|
377 | # |
---|
378 | # .sub _ :main |
---|
379 | # .param pmc args |
---|
380 | # .local int argc |
---|
381 | # argc = args \# line 4 |
---|
382 | # $I0 = 0 |
---|
383 | # loop: |
---|
384 | # unless $I0 < argc goto end_loop |
---|
385 | # print $I0 |
---|
386 | # print "\t" |
---|
387 | # $S0 = args[$I0] \# line 10 |
---|
388 | # print $S0 |
---|
389 | # print "\n" |
---|
390 | # inc $I0 |
---|
391 | # goto loop |
---|
392 | # end_loop: |
---|
393 | # .end |
---|
394 | # |
---|
395 | # |
---|
396 | ok 15 - docs/user/pir/pmcs.pod |
---|
397 | # |
---|
398 | # |
---|
399 | # .sub _ :main |
---|
400 | # .param pmc args |
---|
401 | # $S0 = typeof args |
---|
402 | # print $S0 |
---|
403 | # print "\n" |
---|
404 | # .end |
---|
405 | # |
---|
406 | # |
---|
407 | ok 16 - docs/user/pir/pmcs.pod |
---|
408 | # |
---|
409 | # |
---|
410 | # .sub _ :main |
---|
411 | # .local pmc env, iter |
---|
412 | # .local string key, value |
---|
413 | # |
---|
414 | # env = new 'Env' \# line 3 |
---|
415 | # iter = new 'Iterator', env \# line 4 |
---|
416 | # iterloop: |
---|
417 | # unless iter goto iterend |
---|
418 | # key = shift iter \# line 8 |
---|
419 | # value = env[key] |
---|
420 | # print key |
---|
421 | # print ":" |
---|
422 | # print value |
---|
423 | # print "\n" |
---|
424 | # goto iterloop |
---|
425 | # iterend: |
---|
426 | # .end |
---|
427 | # |
---|
428 | # |
---|
429 | ok 17 - docs/user/pir/pmcs.pod |
---|
430 | # |
---|
431 | # |
---|
432 | # .sub _ :main |
---|
433 | # .param pmc args |
---|
434 | # .local pmc cmdline |
---|
435 | # cmdline = new 'Iterator', args |
---|
436 | # loop: |
---|
437 | # unless cmdline goto end_loop |
---|
438 | # $S0 = shift cmdline |
---|
439 | # print $S0 |
---|
440 | # print "\n" |
---|
441 | # goto loop |
---|
442 | # end_loop: |
---|
443 | # .end |
---|
444 | # |
---|
445 | # |
---|
446 | ok 18 - docs/user/pir/pmcs.pod |
---|
447 | # |
---|
448 | # |
---|
449 | # .sub _ :main |
---|
450 | # $P0 = new 'Random' |
---|
451 | # $N0 = $P0 |
---|
452 | # print $N0 |
---|
453 | # print "\n" |
---|
454 | # $N0 = $P0 |
---|
455 | # print $N0 |
---|
456 | # print "\n" |
---|
457 | # .end |
---|
458 | # |
---|
459 | # |
---|
460 | ok 19 - docs/user/pir/pmcs.pod |
---|
461 | # |
---|
462 | # |
---|
463 | # .sub _ :main |
---|
464 | # $P0 = new 'Exception' |
---|
465 | # $P0 = "The sky is falling!" |
---|
466 | # throw $P0 |
---|
467 | # .end |
---|
468 | # |
---|
469 | # |
---|
470 | not ok 20 - docs/user/pir/pmcs.pod |
---|
471 | # |
---|
472 | # |
---|
473 | # .include "timer.pasm" \# for the timer constants |
---|
474 | # |
---|
475 | # .sub expired |
---|
476 | # print "Timer has expired!\n" |
---|
477 | # .end |
---|
478 | # |
---|
479 | # .sub _ :main |
---|
480 | # $P0 = new 'Timer' |
---|
481 | # $P1 = global "expired" |
---|
482 | # |
---|
483 | # $P0[.PARROT_TIMER_HANDLER] = $P1 \# call sub in $P1 when timer goes off |
---|
484 | # $P0[.PARROT_TIMER_SEC] = 2 \# trigger every 2 seconds |
---|
485 | # $P0[.PARROT_TIMER_REPEAT] = -1 \# repeat indefinitely |
---|
486 | # $P0[.PARROT_TIMER_RUNNING] = 1 \# start timer immediately |
---|
487 | # global "timer" = $P0 \# keep the timer around |
---|
488 | # |
---|
489 | # $I0 = 0 |
---|
490 | # loop: |
---|
491 | # print $I0 |
---|
492 | # print ": running...\n" |
---|
493 | # inc $I0 |
---|
494 | # sleep 1 \# wait a second |
---|
495 | # goto loop |
---|
496 | # .end |
---|
497 | # |
---|
498 | # |
---|
499 | ok 21 - docs/user/pir/intro.pod |
---|
500 | # |
---|
501 | # |
---|
502 | # .sub main :main |
---|
503 | # print "hello world\n" |
---|
504 | # .end |
---|
505 | # |
---|
506 | # |
---|
507 | ok 22 - docs/user/pir/intro.pod |
---|
508 | # |
---|
509 | # |
---|
510 | # .sub main :main |
---|
511 | # hello() |
---|
512 | # .end |
---|
513 | # |
---|
514 | # .sub hello |
---|
515 | # print "Hello World\n" |
---|
516 | # .end |
---|
517 | # |
---|
518 | # |
---|
519 | ok 23 - docs/user/pir/intro.pod |
---|
520 | # |
---|
521 | # |
---|
522 | # .sub main :main |
---|
523 | # hello("leo") |
---|
524 | # hello("chip") |
---|
525 | # .end |
---|
526 | # |
---|
527 | # .sub hello |
---|
528 | # .param string person |
---|
529 | # print "Hello " |
---|
530 | # print person |
---|
531 | # print "\n" |
---|
532 | # .end |
---|
533 | # |
---|
534 | # |
---|
535 | ok 24 - docs/user/pir/intro.pod |
---|
536 | # |
---|
537 | # |
---|
538 | # .sub main :main |
---|
539 | # $I1 = factorial(5) |
---|
540 | # print $I1 |
---|
541 | # print "\n" |
---|
542 | # .end |
---|
543 | # |
---|
544 | # .sub factorial |
---|
545 | # .param int i |
---|
546 | # if i > 1 goto recur |
---|
547 | # .return (1) |
---|
548 | # recur: |
---|
549 | # $I1 = i - 1 |
---|
550 | # $I2 = factorial($I1) |
---|
551 | # $I2 *= i |
---|
552 | # .return ($I2) |
---|
553 | # .end |
---|
554 | # |
---|
555 | # |
---|
556 | not ok 25 - docs/user/pir/intro.pod |
---|
557 | # |
---|
558 | # |
---|
559 | # .sub foo |
---|
560 | # .param string "name" => a |
---|
561 | # .param int "age" => b |
---|
562 | # .param string "gender" => c |
---|
563 | # \# ... |
---|
564 | # .end |
---|
565 | # |
---|
566 | # |
---|
567 | ok 26 - docs/user/pir/intro.pod |
---|
568 | # |
---|
569 | # |
---|
570 | # .sub main |
---|
571 | # .param int a |
---|
572 | # .param int b :named("age") |
---|
573 | # \# ... |
---|
574 | # .end |
---|
575 | # |
---|
576 | # |
---|
577 | ok 27 - docs/book/ch05_pasm.pod |
---|
578 | # |
---|
579 | # |
---|
580 | # LABEL: |
---|
581 | # print "The answer is: " |
---|
582 | # print 42 |
---|
583 | # print "\n" |
---|
584 | # end \# halt the interpreter |
---|
585 | # |
---|
586 | # |
---|
587 | not ok 28 - docs/book/ch04_pir_subroutines.pod |
---|
588 | # |
---|
589 | # |
---|
590 | # \# factorial.pir |
---|
591 | # .sub main |
---|
592 | # .local int count |
---|
593 | # .local int product |
---|
594 | # count = 5 |
---|
595 | # product = 1 |
---|
596 | # |
---|
597 | # $I0 = fact(count, product) |
---|
598 | # |
---|
599 | # print $I0 |
---|
600 | # print "\n" |
---|
601 | # end |
---|
602 | # .end |
---|
603 | # |
---|
604 | # .sub fact |
---|
605 | # .param int c |
---|
606 | # .param int p |
---|
607 | # |
---|
608 | # loop: |
---|
609 | # if c <= 1 goto fin |
---|
610 | # p = c * p |
---|
611 | # dec c |
---|
612 | # branch loop |
---|
613 | # fin: |
---|
614 | # .return p |
---|
615 | # .end |
---|
616 | # |
---|
617 | # |
---|
618 | not ok 29 - docs/book/ch04_pir_subroutines.pod |
---|
619 | # |
---|
620 | # |
---|
621 | # .sub 'MySub' |
---|
622 | # .param int yrs :named("age") |
---|
623 | # .param string call :named("name") |
---|
624 | # $S0 = "Hello " . call |
---|
625 | # $S1 = "You are " . yrs |
---|
626 | # $S1 = $S1 . " years old |
---|
627 | # print $S0 |
---|
628 | # print $S1 |
---|
629 | # .end |
---|
630 | # |
---|
631 | # .sub main :main |
---|
632 | # 'MySub'("age" => 42, "name" => "Bob") |
---|
633 | # .end |
---|
634 | # |
---|
635 | # |
---|
636 | ok 30 - docs/book/ch04_pir_subroutines.pod |
---|
637 | # |
---|
638 | # |
---|
639 | # .sub main :main |
---|
640 | # 'MySub'("name" => "Bob", "age" => 42) \# Same! |
---|
641 | # .end |
---|
642 | # |
---|
643 | # |
---|
644 | not ok 31 - docs/book/ch04_pir_subroutines.pod |
---|
645 | # |
---|
646 | # |
---|
647 | # .sub main :main |
---|
648 | # .local int value |
---|
649 | # value = add_two(5) |
---|
650 | # say value |
---|
651 | # .end |
---|
652 | # |
---|
653 | # .sub add_two |
---|
654 | # .param int value |
---|
655 | # .local int val2 |
---|
656 | # val2 = add_one(value |
---|
657 | # .tailcall add_one(val2) |
---|
658 | # .end |
---|
659 | # |
---|
660 | # .sub add_one |
---|
661 | # .param int a |
---|
662 | # .local int b |
---|
663 | # b = a + 1 |
---|
664 | # return b |
---|
665 | # .end |
---|
666 | # |
---|
667 | # |
---|
668 | not ok 32 - docs/book/ch04_pir_subroutines.pod |
---|
669 | # |
---|
670 | # |
---|
671 | # .sub 'MyOuter' |
---|
672 | # .lex int x |
---|
673 | # .lex int y |
---|
674 | # 'MyInner'() |
---|
675 | # \# only x and y are visible here |
---|
676 | # .end |
---|
677 | # |
---|
678 | # .sub 'MyInner' :outer('MyOuter') |
---|
679 | # .lex int z |
---|
680 | # \#x, y, and z are all "visible" here |
---|
681 | # .end |
---|
682 | # |
---|
683 | # |
---|
684 | not ok 33 - docs/book/ch04_pir_subroutines.pod |
---|
685 | # |
---|
686 | # |
---|
687 | # .sub main |
---|
688 | # $I1 = 5 \# counter |
---|
689 | # call fact \# same as "bsr fact" |
---|
690 | # print $I0 |
---|
691 | # print "\n" |
---|
692 | # $I1 = 6 \# counter |
---|
693 | # call fact |
---|
694 | # print $I0 |
---|
695 | # print "\n" |
---|
696 | # end |
---|
697 | # |
---|
698 | # fact: |
---|
699 | # $I0 = 1 \# product |
---|
700 | # L1: |
---|
701 | # $I0 = $I0 * $I1 |
---|
702 | # dec $I1 |
---|
703 | # if $I1 > 0 goto L1 |
---|
704 | # ret |
---|
705 | # .end |
---|
706 | # |
---|
707 | # |
---|
708 | not ok 34 - docs/book/ch04_pir_subroutines.pod |
---|
709 | # |
---|
710 | # |
---|
711 | # .sub "MyMethod" :method |
---|
712 | # $S0 = self \# Already defined as "self" |
---|
713 | # say $S0 |
---|
714 | # .end |
---|
715 | # |
---|
716 | # .sub "MyMethod2" :method |
---|
717 | # .param pmc item :invocant \# "self" is now called "item" |
---|
718 | # $S0 = item |
---|
719 | # say $S0 |
---|
720 | # .end |
---|
721 | # |
---|
722 | # |
---|
723 | ok 35 - docs/book/ch04_pir_subroutines.pod |
---|
724 | # |
---|
725 | # |
---|
726 | # .sub main |
---|
727 | # .local pmc class |
---|
728 | # .local pmc obj |
---|
729 | # newclass class, "Foo" \# create a new Foo class |
---|
730 | # new obj, "Foo" \# instantiate a Foo object |
---|
731 | # obj."meth"() \# call obj."meth" which is actually |
---|
732 | # print "done\n" \# in the "Foo" namespace |
---|
733 | # end |
---|
734 | # .end |
---|
735 | # |
---|
736 | # .namespace [ "Foo" ] \# start namespace "Foo" |
---|
737 | # |
---|
738 | # .sub meth :method \# define Foo::meth global |
---|
739 | # print "in meth\n" |
---|
740 | # $S0 = "other_meth" \# method names can be in a register too |
---|
741 | # self.$S0() \# self is the invocant |
---|
742 | # .end |
---|
743 | # |
---|
744 | # .sub other_meth :method \# define another method |
---|
745 | # print "in other_meth\n" \# as above Parrot provides a return |
---|
746 | # .end \# statement |
---|
747 | # |
---|
748 | # |
---|
749 | ok 36 - docs/intro.pod |
---|
750 | # |
---|
751 | # |
---|
752 | # .sub main |
---|
753 | # print "Hello world!\n" |
---|
754 | # .end |
---|
755 | # |
---|
756 | # |
---|
757 | ok 37 - docs/intro.pod |
---|
758 | # |
---|
759 | # |
---|
760 | # .sub main |
---|
761 | # set $S0, "Hello world!\n" |
---|
762 | # print $S0 |
---|
763 | # .end |
---|
764 | # |
---|
765 | # |
---|
766 | ok 38 - docs/intro.pod |
---|
767 | # |
---|
768 | # |
---|
769 | # .sub main |
---|
770 | # $S0 = "Hello world!\n" |
---|
771 | # print $S0 |
---|
772 | # .end |
---|
773 | # |
---|
774 | # |
---|
775 | ok 39 - docs/intro.pod |
---|
776 | # |
---|
777 | # |
---|
778 | # .sub main |
---|
779 | # .local string hello |
---|
780 | # hello = "Hello world!\n" |
---|
781 | # print hello |
---|
782 | # .end |
---|
783 | # |
---|
784 | # |
---|
785 | ok 40 - docs/intro.pod |
---|
786 | # |
---|
787 | # |
---|
788 | # .sub main |
---|
789 | # \# State the number of squares to sum. |
---|
790 | # .local int maxnum |
---|
791 | # maxnum = 10 |
---|
792 | # |
---|
793 | # \# We'll use some named registers. Note that we can declare many |
---|
794 | # \# registers of the same type on one line. |
---|
795 | # .local int i, total, temp |
---|
796 | # total = 0 |
---|
797 | # |
---|
798 | # \# Loop to do the sum. |
---|
799 | # i = 1 |
---|
800 | # loop: |
---|
801 | # temp = i * i |
---|
802 | # total += temp |
---|
803 | # inc i |
---|
804 | # if i <= maxnum goto loop |
---|
805 | # |
---|
806 | # \# Output result. |
---|
807 | # print "The sum of the first " |
---|
808 | # print maxnum |
---|
809 | # print " squares is " |
---|
810 | # print total |
---|
811 | # print ".\n" |
---|
812 | # .end |
---|
813 | # |
---|
814 | # |
---|
815 | ok 41 - docs/intro.pod |
---|
816 | # |
---|
817 | # |
---|
818 | # .sub factorial |
---|
819 | # \# Get input parameter. |
---|
820 | # .param int n |
---|
821 | # |
---|
822 | # \# return (n > 1 ? n * factorial(n - 1) : 1) |
---|
823 | # .local int result |
---|
824 | # |
---|
825 | # if n > 1 goto recurse |
---|
826 | # result = 1 |
---|
827 | # goto return |
---|
828 | # |
---|
829 | # recurse: |
---|
830 | # $I0 = n - 1 |
---|
831 | # result = factorial($I0) |
---|
832 | # result *= n |
---|
833 | # |
---|
834 | # return: |
---|
835 | # .return (result) |
---|
836 | # .end |
---|
837 | # |
---|
838 | # |
---|
839 | # .sub main :main |
---|
840 | # .local int f, i |
---|
841 | # |
---|
842 | # \# We'll do factorial 0 to 10. |
---|
843 | # i = 0 |
---|
844 | # loop: |
---|
845 | # f = factorial(i) |
---|
846 | # |
---|
847 | # print "Factorial of " |
---|
848 | # print i |
---|
849 | # print " is " |
---|
850 | # print f |
---|
851 | # print ".\n" |
---|
852 | # |
---|
853 | # inc i |
---|
854 | # if i <= 10 goto loop |
---|
855 | # .end |
---|
856 | # |
---|
857 | # |
---|
858 | ok 42 - docs/user/pir/objects.pod |
---|
859 | # |
---|
860 | # |
---|
861 | # .namespace [ "Person" ] |
---|
862 | # |
---|
863 | # .sub run |
---|
864 | # say "Run Forrest, Run!" |
---|
865 | # .end |
---|
866 | # |
---|
867 | # .namespace [ "Process" ] |
---|
868 | # |
---|
869 | # .sub run |
---|
870 | # say "Running process \#53" |
---|
871 | # .end |
---|
872 | # |
---|
873 | # |
---|
874 | ok 43 - docs/user/pir/objects.pod |
---|
875 | # |
---|
876 | # |
---|
877 | # .sub _ :main |
---|
878 | # $P0 = newclass 'Dog' |
---|
879 | # .local pmc spot |
---|
880 | # spot = new 'Dog' |
---|
881 | # .end |
---|
882 | # |
---|
883 | # |
---|
884 | ok 44 - docs/user/pir/objects.pod |
---|
885 | # |
---|
886 | # |
---|
887 | # .namespace [ "Cow" ] |
---|
888 | # |
---|
889 | # .sub speak :method |
---|
890 | # print "Moo\n" |
---|
891 | # .end |
---|
892 | # |
---|
893 | # .namespace [ "Dog" ] |
---|
894 | # |
---|
895 | # .sub speak :method |
---|
896 | # print "Woof\n" |
---|
897 | # .end |
---|
898 | # |
---|
899 | # .namespace [ "Pig" ] |
---|
900 | # |
---|
901 | # .sub speak :method |
---|
902 | # print "Oink\n" |
---|
903 | # .end |
---|
904 | # |
---|
905 | # .namespace [] |
---|
906 | # |
---|
907 | # .sub _ :main |
---|
908 | # $P0 = newclass "Cow" |
---|
909 | # $P0 = newclass "Dog" |
---|
910 | # $P0 = newclass "Pig" |
---|
911 | # |
---|
912 | # .local pmc elsie, fido, porky |
---|
913 | # |
---|
914 | # elsie = new "Cow" |
---|
915 | # fido = new "Dog" |
---|
916 | # porky = new "Pig" |
---|
917 | # |
---|
918 | # elsie.'speak'() |
---|
919 | # fido.'speak'() |
---|
920 | # porky.'speak'() |
---|
921 | # .end |
---|
922 | # |
---|
923 | # |
---|
924 | ok 45 - docs/user/pir/objects.pod |
---|
925 | # |
---|
926 | # |
---|
927 | # .namespace [ 'Foo' ] |
---|
928 | # |
---|
929 | # .sub foo :method |
---|
930 | # print "foo\n" |
---|
931 | # .end |
---|
932 | # |
---|
933 | # .sub bar :method |
---|
934 | # print "bar\n" |
---|
935 | # .end |
---|
936 | # |
---|
937 | # .namespace [] |
---|
938 | # |
---|
939 | # .sub _ :main |
---|
940 | # $P0 = newclass "Foo" |
---|
941 | # .local pmc f |
---|
942 | # f = new "Foo" |
---|
943 | # |
---|
944 | # .local string m |
---|
945 | # m = "foo" |
---|
946 | # f.m() |
---|
947 | # m = "bar" |
---|
948 | # f.m() |
---|
949 | # .end |
---|
950 | # |
---|
951 | # |
---|
952 | ok 46 - docs/user/pir/objects.pod |
---|
953 | # |
---|
954 | # |
---|
955 | # .namespace [ "Dog" ] |
---|
956 | # |
---|
957 | # .sub name :method |
---|
958 | # .local pmc name |
---|
959 | # name = getattribute self, "name" |
---|
960 | # print name |
---|
961 | # .end |
---|
962 | # |
---|
963 | # .sub speak :method |
---|
964 | # print "woof" |
---|
965 | # .end |
---|
966 | # |
---|
967 | # .namespace [] |
---|
968 | # |
---|
969 | # .sub _ :main |
---|
970 | # $P0 = newclass "Dog" |
---|
971 | # addattribute $P0, "name" |
---|
972 | # |
---|
973 | # .local pmc dog |
---|
974 | # dog = new "Dog" |
---|
975 | # $P0 = new "String" |
---|
976 | # $P0 = "Phideaux" |
---|
977 | # setattribute dog, "name", $P0 |
---|
978 | # |
---|
979 | # dog.'name'() |
---|
980 | # print " says " |
---|
981 | # dog.'speak'() |
---|
982 | # print "!\n" |
---|
983 | # .end |
---|
984 | # |
---|
985 | # |
---|
986 | ok 47 - docs/user/pir/objects.pod |
---|
987 | # |
---|
988 | # |
---|
989 | # .namespace [ "Animal" ] |
---|
990 | # |
---|
991 | # .sub setname :method |
---|
992 | # .param string name |
---|
993 | # $P0 = new 'String' |
---|
994 | # $P0 = name |
---|
995 | # setattribute self, "name", $P0 |
---|
996 | # .end |
---|
997 | # |
---|
998 | # .sub getname :method |
---|
999 | # $P0 = getattribute self, "name" |
---|
1000 | # print $P0 |
---|
1001 | # .end |
---|
1002 | # |
---|
1003 | # .sub speak :method |
---|
1004 | # .local string name, sound |
---|
1005 | # name = self.'getname'() |
---|
1006 | # sound = self.'sound'() |
---|
1007 | # print name |
---|
1008 | # print " says " |
---|
1009 | # print sound |
---|
1010 | # print "\n" |
---|
1011 | # .end |
---|
1012 | # |
---|
1013 | # .namespace [ "Cow" ] |
---|
1014 | # |
---|
1015 | # .sub sound :method |
---|
1016 | # .return( "moo" ) |
---|
1017 | # .end |
---|
1018 | # |
---|
1019 | # .namespace [ "Dog" ] |
---|
1020 | # |
---|
1021 | # .sub sound :method |
---|
1022 | # .return( "woof" ) |
---|
1023 | # .end |
---|
1024 | # |
---|
1025 | # .namespace [ "Pig" ] |
---|
1026 | # |
---|
1027 | # .sub sound :method |
---|
1028 | # .return( "oink" ) |
---|
1029 | # .end |
---|
1030 | # |
---|
1031 | # .namespace [] |
---|
1032 | # |
---|
1033 | # .sub _ :main |
---|
1034 | # $P0 = newclass "Animal" |
---|
1035 | # addattribute $P0, "name" |
---|
1036 | # $P0 = subclass "Animal", "Cow" |
---|
1037 | # $P0 = subclass "Animal", "Dog" |
---|
1038 | # $P0 = subclass "Animal", "Pig" |
---|
1039 | # |
---|
1040 | # .local pmc cow, dog, pig |
---|
1041 | # |
---|
1042 | # cow = new "Cow" |
---|
1043 | # cow.'setname'("Elsie") |
---|
1044 | # dog = new "Dog" |
---|
1045 | # dog.'setname'("Snoopy") |
---|
1046 | # pig = new "Pig" |
---|
1047 | # pig.'setname'("Porky") |
---|
1048 | # |
---|
1049 | # cow.'speak'() |
---|
1050 | # dog.'speak'() |
---|
1051 | # pig.'speak'() |
---|
1052 | # .end |
---|
1053 | # |
---|
1054 | # |
---|
1055 | ok 48 - docs/compiler_faq.pod |
---|
1056 | # |
---|
1057 | # .sub my_coro \# automagically a Coroutine PMC |
---|
1058 | # .param pmc result |
---|
1059 | # \#... |
---|
1060 | # .yield (result) |
---|
1061 | # \#... |
---|
1062 | # .end |
---|
1063 | # |
---|
1064 | ok 49 - docs/compiler_faq.pod |
---|
1065 | # |
---|
1066 | # .sub foo |
---|
1067 | # \# ... |
---|
1068 | # .tailcall bar(42) \# tail call sub bar |
---|
1069 | # .end |
---|
1070 | # |
---|
1071 | # .sub bar |
---|
1072 | # .param int answer |
---|
1073 | # inc answer |
---|
1074 | # .return(answer) |
---|
1075 | # .end |
---|
1076 | # |
---|
1077 | ok 50 - docs/user/pir/exceptions.pod |
---|
1078 | # |
---|
1079 | # |
---|
1080 | # .include 'include/except_severity.pasm' |
---|
1081 | # |
---|
1082 | # .sub 'dostuff' |
---|
1083 | # .local pmc eh |
---|
1084 | # eh = new 'ExceptionHandler' |
---|
1085 | # set_addr eh, handler |
---|
1086 | # eh.'min_severity'(.EXCEPT_ERROR) |
---|
1087 | # push_eh eh |
---|
1088 | # \# ... stuff that might throw an error |
---|
1089 | # pop_eh |
---|
1090 | # .return (1) |
---|
1091 | # handler: |
---|
1092 | # .local pmc ex |
---|
1093 | # .local string msg |
---|
1094 | # .get_results (ex) |
---|
1095 | # print "There was a fatal error in dostuff: " |
---|
1096 | # msg = ex |
---|
1097 | # say ex |
---|
1098 | # exit 1 |
---|
1099 | # .end |
---|
1100 | # |
---|
1101 | # |
---|
1102 | 1..50 |
---|
1103 | Dubious, test returned 8 (wstat 2048, 0x800) |
---|
1104 | Failed 8/50 subtests |
---|
1105 | |
---|
1106 | Test Summary Report |
---|
1107 | ------------------- |
---|
1108 | t/examples/pod.t (Wstat: 2048 Tests: 50 Failed: 8) |
---|
1109 | Failed tests: 20, 25, 28-29, 31-34 |
---|
1110 | Non-zero exit status: 8 |
---|
1111 | Files=1, Tests=50, 1 wallclock secs ( 0.12 usr 0.01 sys + 0.86 cusr 0.42 csys = 1.41 CPU) |
---|
1112 | Result: FAIL |
---|