This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Make all warnings and error messages UTF-8 clean
[perl5.git] / t / op / index.t
index ad01408..eaed4b3 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
 }
 
 use strict;
-plan( tests => 116 );
+plan( tests => 121 );
 
 run_tests() unless caller;
 
@@ -227,4 +227,28 @@ bless \our $referent, o::;
 is index("foo", riffraff), 0,
     'index respects changes in ref stringification';
 
+use constant quire => ${qr/(?{})/}; # A REGEXP, not a reference to one
+index "foo", quire;
+eval ' "" =~ quire ';
+is $@, "", 'regexp constants containing code blocks are not flattened';
+
+use constant bang => $! = 8;
+index "foo", bang;
+cmp_ok bang, '==', 8, 'dualvar constants are not flattened';
+
+use constant u => undef;
+{
+    my $w;
+    local $SIG{__WARN__} = sub { $w .= shift };
+    eval '
+        use warnings;
+        sub { () = index "foo", u; }
+    ';
+    is $w, undef, 'no warnings from compiling index($foo, undef_constant)';
+}
+is u, undef, 'undef constant is still undef';
+
+is index('the main road', __PACKAGE__), 4,
+    '[perl #119169] __PACKAGE__ as 2nd argument';
+
 } # end of sub run_tests