Add a few regression tests, making sure ... is parsed as a range operator
authorAbigail <abigail@abigail.be>
Thu, 28 Jan 2010 20:16:33 +0000 (21:16 +0100)
committerAbigail <abigail@abigail.be>
Thu, 28 Jan 2010 20:16:33 +0000 (21:16 +0100)
t/op/yadayada.t

index f82aa72..770a51e 100644 (file)
@@ -8,10 +8,43 @@ BEGIN {
 
 use strict;
 
-plan 1;
+plan 5;
 
 my $err = "Unimplemented at $0 line " . ( __LINE__ + 2 ) . ".\n";
 
 eval { ... };
 
 is $@, $err;
+
+
+#
+# Regression tests, making sure ... is still parsable as an operator.
+#
+my @lines = split /\n/ => <<'--';
+
+# Check simple range operator.
+my @arr = 'A' ... 'D';
+
+# Range operator with print.
+print 'D' ... 'A';
+
+# Without quotes, 'D' could be a file handle.
+print  D  ...  A ;
+
+# Another possible interaction with a file handle.
+print ${\"D"}  ...  A ;
+--
+
+foreach my $line (@lines) {
+    next if $line =~ /^\s*#/ || $line !~ /\S/;
+    my $mess = qq {Parsing '...' in "$line" as a range operator};
+    eval qq {
+       {local *STDOUT; no strict "subs"; $line;}
+        pass \$mess;
+        1;
+    } or do {
+        my $err = $@;
+        $err =~ s/\n//g;
+        fail "$mess ($err)";
+    }
+}