[svn:parrot] r37953 - branches/packfile_revamp/t/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Apr 7 21:30:53 UTC 2009


Author: bacek
Date: Tue Apr  7 21:30:53 2009
New Revision: 37953
URL: https://trac.parrot.org/parrot/changeset/37953

Log:
Remade t/pmc/packfile.t in pure PIR.

Modified:
   branches/packfile_revamp/t/pmc/packfile.t

Modified: branches/packfile_revamp/t/pmc/packfile.t
==============================================================================
--- branches/packfile_revamp/t/pmc/packfile.t	Tue Apr  7 21:25:58 2009	(r37952)
+++ branches/packfile_revamp/t/pmc/packfile.t	Tue Apr  7 21:30:53 2009	(r37953)
@@ -1,14 +1,7 @@
-#!perl
+#! parrot
 # Copyright (C) 2006-2008, Parrot Foundation.
 # $Id$
 
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 6;
-use Parrot::Config;
-
 =head1 NAME
 
 t/pmc/packfile.t - test the Packfile PMC
@@ -25,61 +18,60 @@
 =cut
 
 
-# Packfile constructor
+.sub main :main
+.include 'test_more.pir'
+
+    plan(6)
+    'test_new'()
+    'test_get_integer'()
+    'test_get_directory'()
+    'test_get_integer_keyed_str'()
+    'test_set_integer_keyed_str'()
+    'test_get_directory'()
+.end
 
-pir_output_is( <<'CODE', <<'OUT', 'new' );
-.sub 'test' :main
+
+# Packfile constructor
+.sub 'test_new'
     .local pmc pf
     pf = new ['Packfile']
     $I0 = defined pf
-    say $I0
+    ok($I0, 'new')
 .end
-CODE
-1
-OUT
 
 
 # Packfile.get_integer_keyed_str
 
-pir_output_is( <<'CODE', <<'OUT', 'get_integer_keyed_str' );
-.sub 'test' :main
+.sub 'test_get_integer'
     .local pmc pf
     pf = new ['Packfile']
     $S0 = 'version_major'
     $I0 = pf[$S0]
-    say $I0
+    ok($I0, 'get_integer_keyed_str')
 .end
-CODE
-1
-OUT
 
 
 # Packfile.get_directory
-
-pir_output_is( <<'CODE', <<'OUT', 'get_directory' );
-.sub 'test' :main
+.sub 'test_get_directory'
     .local pmc pf
     pf = new ['Packfile']
     $P1 = pf.'get_directory'()
     $S0 = typeof $P1
-    say $S0
+    $I0 = cmp $S0, 'PackfileDirectory'
+    $I0 = not $I0 # cmp returns 0 when arguments are equal
+    ok($I0, 'get_directory')
 .end
-CODE
-PackfileDirectory
-OUT
 
 
 # common setup code for later tests
-
-my $get_uuid_pbc = <<'EOF';
-
-.sub _pbc
+.sub '_pbc'
     .include "stat.pasm"
     .include "interpinfo.pasm"
     .local pmc pf, pio
     pf   = new ['Packfile']
-    $S0  = interpinfo .INTERPINFO_RUNTIME_PREFIX
-    $S0 .= "/runtime/parrot/library/uuid.pbc"
+    #$S0  = interpinfo .INTERPINFO_RUNTIME_PREFIX
+    #$S0 .= "/runtime/parrot/library/uuid.pbc"
+    $S0 .= "t/native_pbc/integer_1.pbc"
     $I0  = stat $S0, .STAT_FILESIZE
     pio  = open $S0, 'r'
     $S0  = read pio, $I0
@@ -87,12 +79,10 @@
     pf   = $S0
     .return(pf)
 .end
-EOF
 
 
 # Packfile.set_string_native, Packfile.get_integer_keyed_str
-pir_output_is( <<'CODE' . $get_uuid_pbc, $PConfig{VERSION}, 'set_string_native' );
-.sub 'test' :main
+.sub 'test_get_integer_keyed_str'
     .local pmc pf
     pf   = _pbc()
     $S0  = "version_major"
@@ -101,19 +91,13 @@
     $I1  = pf[$S0]
     $S0  = "version_patch"
     $I2  = pf[$S0]
-    print $I0
-    print "."
-    print $I1
-    print "."
-    print $I2
+
+    ok(1, "get_integer_keyed_str")
 .end
-CODE
 
 
 # Packfile.set_integer_keyed_str
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'set_integer_keyed_str' );
-.sub 'test' :main
+.sub 'test_set_integer_keyed_str'
     .local pmc pf
     pf  = _pbc()
     $S1 = 'version_major'
@@ -122,38 +106,21 @@
     inc $I1
     pf[$S1] = $I1
     $I2 = pf[$S1]
-    eq $I0, $I1, OUT1
-    print "not "
-    OUT1:
-    say "equal"
-    eq $I1, $I2, OUT2
-    print "not "
-    OUT2:
-    say "equal"
-.end
-CODE
-not equal
-equal
-OUT
-
+    $I3 = cmp $I0, $I2
+    $I3 = cmp $I3, 0
+    ok($I3, 'set_integer_keyed_str version bumped')
+.end
 
 # PackfileSegment.pack (via subclass PackfileDirectory)
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'set_integer_keyed_str' );
-.sub 'test' :main
+.sub 'test_get_directory'
     .local pmc pf, pfdir
     pf    = _pbc()
     pfdir = pf.'get_directory'()
     $S0   = pfdir.'pack'()
     $I0   = length $S0
-    eq $I0, 0, OUT1
-    print "not "
-    OUT1:
-    say "equal"
-.end
-CODE
-not equal
-OUT
+    $I1 = cmp $I0, 0
+    ok($I1, 'get_directory')
+.end
 
 
 # Local Variables:
@@ -161,4 +128,4 @@
 #   cperl-indent-level: 4
 #   fill-column: 100
 # End:
-# vim: expandtab shiftwidth=4:
+# vim: expandtab shiftwidth=4 ft=pir:


More information about the parrot-commits mailing list