Implement new regex escape \N
[p5sagit/p5-mst-13.2.git] / t / op / switch.t
index f4cedba..d8cb781 100644 (file)
@@ -3,20 +3,19 @@
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
+    require './test.pl';
 }
 
 use strict;
 use warnings;
 
-use Test::More tests => 124;
+plan tests => 122;
 
 # The behaviour of the feature pragma should be tested by lib/switch.t
 # using the tests in t/lib/switch/*. This file tests the behaviour of
 # the switch ops themselves.
-              
 
 use feature 'switch';
-no warnings "numeric";
 
 eval { continue };
 like($@, qr/^Can't "continue" outside/, "continue outside");
@@ -517,6 +516,17 @@ sub notfoo {"bar"}
     my $n = 0;
     for my $l qw(a b c d) {
        given ($l) {
+           when ($_ eq "b" .. $_ eq "c") { $n = 1 }
+           default { $n = 0 }
+       }
+       ok(($n xor $l =~ /[ad]/), 'when(E1..E2) evaluates in boolean context');
+    }
+}
+
+{
+    my $n = 0;
+    for my $l qw(a b c d) {
+       given ($l) {
            when ($_ eq "b" ... $_ eq "c") { $n = 1 }
            default { $n = 0 }
        }
@@ -724,7 +734,6 @@ my $f = tie my $v, "FetchCounter";
 
 # Code references
 {
-    no warnings "redefine";
     my $called_foo = 0;
     sub foo {$called_foo = 1; "@_" eq "foo"}
     my $called_bar = 0;
@@ -772,6 +781,7 @@ SKIP: {
     { package OverloadTest;
 
       use overload '""' => sub{"string value of obj"};
+      use overload 'eq' => sub{"$_[0]" eq "$_[1]"};
 
       use overload "~~" => sub {
          my ($self, $other, $reversed) = @_;
@@ -806,11 +816,8 @@ SKIP: {
            default {$matched = 0}
        }
     
-       is($obj->{called},  1, "$test: called");
+       is($obj->{called}, 1, "$test: called");
        ok($matched, "$test: matched");
-       is($obj->{left}, "string value of obj", "$test: left");
-       is($obj->{right}, "other arg", "$test: right");
-       ok(!$obj->{reversed}, "$test: not reversed");
     }
 
     {
@@ -821,11 +828,8 @@ SKIP: {
            when ("other arg") {$matched = 1}
        }
     
-       is($obj->{called},  1, "$test: called");
+       is($obj->{called}, 1, "$test: called");
        ok(!$matched, "$test: not matched");
-       is($obj->{left}, "string value of obj", "$test: left");
-       is($obj->{right}, "other arg", "$test: right");
-       ok(!$obj->{reversed}, "$test: not reversed");
     }
 
     {