summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-10-09 19:18:52 +0200
committerNicholas Clark <nick@ccl4.org>2009-10-09 20:26:19 +0200
commit76c3cfbe78336e0cb070b0aac1ead2413441af81 (patch)
tree6552ffd5af3af4a85e8dd1cb06ae391106b9fcc5 /t
parenta6d95d3b2a78200d46f5f1182e3d35b2fcc34eae (diff)
downloadperl-76c3cfbe78336e0cb070b0aac1ead2413441af81.tar.gz
Don't use require in comp/fold.t, as require isn't tested yet.
Emit TAP directly.
Diffstat (limited to 't')
-rw-r--r--t/comp/fold.t42
1 files changed, 39 insertions, 3 deletions
diff --git a/t/comp/fold.t b/t/comp/fold.t
index 0e507c3a25..23e8e89b62 100644
--- a/t/comp/fold.t
+++ b/t/comp/fold.t
@@ -1,12 +1,11 @@
#!./perl -w
-require './test.pl';
-
# Uncomment this for testing, but don't leave it in for "production", as
# we've not yet verified that use works.
# use strict;
-plan (13);
+print "1..13\n";
+my $test = 0;
# Historically constant folding was performed by evaluating the ops, and if
# they threw an exception compilation failed. This was seen as buggy, because
@@ -16,6 +15,43 @@ plan (13);
# optimisation rather than a behaviour change.
+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;
+}
+
+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 $a;
$a = eval '$b = 0/0 if 0; 3';
is ($a, 3, 'constants in conditionals don\'t affect constant folding');