summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2002-12-20 00:35:27 +0000
committerhv <hv@crypt.org>2002-12-23 03:36:26 +0000
commite9bdcc27a1d9b3f31b4d8c3678dd1346910c9b4d (patch)
treedca7ea6b1fcce75741a00aa3b14cc349dbf9354f /t
parentf800e14d03e1bfa2cf42b86e56c0183cd5875618 (diff)
downloadperl-e9bdcc27a1d9b3f31b4d8c3678dd1346910c9b4d.tar.gz
Reverse #18285, for reasons given in:
Subject: Re: Precedence of ? : Message-Id: <200212200035.gBK0ZRm29309@crypt.compulink.co.uk> p4raw-id: //depot/perl@18336
Diffstat (limited to 't')
-rwxr-xr-xt/op/cond.t72
1 files changed, 1 insertions, 71 deletions
diff --git a/t/op/cond.t b/t/op/cond.t
index de72a51e9f..427efb4887 100755
--- a/t/op/cond.t
+++ b/t/op/cond.t
@@ -2,7 +2,7 @@
# $RCSfile: cond.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:41 $
-print "1..16\n";
+print "1..4\n";
print 1 ? "ok 1\n" : "not ok 1\n"; # compile time
print 0 ? "not ok 2\n" : "ok 2\n";
@@ -10,73 +10,3 @@ print 0 ? "not ok 2\n" : "ok 2\n";
$x = 1;
print $x ? "ok 3\n" : "not ok 3\n"; # run time
print !$x ? "not ok 4\n" : "ok 4\n";
-
-# Very low precedence between the ? and the :
-print $x ? "ok 5\n" or "not ok 5\n" : "not ok 5\n";
-# Binds tighter than assignment
-$msg = "not ok 6\n" ? "ok 6\n" : "ok 6\n";
-print $msg;
-# Binds looser than ".."
-print "ok ", $x ? 7 : -2..15, "\n";
-# Right-associative
-print $x ? "ok 8\n" : 0 ? "not ok 8\n" : "not ok 8\n";
-# No parens needed when nested like an if-elsif-elsif-elsif-else
-$n = 9;
-print $n == 7 ? "not ok 9\n" :
- $n == 8 ? "not ok 9\n" :
- $n == 9 ? "ok 9\n" :
- $n == 10 ? "not ok 9\n" :
- "not ok 9\n";
-# Nor when used like a deeply nested if-else chain
-print $n != 7 ?
- $n != 8 ?
- $n != 9 ?
- $n != 10 ?
- "not ok 10\n"
- :
- "not ok 10\n"
- :
- "ok 10\n"
- :
- "not ok 10\n"
- :
- "not ok 10\n";
-# A random pathologically nested example, which parses like
-# $a ? ($b ? ($c ? $d : ($e ? $f : $g)) : $h) : ($i ? $j : $k),
-# i.e.,
-# if ($a) {
-# if ($b) {
-# if ($c) {
-# $d;
-# } else {
-# if ($e) {
-# $f;
-# } else {
-# $g;
-# }
-# }
-# } else {
-# $h;
-# }
-# } else {
-# if ($i) {
-# $j;
-# } else {
-# $k;
-# }
-# }
-# We exercise all the branches. The ".5"s should be dont-cares.
-($d, $f, $g, $h, $j, $k) =
- ("ok 11\n", "ok 12\n", "ok 13\n", "ok 14\n", "ok 15\n", "ok 16\n");
-($a, $b, $c, $e, $i) = (1, 1, 1, .5, .5);
-print $a ? $ b ? $c ? $d : $e ? $f : $g : $h : $i ? $j : $k;
-($a, $b, $c, $e, $i) = (1, 1, 0, 1, .5);
-print $a ? $ b ? $c ? $d : $e ? $f : $g : $h : $i ? $j : $k;
-($a, $b, $c, $e, $i) = (1, 1, 0, 0, .5);
-print $a ? $ b ? $c ? $d : $e ? $f : $g : $h : $i ? $j : $k;
-($a, $b, $c, $e, $i) = (1, 0, .5, .5, .5);
-print $a ? $ b ? $c ? $d : $e ? $f : $g : $h : $i ? $j : $k;
-($a, $b, $c, $e, $i) = (0, .5, .5, .5, 1);
-print $a ? $ b ? $c ? $d : $e ? $f : $g : $h : $i ? $j : $k;
-($a, $b, $c, $e, $i) = (0, .5, .5, .5, 0);
-print $a ? $ b ? $c ? $d : $e ? $f : $g : $h : $i ? $j : $k;