error:imcc:syntax error, unexpected STRINGC, expecting '(' ('"expired"') in file '/tmp/1gwF_yRDuu.pir' line 11 error:imcc:syntax error, unexpected STRINGC, expecting '(' ('"timer"') in file '/tmp/1gwF_yRDuu.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/4gxj7SjW6U.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/T01udkLNqa.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/Q7rz5y8THb.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/lcqLDnOhtE.pir' line 12 error:imcc:syntax error, unexpected VAR, expecting '(' ('b') in file '/tmp/lcqLDnOhtE.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/OoAnD0DsUw.pir' line 4 error:imcc:syntax error, unexpected INTV, expecting STRINGC ('int') in file '/tmp/OoAnD0DsUw.pir' line 5 error:imcc:syntax error, unexpected INTV, expecting STRINGC ('int') in file '/tmp/OoAnD0DsUw.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/_fIsrlJkwA.pir' line 5 error:imcc:syntax error, unexpected PARROT_OP, expecting '(' ('fact') in file '/tmp/_fIsrlJkwA.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/n7lSR39Fuc.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. t/examples/pod.t .. ok 1 - docs/book/ch03_pir_basics.pod # # .sub main # $S0 = "hello " # print $S0 # $S1 = "world!" # print $S1 # .end # ok 2 - docs/book/ch03_pir_basics.pod # # .sub main # $S0 = "hello " # print $S0 # $S0 = "world!" # print $S0 # .end # ok 3 - docs/book/ch03_pir_basics.pod # # .sub main # print "Hello, Polly.\n" # .end # ok 4 - docs/book/ch03_pir_basics.pod # # .sub first # print "Polly want a cracker?\n" # .end # # .sub second :main # print "Hello, Polly.\n" # .end # ok 5 - docs/book/ch03_pir_basics.pod # # .sub first :main # print "Polly want a cracker?\n" # .end # # .sub second # print "Hello, Polly.\n" # .end # ok 6 - docs/book/ch03_pir_basics.pod # # .sub _main # goto L1 # print "never printed" # L1: # print "after branch\n" # end # .end # ok 7 - docs/book/ch03_pir_basics.pod # # .sub _main # $I0 = 42 # if $I0 goto L1 # print "never printed" # L1: print "after branch\n" # end # .end # ok 8 - docs/book/ch03_pir_basics.pod # # .sub _main # $I0 = 42 # $I1 = 43 # if $I0 < $I1 goto L1 # print "never printed" # L1: # print "after branch\n" # end # .end # ok 9 - docs/book/ch03_pir_basics.pod # # .sub _main # $I0 = 1 \# product # $I1 = 5 \# counter # # REDO: \# start of loop # $I0 = $I0 * $I1 # dec $I1 # if $I1 > 0 goto REDO \# end of loop # # print $I0 # print "\n" # end # .end # ok 10 - docs/book/ch03_pir_basics.pod # # .sub _main # $I0 = 1 \# product # $I1 = 5 \# counter # # REDO: \# start of loop # if $I1 <= 0 goto LAST # $I0 = $I0 * $I1 # dec $I1 # goto REDO # LAST: \# end of loop # # print $I0 # print "\n" # end # .end # ok 11 - docs/book/ch03_pir_basics.pod # # .sub main # loop_top: # $S0 = read 10 # print $S0 # goto loop_top # .end # ok 12 - docs/book/ch03_pir_basics.pod # # .sub main # $P0 = getstdout # $P1 = open "myfile.txt", "r" # loop_top: # $S0 = readline $P1 # print $P0, $S0 # if $P1 goto loop_top # close $P1 # .end # ok 13 - docs/user/pir/pmcs.pod # # # .sub _ :main # .param pmc args # loop: # unless args goto end_loop \# line 4 # $S0 = shift args # print $S0 # print "\n" # goto loop # end_loop: # .end # # ok 14 - docs/user/pir/pmcs.pod # # # .sub _ :main # .param pmc args # .local int argc # argc = args \# line 4 # $I0 = 0 # loop: # unless $I0 < argc goto end_loop # print $I0 # print "\t" # $S0 = args[$I0] \# line 10 # print $S0 # print "\n" # inc $I0 # goto loop # end_loop: # .end # # ok 15 - docs/user/pir/pmcs.pod # # # .sub _ :main # .param pmc args # $S0 = typeof args # print $S0 # print "\n" # .end # # ok 16 - docs/user/pir/pmcs.pod # # # .sub _ :main # .local pmc env, iter # .local string key, value # # env = new 'Env' \# line 3 # iter = new 'Iterator', env \# line 4 # iterloop: # unless iter goto iterend # key = shift iter \# line 8 # value = env[key] # print key # print ":" # print value # print "\n" # goto iterloop # iterend: # .end # # ok 17 - docs/user/pir/pmcs.pod # # # .sub _ :main # .param pmc args # .local pmc cmdline # cmdline = new 'Iterator', args # loop: # unless cmdline goto end_loop # $S0 = shift cmdline # print $S0 # print "\n" # goto loop # end_loop: # .end # # ok 18 - docs/user/pir/pmcs.pod # # # .sub _ :main # $P0 = new 'Random' # $N0 = $P0 # print $N0 # print "\n" # $N0 = $P0 # print $N0 # print "\n" # .end # # ok 19 - docs/user/pir/pmcs.pod # # # .sub _ :main # $P0 = new 'Exception' # $P0 = "The sky is falling!" # throw $P0 # .end # # not ok 20 - 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 # # ok 21 - docs/user/pir/intro.pod # # # .sub main :main # print "hello world\n" # .end # # ok 22 - docs/user/pir/intro.pod # # # .sub main :main # hello() # .end # # .sub hello # print "Hello World\n" # .end # # ok 23 - docs/user/pir/intro.pod # # # .sub main :main # hello("leo") # hello("chip") # .end # # .sub hello # .param string person # print "Hello " # print person # print "\n" # .end # # not ok 24 - 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 # # ok 25 - docs/user/pir/intro.pod # # # .sub main # .param int a # .param int b :named("age") # \# ... # .end # # ok 26 - docs/book/ch05_pasm.pod # # # LABEL: # print "The answer is: " # print 42 # print "\n" # end \# halt the interpreter # # not ok 27 - 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 # # not ok 28 - 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 # # ok 29 - docs/book/ch04_pir_subroutines.pod # # # .sub main :main # 'MySub'("name" => "Bob", "age" => 42) \# Same! # .end # # not ok 30 - 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 # # not ok 31 - 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 # # not ok 32 - 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 # # not ok 33 - 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 # # ok 34 - docs/book/ch04_pir_subroutines.pod # # # .sub main # .local pmc class # .local pmc obj # newclass class, "Foo" \# create a new Foo class # new obj, "Foo" \# instantiate a Foo object # obj."meth"() \# call obj."meth" which is actually # print "done\n" \# in the "Foo" namespace # end # .end # # .namespace [ "Foo" ] \# start namespace "Foo" # # .sub meth :method \# define Foo::meth global # print "in meth\n" # $S0 = "other_meth" \# method names can be in a register too # self.$S0() \# self is the invocant # .end # # .sub other_meth :method \# define another method # print "in other_meth\n" \# as above Parrot provides a return # .end \# statement # # ok 35 - docs/intro.pod # # # .sub main # print "Hello world!\n" # .end # # ok 36 - docs/intro.pod # # # .sub main # set $S0, "Hello world!\n" # print $S0 # .end # # ok 37 - docs/intro.pod # # # .sub main # $S0 = "Hello world!\n" # print $S0 # .end # # ok 38 - docs/intro.pod # # # .sub main # .local string hello # hello = "Hello world!\n" # print hello # .end # # ok 39 - docs/intro.pod # # # .sub main # \# State the number of squares to sum. # .local int maxnum # maxnum = 10 # # \# We'll use some named registers. Note that we can declare many # \# registers of the same type on one line. # .local int i, total, temp # total = 0 # # \# Loop to do the sum. # i = 1 # loop: # temp = i * i # total += temp # inc i # if i <= maxnum goto loop # # \# Output result. # print "The sum of the first " # print maxnum # print " squares is " # print total # print ".\n" # .end # # ok 40 - docs/intro.pod # # # .sub factorial # \# Get input parameter. # .param int n # # \# return (n > 1 ? n * factorial(n - 1) : 1) # .local int result # # if n > 1 goto recurse # result = 1 # goto return # # recurse: # $I0 = n - 1 # result = factorial($I0) # result *= n # # return: # .return (result) # .end # # # .sub main :main # .local int f, i # # \# We'll do factorial 0 to 10. # i = 0 # loop: # f = factorial(i) # # print "Factorial of " # print i # print " is " # print f # print ".\n" # # inc i # if i <= 10 goto loop # .end # # ok 41 - docs/user/pir/objects.pod # # # .namespace [ "Person" ] # # .sub run # say "Run Forrest, Run!" # .end # # .namespace [ "Process" ] # # .sub run # say "Running process \#53" # .end # # ok 42 - docs/user/pir/objects.pod # # # .sub _ :main # $P0 = newclass 'Dog' # .local pmc spot # spot = new 'Dog' # .end # # ok 43 - docs/user/pir/objects.pod # # # .namespace [ "Cow" ] # # .sub speak :method # print "Moo\n" # .end # # .namespace [ "Dog" ] # # .sub speak :method # print "Woof\n" # .end # # .namespace [ "Pig" ] # # .sub speak :method # print "Oink\n" # .end # # .namespace [] # # .sub _ :main # $P0 = newclass "Cow" # $P0 = newclass "Dog" # $P0 = newclass "Pig" # # .local pmc elsie, fido, porky # # elsie = new "Cow" # fido = new "Dog" # porky = new "Pig" # # elsie.'speak'() # fido.'speak'() # porky.'speak'() # .end # # ok 44 - docs/user/pir/objects.pod # # # .namespace [ 'Foo' ] # # .sub foo :method # print "foo\n" # .end # # .sub bar :method # print "bar\n" # .end # # .namespace [] # # .sub _ :main # $P0 = newclass "Foo" # .local pmc f # f = new "Foo" # # .local string m # m = "foo" # f.m() # m = "bar" # f.m() # .end # # ok 45 - docs/user/pir/objects.pod # # # .namespace [ "Dog" ] # # .sub name :method # .local pmc name # name = getattribute self, "name" # print name # .end # # .sub speak :method # print "woof" # .end # # .namespace [] # # .sub _ :main # $P0 = newclass "Dog" # addattribute $P0, "name" # # .local pmc dog # dog = new "Dog" # $P0 = new "String" # $P0 = "Phideaux" # setattribute dog, "name", $P0 # # dog.'name'() # print " says " # dog.'speak'() # print "!\n" # .end # # ok 46 - docs/user/pir/objects.pod # # # .namespace [ "Animal" ] # # .sub setname :method # .param string name # $P0 = new 'String' # $P0 = name # setattribute self, "name", $P0 # .end # # .sub getname :method # $P0 = getattribute self, "name" # print $P0 # .end # # .sub speak :method # .local string name, sound # name = self.'getname'() # sound = self.'sound'() # print name # print " says " # print sound # print "\n" # .end # # .namespace [ "Cow" ] # # .sub sound :method # .return( "moo" ) # .end # # .namespace [ "Dog" ] # # .sub sound :method # .return( "woof" ) # .end # # .namespace [ "Pig" ] # # .sub sound :method # .return( "oink" ) # .end # # .namespace [] # # .sub _ :main # $P0 = newclass "Animal" # addattribute $P0, "name" # $P0 = subclass "Animal", "Cow" # $P0 = subclass "Animal", "Dog" # $P0 = subclass "Animal", "Pig" # # .local pmc cow, dog, pig # # cow = new "Cow" # cow.'setname'("Elsie") # dog = new "Dog" # dog.'setname'("Snoopy") # pig = new "Pig" # pig.'setname'("Porky") # # cow.'speak'() # dog.'speak'() # pig.'speak'() # .end # # ok 47 - docs/compiler_faq.pod # # .sub my_coro \# automagically a Coroutine PMC # .param pmc result # \#... # .yield (result) # \#... # .end # ok 48 - docs/compiler_faq.pod # # .sub foo # \# ... # .tailcall bar(42) \# tail call sub bar # .end # # .sub bar # .param int answer # inc answer # .return(answer) # .end # ok 49 - docs/user/pir/exceptions.pod # # # .include 'include/except_severity.pasm' # # .sub 'dostuff' # .local pmc eh # eh = new 'ExceptionHandler' # set_addr eh, handler # eh.'min_severity'(.EXCEPT_ERROR) # push_eh eh # \# ... stuff that might throw an error # pop_eh # .return (1) # handler: # .local pmc ex # .local string msg # .get_results (ex) # print "There was a fatal error in dostuff: " # msg = ex # say ex # exit 1 # .end # # 1..49 Dubious, test returned 8 (wstat 2048, 0x800) Failed 8/49 subtests Test Summary Report ------------------- t/examples/pod.t (Wstat: 2048 Tests: 49 Failed: 8) Failed tests: 20, 24, 27-28, 30-33 Non-zero exit status: 8 Files=1, Tests=49, 1 wallclock secs ( 0.12 usr 0.00 sys + 0.86 cusr 0.43 csys = 1.41 CPU) Result: FAIL