This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
in Carp, avoid vivifying utf8 stash on Perl 5.6
[perl5.git] / t / comp / multiline.t
old mode 100755 (executable)
new mode 100644 (file)
index 78820c4..f1e098e
@@ -1,14 +1,52 @@
 #!./perl
 
-BEGIN: {
-    chdir 't';
-    @INC = '../lib';
-    require './test.pl';
+print "1..6\n";
+my $test = 0;
+
+sub failed {
+    my ($got, $expected, $name) = @_;
+
+    print "not ok $test - $name\n";
+    my @caller = caller(1);
+    print "# Failed test at $caller[1] line $caller[2]\n";
+    if (defined $got) {
+       print "# Got '$got'\n";
+    } else {
+       print "# Got undef\n";
+    }
+    print "# Expected $expected\n";
+    return;
 }
 
-plan(tests => 6);
+sub like {
+    my ($got, $pattern, $name) = @_;
+    $test = $test + 1;
+    if (defined $got && $got =~ $pattern) {
+       print "ok $test - $name\n";
+       # Principle of least surprise - maintain the expected interface, even
+       # though we aren't using it here (yet).
+       return 1;
+    }
+    failed($got, $pattern, $name);
+}
+
+sub is {
+    my ($got, $expect, $name) = @_;
+    $test = $test + 1;
+    if (defined $got && $got eq $expect) {
+       print "ok $test - $name\n";
+       return 1;
+    }
+    failed($got, "'$expect'", $name);
+}
+
+my $filename = "multiline$$";
+
+END {
+    1 while unlink $filename;
+}
 
-open(TRY,'>Comp.try') || (die "Can't open temp file.");
+open(TRY,'>',$filename) || (die "Can't open $filename: $!");
 
 $x = 'now is the time
 for all good men
@@ -28,7 +66,7 @@ is($x, $y,  'test data is sane');
 print TRY $x;
 close TRY or die "Could not close: $!";
 
-open(TRY,'Comp.try') || (die "Can't reopen temp file.");
+open(TRY,$filename) || (die "Can't reopen $filename: $!");
 $count = 0;
 $z = '';
 while (<TRY>) {
@@ -41,13 +79,12 @@ is($z, $y,  'basic multiline reading');
 is($count, 7,   '    line count');
 is($., 7,       '    $.' );
 
-$out = (($^O eq 'MSWin32') || $^O eq 'NetWare' || $^O eq 'VMS') ? `type Comp.try`
-    : ($^O eq 'MacOS') ? `catenate Comp.try`
-    : `cat Comp.try`;
+$out = (($^O eq 'MSWin32') || $^O eq 'NetWare') ? `type $filename`
+    : ($^O eq 'VMS') ? `type $filename.;0`   # otherwise .LIS is assumed
+    : `cat $filename`;
 
 like($out, qr/.*\n.*\n.*\n$/);
 
-close(TRY) || (die "Can't close temp file.");
-unlink 'Comp.try' || `/bin/rm -f Comp.try`;
+close(TRY) || (die "Can't close $filename: $!");
 
 is($out, $y);