t/examples/pod....error:imcc:syntax error, unexpected STRINGC, expecting '(' ('"expired"') in file '/tmp/oFLv8VF8TK.pir' line 11 error:imcc:syntax error, unexpected STRINGC, expecting '(' ('"timer"') in file '/tmp/oFLv8VF8TK.pir' line 17 # Failed test 'docs/user/pir/pmcs.pod # # # .include "timer.pasm" \# for the timer constants # # .sub expired # print "Timer has expired!\n" # .end # # .sub _ :main # $P0 = new 'Timer' # $P1 = global "expired" # # $P0[.PARROT_TIMER_HANDLER] = $P1 \# call sub in $P1 when timer goes off # $P0[.PARROT_TIMER_SEC] = 2 \# trigger every 2 seconds # $P0[.PARROT_TIMER_REPEAT] = -1 \# repeat indefinitely # $P0[.PARROT_TIMER_RUNNING] = 1 \# start timer immediately # global "timer" = $P0 \# keep the timer around # # $I0 = 0 # loop: # print $I0 # print ": running...\n" # inc $I0 # sleep 1 \# wait a second # goto loop # .end # # ' # at t/examples/pod.t line 49. # got: '256' # expected: '0' error:imcc:syntax error, unexpected IDENTIFIER, expecting $end ('This') in file '/tmp/4Wsizg0h5B.pir' line 21 # Failed test 'docs/user/pir/intro.pod # # # .sub main :main # $I1 = factorial(5) # print $I1 # print "\n" # .end # # .sub factorial # .param int i # if i > 1 goto recur # .return (1) # recur: # $I1 = i - 1 # $I2 = factorial($I1) # $I2 *= i # .return ($I2) # .end # # =cut # # This example also shows that PIR subroutines may be recursive just as in # a high-level language. # # =head2 Named Arguments # # As some other languages as Python and Perl support named arguments, # PIR supports them as well. # # As before, I need to use C<.param> for each named argument, but you need to # specify a flag indicating the parameter is named: # # .sub func # .param int a :named("foo") # # The subroutine will receive an integer named "foo", and inside of the # subroutine that integer will be known as "a". # # When calling the function, I need to pass the names of the # arguments. For that there are two syntaxes: # # func( 10 :named("foo") ) \# or # func( "foo" => 10 ) # # Note that with named arguments, you may rearrange the order of your # parameters at will. # # =begin PIR # # .sub foo # .param string "name" => a # .param int "age" => b # .param string "gender" => c # \# ... # .end # # ' # at t/examples/pod.t line 49. # got: '256' # expected: '0' error:imcc:The opcode 'fact_i' (fact<1>) was not found. Check the type and number of the arguments in file '/tmp/PHze5YBsNQ.pir' line 10 # Failed test 'docs/book/ch04_pir_subroutines.pod # # # \# factorial.pir # .sub main # .local int count # .local int product # count = 5 # product = 1 # # $I0 = fact(count, product) # # print $I0 # print "\n" # end # .end # # .sub fact # .param int c # .param int p # # loop: # if c <= 1 goto fin # p = c * p # dec c # branch loop # fin: # .return p # .end # # ' # at t/examples/pod.t line 49. # got: '512' # expected: '0' error:imcc:The opcode 'concat_s_sc_i' (concat<3>) was not found. Check the type and number of the arguments in file '/tmp/JcNjVN4Ljy.pir' line 7 # Failed test 'docs/book/ch04_pir_subroutines.pod # # # .sub 'MySub' # .param int yrs :named("age") # .param string call :named("name") # $S0 = "Hello " . call # $S1 = "You are " . yrs # $S1 = $S1 . " years old # print $S0 # print $S1 # .end # # .sub main :main # 'MySub'("age" => 42, "name" => "Bob") # .end # # ' # at t/examples/pod.t line 49. # got: '512' # expected: '0' error:imcc:syntax error, unexpected '\n', expecting COMMA or ')' in file '/tmp/FTZhyWsid2.pir' line 12 error:imcc:syntax error, unexpected VAR, expecting '(' ('b') in file '/tmp/FTZhyWsid2.pir' line 20 # Failed test 'docs/book/ch04_pir_subroutines.pod # # # .sub main :main # .local int value # value = add_two(5) # say value # .end # # .sub add_two # .param int value # .local int val2 # val2 = add_one(value # .tailcall add_one(val2) # .end # # .sub add_one # .param int a # .local int b # b = a + 1 # return b # .end # # ' # at t/examples/pod.t line 49. # got: '256' # expected: '0' error:imcc:syntax error, unexpected INTV, expecting STRINGC ('int') in file '/tmp/wlhMKOemjj.pir' line 4 error:imcc:syntax error, unexpected INTV, expecting STRINGC ('int') in file '/tmp/wlhMKOemjj.pir' line 5 error:imcc:syntax error, unexpected INTV, expecting STRINGC ('int') in file '/tmp/wlhMKOemjj.pir' line 11 # Failed test 'docs/book/ch04_pir_subroutines.pod # # # .sub 'MyOuter' # .lex int x # .lex int y # 'MyInner'() # \# only x and y are visible here # .end # # .sub 'MyInner' :outer('MyOuter') # .lex int z # \#x, y, and z are all "visible" here # .end # # ' # at t/examples/pod.t line 49. # got: '256' # expected: '0' error:imcc:syntax error, unexpected PARROT_OP, expecting '(' ('fact') in file '/tmp/tp7yEZjet4.pir' line 5 error:imcc:syntax error, unexpected PARROT_OP, expecting '(' ('fact') in file '/tmp/tp7yEZjet4.pir' line 9 # Failed test 'docs/book/ch04_pir_subroutines.pod # # # .sub main # $I1 = 5 \# counter # call fact \# same as "bsr fact" # print $I0 # print "\n" # $I1 = 6 \# counter # call fact # print $I0 # print "\n" # end # # fact: # $I0 = 1 \# product # L1: # $I0 = $I0 * $I1 # dec $I1 # if $I1 > 0 goto L1 # ret # .end # # ' # at t/examples/pod.t line 49. # got: '256' # expected: '0' error:imcc:syntax error, unexpected ADV_INVOCANT, expecting '\n' (':invocant') in file '/tmp/F4D162WOA5.pir' line 9 # Failed test 'docs/book/ch04_pir_subroutines.pod # # # .sub "MyMethod" :method # $S0 = self \# Already defined as "self" # say $S0 # .end # # .sub "MyMethod2" :method # .param pmc item :invocant \# "self" is now called "item" # $S0 = item # say $S0 # .end # # ' # at t/examples/pod.t line 49. # got: '256' # expected: '0' # Looks like you failed 8 tests of 49. Dubious, test returned 8 (wstat 2048, 0x800) Failed 8/49 subtests Test Summary Report ------------------- t/examples/pod (Wstat: 2048 Tests: 49 Failed: 8) Failed tests: 20, 24, 27-28, 30-33 Non-zero exit status: 8 Files=1, Tests=49, 4 wallclock secs ( 0.00 usr 0.00 sys + 0.95 cusr 0.48 csys = 1.43 CPU) Result: FAIL