id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,lang,patch,platform
1090,Convert t/pmc/exporter.t to PIR,kurahaupo,,"Index: t/pmc/exporter.t
===================================================================
--- t/pmc/exporter.t    (revision 41672)
+++ t/pmc/exporter.t    (working copy)
@@ -1,13 +1,7 @@
-#!perl
+#!parrot
 # Copyright (C) 2007, Parrot Foundation.
 # $Id$
 
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 12;
-
 =head1 NAME
 
 t/pmc/exporter.t - test the Exporter PMC
@@ -23,30 +17,43 @@
 =cut
 
 # L<PDD17/Exporter PMC>
-pir_output_is( <<'CODE', <<'OUT', 'new' );
-.sub 'test' :main
+
+.sub 'main' :main
+    .include 'test_more.pir'
+    plan(26)
+
+    test_1()     # 3 tests
+    test_2()     # 4 tests
+    test_3()     # 5 tests
+    test_4()     # 6 tests
+    test_5()     # 1 tests
+    test_6()     # 1 tests
+    test_7()     # 1 tests
+    test_8()     # 1 tests
+    test_9()     # 1 tests
+    test_10()    # 1 tests
+    test_11()    # 1 tests
+    test_12()    # 1 tests
+
+.end
+
+.sub 'test_1'
     $P0 = new ['Exporter']
-    say ""ok 1 - $P0 = new ['Exporter']""
+    $I0 = isnull $P0
+    is( $I0, 0, 'Constructed ""Exporter"" object' )
 
     $I0 = isa $P0, 'Exporter'
-    if $I0 goto ok_2
-    print 'not '
-  ok_2:
-    say ""ok 2 - isa $P0, 'Exporter'""
+    ok( $I0, '... isa ""Exporter""' )
+
+    $I0 = can $P0, 'destination'
+    ok( $I0, '... can ""destination""' )
 .end
-CODE
-ok 1 - $P0 = new ['Exporter']
-ok 2 - isa $P0, 'Exporter'
-OUT
 
-pir_output_is( <<'CODE', <<'OUT', 'source' );
-.sub 'test' :main
+.sub 'test_2'
     $P0 = new ['Exporter']
     $P1 = $P0.'source'()
-    if null $P1 goto ok_1
-    print 'not '
-  ok_1:
-    say 'ok 1 - source() returns PMCNULL upon Exporter init'
+    $I0 = isnull $P1
+    ok( $I0, 'source() returns PMCNULL upon Exporter init' )
 
     # get a NameSpace PMC for testing
     # RT #46859 replace with make_namespace, when implemented
@@ -55,111 +62,70 @@
 
     $P0.'source'(ns)
     $P1 = $P0.'source'()
-    if $P1 == 'Eponymous' goto ok_2
-    print 'not '
-  ok_2:
-    say 'ok 2 - source() with args sets source namespace'
+    is( $P1, 'Eponymous', 'source() with args sets source namespace' )
 
     $P1 = clone ns
-
+    $I0 = 1
     push_eh ok_3
     $P0.'source'(ns, $P1)
+    $I0 = 0
+  ok_3:
     pop_eh
+    ok( $I0, 'source() with too many args fails' )
 
-    print 'not '
-  ok_3:
-    say 'ok 3 - source() with too many args fails'
-
     push_eh ok_4
+    $I0 = 1
     $P0.'source'('foo')
-    pop_eh
-    print 'not '
+    $I0 = 0
 
   ok_4:
-    say 'ok 4 - source() with non-namespace arg throws exception'
+    pop_eh
+    ok( $I0, 'source() with non-namespace arg throws exception' )
 .end
 
-
-# RT #46859 replace with make_namespace, when implemented
-.namespace ['Eponymous']
-.sub 'Eponymous' :anon
-.end
-CODE
-ok 1 - source() returns PMCNULL upon Exporter init
-ok 2 - source() with args sets source namespace
-ok 3 - source() with too many args fails
-ok 4 - source() with non-namespace arg throws exception
-OUT
-
-pir_output_is( <<'CODE', <<'OUT', 'destination' );
-.sub 'test' :main
+.sub 'test_3'
     $P0 = new ['Exporter']
     $P1 = $P0.'destination'()
-    unless null $P1 goto ok_1
-    print 'not '
-  ok_1:
-    say 'ok 1 - destination() with no args returns destination namespace'
+    $I0 = isnull $P1
+    is( $I0, 0, 'destination() with no args returns destination namespace' )
 
     $P99 = get_namespace
-    if $P1 == $P99 goto ok_2
-    print 'not '
-  ok_2:
-    say 'ok 2 - ...which is current namespace at first'
+    is( $P1, $P99, 'ok 2 - ...which is current namespace at first' )
 
     # get a NameSpace PMC for testing
     # RT #46859 replace with make_namespace, when implemented
     .local pmc ns
     ns = get_namespace ['Eponymous']
-
     $P0.'destination'(ns)
     $P1 = $P0.'destination'()
-    if $P1 == 'Eponymous' goto ok_3
-    print 'not '
-  ok_3:
-    say 'ok 3 - destination() with args sets destination namespace'
+    is( $P1, 'Eponymous', 'destination() with args sets destination namespace' )
 
     $P1 = clone ns
-
     push_eh ok_4
+    $I0 = 1
     $P0.'destination'(ns, $P1)
+    $I0 = 0
+  ok_4:
     pop_eh
+    ok( $I0, 'destination() with too many args fails' )
 
-    print 'not '
-  ok_4:
-    say 'ok 4 - destination() with too many args fails'
-
     push_eh ok_5
+    $I0 = 1
     $P0.'destination'('foo')
+    $I0 = 0
+  ok_5:
     pop_eh
-    print 'not '
+    ok( $I0, 'destination() with non-namespace arg throws exception' )
 
-  ok_5:
-    say 'ok 5 - destination() with non-namespace arg throws exception'
 .end
 
 
-# RT #46859 replace with make_namespace, when implemented
-.namespace ['Eponymous']
-.sub 'Eponymous' :anon
-.end
-CODE
-ok 1 - destination() with no args returns destination namespace
-ok 2 - ...which is current namespace at first
-ok 3 - destination() with args sets destination namespace
-ok 4 - destination() with too many args fails
-ok 5 - destination() with non-namespace arg throws exception
-OUT
-
-pir_output_is( <<'CODE', <<'OUT', 'globals' );
-.sub 'test' :main
+.sub 'test_4'
     $P0 = new ['Exporter']
 
     $P1 = $P0.'globals'()
     $I0 = isnull $P1
-    if $I0 goto ok_1
-    print 'not '
-  ok_1:
-    say 'ok 1 - globals() returns PMCNULL upon Exporter init'
+    ok( $I0, 'globals() returns PMCNULL upon Exporter init' )
 
     # create an array to store globals in
     $P99 = new ['ResizableStringArray']
@@ -167,30 +133,29 @@
     $P0.'globals'($P99)
     $P1 = $P0.'globals'()
     $I0 = isnull $P1
-    if $I0 goto ok_2
-    print 'not '
-  ok_2:
-    say 'ok 2 - globals() with empty array arg sets PMCNULL'
+    ok( $I0, 'globals() with empty array arg sets PMCNULL' )
 
     $P99 = push 'Alex'
     $P99 = push 'Prince'
 
+    $I9 = 1
     $P0.'globals'($P99)
     $P1 = $P0.'globals'()
     $I0 = does $P1, 'hash'
+    eq $I0, 0, nok_3
     $I99 = $P99
     $I1 = $P1
-    unless $I0 == 1 goto nok_3
-    unless $I1 == $I99 goto nok_3
-    unless $I1 == 2 goto ok_3
+    ne $I1, $I99, nok_3
+    ne $I1, 2, ok_3     # <<< should this be nok_3 instead?!?
     $I0 = exists $P1['Prince']
-    unless $I0 goto nok_3
+    eq $I0, 0, nok_3
     $I0 = exists $P1['Alex']
+    eq $I0, 0, nok_3
     goto ok_3
   nok_3:
-    print 'not '
+    $I9 = 0
   ok_3:
-    say 'ok 3 - globals() with array arg sets globals hash (hash with two keys)'
+    ok( $I9, 'globals() with array arg sets globals hash (hash with two keys)' )
 
     # create a hash to store globals in
     $P99 = new ['Hash']
@@ -198,14 +163,12 @@
     $P0.'globals'($P99)
     $P1 = $P0.'globals'()
     $I0 = isnull $P1
-    if $I0 goto ok_4
-    print 'not '
-  ok_4:
-    say 'ok 4 - globals() with empty hash arg sets PMCNULL'
+    ok( $I0, 'globals() with empty hash arg sets PMCNULL' )
 
     $P99['Prince'] = ''
     $P99['Alex'] = ''
 
+    $I9 = 1
     $P0.'globals'($P99)
     $P1 = $P0.'globals'()
     $I99 = $P99
@@ -218,71 +181,46 @@
     unless $I0 goto nok_5
     goto ok_5
   nok_5:
-    print 'not '
+    $I9 = 0
   ok_5:
-    say 'ok 5 - globals() with hash arg sets globals hash (hash with two keys)'
+    ok( $I9, 'globals() with hash arg sets globals hash (hash with two keys)' )
 
-
     $P98 = clone $P99
 
     push_eh ok_6
+    $I1 = 1
     $P0.'globals'($P99, $P98)
+    $I1 = 0
+  ok_6:
     pop_eh
+    ok( $I1, 'globals() with too many args fails' )
 
-    print 'not '
-  ok_6:
-    say 'ok 6 - globals() with too many args fails'
-
 .end
-CODE
-ok 1 - globals() returns PMCNULL upon Exporter init
-ok 2 - globals() with empty array arg sets PMCNULL
-ok 3 - globals() with array arg sets globals hash (hash with two keys)
-ok 4 - globals() with empty hash arg sets PMCNULL
-ok 5 - globals() with hash arg sets globals hash (hash with two keys)
-ok 6 - globals() with too many args fails
-OUT
 
-pir_error_output_like( <<'CODE', <<'OUT', 'import - no args' );
-.sub 'test' :main
+.sub 'test_5'
     $P0 = new ['Exporter']
 
+    push_eh e1
+    $I0 = 1
     $P0.'import'()
-    say 'ok 1 - import() with no args throws an exception'
-
+    $I0 = 0
+e1:
+    pop_eh
+# /^source namespace not set\n/
+    ok( $I0, 'import() with no args throws an exception' )
 .end
-CODE
-/^source namespace not set\n/
-OUT
 
-pir_output_is( <<'CODE', <<'OUT', 'import - same source and destination namespaces' );
-.sub 'test' :main
+.sub 'test_6'
     .local pmc exporter, src
 
     src      = get_namespace
 
     exporter = new ['Exporter']
     exporter.'import'( src :named('source'), src :named('destination'), 'plan ok' :named('globals') )
-    plan(1)
     ok(1)
 .end
 
-.sub 'plan'
-    .param int one
-    say '1..1'
-.end
-
-.sub 'ok'
-    .param int one
-    say 'ok 1'
-.end
-CODE
-1..1
-ok 1
-OUT
-
-pir_output_is( <<'CODE', <<'OUT', 'import - globals as string' );
-.sub 'test' :main
+.sub 'test_7'
     load_bytecode 'Test/More.pbc'
     .local pmc exporter, src
 
@@ -290,16 +228,10 @@
 
     exporter = new ['Exporter']
     exporter.'import'( src :named('source'), 'plan ok' :named('globals') )
-    plan(1)
     ok(1)
 .end
-CODE
-1..1
-ok 1
-OUT
 
-pir_output_is( <<'CODE', <<'OUT', 'import - globals with source passed separately' );
-.sub 'test' :main
+.sub 'test_8'
     load_bytecode 'Test/More.pbc'
     .local pmc exporter, src
 
@@ -308,16 +240,10 @@
     exporter = new ['Exporter']
     exporter.'source'( src )
     exporter.'import'( 'plan ok' :named('globals') )
-    plan(1)
     ok(1)
 .end
-CODE
-1..1
-ok 1
-OUT
 
-pir_output_is( <<'CODE', <<'OUT', 'import - globals as array' );
-.sub 'test' :main
+.sub 'test_9'
     load_bytecode 'Test/More.pbc'
     .local pmc exporter, src, globals
 
@@ -328,16 +254,10 @@
 
     exporter = new ['Exporter']
     exporter.'import'( src :named('source'), globals :named('globals') )
-    plan(1)
     ok(1)
 .end
-CODE
-1..1
-ok 1
-OUT
 
-pir_output_is( <<'CODE', <<'OUT', 'import - globals as hash - null + empty string' );
-.sub 'test' :main
+.sub 'test_10'
     load_bytecode 'Test/More.pbc'
     .local pmc exporter, src, globals, nul
 
@@ -349,16 +269,10 @@
 
     exporter = new ['Exporter']
     exporter.'import'( src :named('source'), globals :named('globals') )
-    plan(1)
     ok(1)
 .end
-CODE
-1..1
-ok 1
-OUT
 
-pir_output_is( <<'CODE', <<'OUT', 'import - globals as hash - with dest names (latin)' );
-.sub 'test' :main
+.sub 'test_11'
     load_bytecode 'Test/More.pbc'
     .local pmc exporter, src, globals
 
@@ -369,16 +283,11 @@
 
     exporter = new ['Exporter']
     exporter.'import'( src :named('source'), globals :named('globals') )
-    consilium(1)
+    #consilium(1)
     rectus(1)
 .end
-CODE
-1..1
-ok 1
-OUT
 
-pir_output_is( <<'CODE', <<'OUT', 'import - globals with destination' );
-.sub 'test' :main
+.sub 'test_12'
     load_bytecode 'Test/More.pbc'
     .local pmc exporter, src, dest, globals
 
@@ -397,14 +306,14 @@
 
 .namespace ['foo']
 .sub 'bar'
-    plan(1)
     ok(1)
 .end
-CODE
-1..1
-ok 1
-OUT
 
+# RT #46859 replace with make_namespace, when implemented
+.namespace ['Eponymous']
+.sub 'Eponymous' :anon
+.end
+
 # RT #46861 test exporting mmd subs
 
 # Local Variables:
@@ -412,4 +321,4 @@
 #   cperl-indent-level: 4
 #   fill-column: 100
 # End:
-# vim: expandtab shiftwidth=4:
+# vim: expandtab shiftwidth=4 ft=pir:
",patch,closed,minor,,testing,1.6.0,low,done,,,,rejected,all
