summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-10-09 13:48:43 +0200
committerNicholas Clark <nick@ccl4.org>2009-10-09 20:26:18 +0200
commitcf1e28d2637f0459847074ab67bb30cc13d0473a (patch)
treebfaae065970596c2133d8587f557946b3339d8b2 /t
parent3d899d640007cb6cbc676620da4d0aba415fdff6 (diff)
downloadperl-cf1e28d2637f0459847074ab67bb30cc13d0473a.tar.gz
Don't use require in comp/uproto.t, as require isn't tested yet.
Emit TAP directly.
Diffstat (limited to 't')
-rw-r--r--t/comp/uproto.t50
1 files changed, 45 insertions, 5 deletions
diff --git a/t/comp/uproto.t b/t/comp/uproto.t
index 265854f79e..c899b68b8f 100644
--- a/t/comp/uproto.t
+++ b/t/comp/uproto.t
@@ -1,12 +1,52 @@
#!perl
-BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
- require "./test.pl";
+print "1..39\n";
+my $test = 0;
+
+sub failed {
+ my ($got, $expected) = @_;
+
+ print "not ok $test\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 => 39);
+sub like {
+ my ($got, $pattern) = @_;
+ $test = $test + 1;
+ if (defined $got && $got =~ $pattern) {
+ print "ok $test\n";
+ # Principle of least surprise - maintain the expected interface, even
+ # though we aren't using it here (yet).
+ return 1;
+ }
+ failed($got, $pattern);
+}
+
+sub is {
+ my ($got, $expect) = @_;
+ $test = $test + 1;
+ if (defined $expect) {
+ if (defined $got && $got eq $expect) {
+ print "ok $test\n";
+ return 1;
+ }
+ failed($got, "'$expect'");
+ } else {
+ if (!defined $got) {
+ print "ok $test\n";
+ return 1;
+ }
+ failed($got, 'undef');
+ }
+}
sub f($$_) { my $x = shift; is("@_", $x) }