This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add 'extra paired delimiters' feature
[perl5.git] / t / lib / croak / toke
index c295534..3d28938 100644 (file)
@@ -70,6 +70,13 @@ Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
 EXPECT
 Can't find string terminator "foo" anywhere before EOF at - line 1.
 ########
+# NAME Unterminated here-doc with non-Latin-1 terminator
+BEGIN { binmode STDERR, ":utf8" }
+use utf8;
+<<옷옷
+EXPECT
+Can't find string terminator "옷옷" anywhere before EOF at - line 3.
+########
 # NAME Unterminated qw//
 qw/
 EXPECT
@@ -85,6 +92,62 @@ Can't find string terminator "/" anywhere before EOF at - line 1.
 EXPECT
 Can't find string terminator "'" anywhere before EOF at - line 1.
 ########
+# NAME Unterminated ""
+"
+EXPECT
+Can't find string terminator '"' anywhere before EOF at - line 1.
+########
+# NAME Unterminated q// with non-ASCII delimiter, under utf8
+BEGIN { binmode STDERR, ":utf8" }
+use utf8;
+no warnings 'deprecated';
+q«
+EXPECT
+Can't find string terminator "«" anywhere before EOF at - line 4.
+########
+# NAME Unterminated q// with non-Latin-1 delimiter
+BEGIN { binmode STDERR, ":utf8" }
+use utf8;
+q 옷
+EXPECT
+Can't find string terminator "옷" anywhere before EOF at - line 3.
+########
+# NAME extra paired delimiters Latin1 range in UTF-8
+BEGIN { binmode STDERR, ":utf8" }
+use utf8;
+use feature 'extra_paired_delimiters';
+no warnings 'experimental::extra_paired_delimiters';
+my $good = q«this string has a mirrored terminator»;
+my $bad = q«this string needs to have a mirrored terminator«;
+EXPECT
+Can't find string terminator "»" anywhere before EOF at - line 6.
+########
+# NAME paired non-ASCII Latin1 delimiters need feature enabled, in UTF-8
+BEGIN { binmode STDERR, ":utf8" }
+use utf8;
+my $good = q«this string works as before without the feature enabled«;
+no warnings 'deprecated';
+my $bad = q«this string has a mirrored terminator»;
+EXPECT
+Use of '«' is deprecated as a string delimiter at - line 3.
+Can't find string terminator "«" anywhere before EOF at - line 5.
+########
+# NAME paired above Latin1 delimiters need feature enabled
+BEGIN { binmode STDERR, ":utf8" }
+use utf8;
+my $bad = q《this string has a mirrored terminator》;
+EXPECT
+Use of '《' is deprecated as a string delimiter at - line 3.
+Can't find string terminator "《" anywhere before EOF at - line 3.
+########
+# NAME rhs directional delimiter can be used as lhs Latin1 range in UTF-8
+BEGIN { binmode STDERR, ":utf8" }
+use utf8;
+my $good = q»this string starts and ends with the rhs terminator»;
+my $bad = q»this string has delimiters reversed«;
+EXPECT
+Can't find string terminator "»" anywhere before EOF at - line 4.
+########
 # NAME /\N{/
 /\N{/
 EXPECT
@@ -112,6 +175,12 @@ state sub;
 EXPECT
 Missing name in "state sub" at - line 2.
 ########
+# NAME our sub pack::foo
+our sub foo::bar;
+EXPECT
+No package name allowed for subroutine &foo::bar in "our" at - line 1, near "our sub foo::bar"
+Execution of - aborted due to compilation errors.
+########
 # NAME my sub pack::foo
 use feature 'lexical_subs', 'state';
 my sub foo::bar;
@@ -159,9 +228,16 @@ Execution of - aborted due to compilation errors.
 # NAME Regexp constant overloading when *^H is undefined
 use overload;
 BEGIN { overload::constant qr => sub {}; undef *^H }
-/a/, m'a'
+/a/
 EXPECT
 Constant(qq) unknown at - line 3, within pattern
+Execution of - aborted due to compilation errors.
+########
+# NAME Regexp constant overloading when *^H is undefined
+use overload;
+BEGIN { overload::constant qr => sub {}; undef *^H }
+m'a'
+EXPECT
 Constant(q) unknown at - line 3, within pattern
 Execution of - aborted due to compilation errors.
 ########
@@ -211,9 +287,16 @@ Execution of - aborted due to compilation errors.
 # NAME Regexp constant overloading returning undef
 use overload;
 BEGIN { overload::constant qr => sub {} }
-/a/, m'a'
+/a/
 EXPECT
 Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
+Execution of - aborted due to compilation errors.
+########
+# NAME Regexp constant overloading returning undef
+use overload;
+BEGIN { overload::constant qr => sub {} }
+m'a'
+EXPECT
 Constant(q): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
 Execution of - aborted due to compilation errors.
 ########
@@ -243,6 +326,44 @@ Too many arguments for undef operator at - line 11, near "2)"
 Constant(q) unknown at - line 12, near ""a""
 - has too many errors.
 ########
+# NAME Bad name after ' (with other helpful messages)
+sub has{}
+has erdef => (
+    isa => 'Int',
+    is => 'ro,
+    default => sub { 1 }
+);
+
+has cxxc => (
+    isa => 'Int',
+    is => 'ro',
+    default => sub { 1 }
+);
+EXPECT
+Bareword found where operator expected at - line 9, near "isa => 'Int"
+  (Might be a runaway multi-line '' string starting on line 4)
+       (Do you need to predeclare isa?)
+Bad name after Int' at - line 9.
+########
+# NAME Bad name after :: (with other helpful messages)
+sub has{}
+has erdef => (
+    isa => 'Int',
+    is => "ro,
+    default => sub { 1 }
+);
+
+has cxxc => (
+    isa => "Foo::$subpackage",
+    is => 'ro',
+    default => sub { 1 }
+);
+EXPECT
+Bareword found where operator expected at - line 9, near "isa => "Foo"
+  (Might be a runaway multi-line "" string starting on line 4)
+       (Do you need to predeclare isa?)
+Bad name after Foo:: at - line 9.
+########
 # NAME Unterminated delimiter for here document
 <<"foo
 EXPECT
@@ -251,49 +372,241 @@ Unterminated delimiter for here document at - line 1.
 # NAME my (our $x) errors
 my (our $x);
 EXPECT
-Can't redeclare "our" in "my" at - line 1, at end of line
+Can't redeclare "our" in "my" at - line 1, near "(our"
 Execution of - aborted due to compilation errors.
 ########
 # NAME our (my $x) errors
 our (my $x);
 EXPECT
-Can't redeclare "my" in "our" at - line 1, at end of line
+Can't redeclare "my" in "our" at - line 1, near "(my"
 Execution of - aborted due to compilation errors.
 ########
 # NAME state (my $x) errors
 use feature 'state';
 state (my $x);
 EXPECT
-Can't redeclare "my" in "state" at - line 2, at end of line
+Can't redeclare "my" in "state" at - line 2, near "(my"
 Execution of - aborted due to compilation errors.
 ########
 # NAME our (state $x) errors
 use feature 'state';
 our (state $x);
 EXPECT
-Can't redeclare "state" in "our" at - line 2, at end of line
+Can't redeclare "state" in "our" at - line 2, near "(state"
 Execution of - aborted due to compilation errors.
 ########
 # NAME my (my $x) errors
 my (my $x, $y, $z);
 EXPECT
-Can't redeclare "my" in "my" at - line 1, at end of line
+Can't redeclare "my" in "my" at - line 1, near "(my"
 Execution of - aborted due to compilation errors.
 ########
 # NAME our (our $x) errors
 our ($x, our($y), $z);
 EXPECT
-Can't redeclare "our" in "our" at - line 1, near ", "
+Can't redeclare "our" in "our" at - line 1, near ", our"
 Execution of - aborted due to compilation errors.
 ########
 # NAME state (state $x) errors
 use feature 'state';
 state ($x, $y, state $z);
 EXPECT
-Can't redeclare "state" in "state" at - line 2, near ", "
+Can't redeclare "state" in "state" at - line 2, near ", state"
 Execution of - aborted due to compilation errors.
 ########
 # NAME BEGIN <> [perl #125341]
 BEGIN <>
 EXPECT
 Illegal declaration of subroutine BEGIN at - line 1.
+########
+# NAME multiple conflict markers
+<<<<<<< yours:sample.txt
+my $some_code;
+=======
+my $some_other_code;
+>>>>>>> theirs:sample.txt
+EXPECT
+Version control conflict marker at - line 1, near "<<<<<<<"
+Version control conflict marker at - line 3, near "======="
+Version control conflict marker at - line 5, near ">>>>>>>"
+Execution of - aborted due to compilation errors.
+########
+# NAME (Might be a runaway multi-line...) with Latin-1 delimiters in utf8
+BEGIN { binmode STDERR, ':utf8' }
+use utf8;
+no warnings 'deprecated';
+q«
+« time
+EXPECT
+syntax error at - line 5, near "« time"
+  (Might be a runaway multi-line «« string starting on line 4)
+Execution of - aborted due to compilation errors.
+########
+# NAME (Might be a runaway multi-line...) with non-Latin-1 delimiters
+BEGIN { binmode STDERR, ':utf8' }
+use utf8;
+q ϡ
+ϡ time
+EXPECT
+syntax error at - line 4, near "ϡ time"
+  (Might be a runaway multi-line ϡϡ string starting on line 3)
+Execution of - aborted due to compilation errors.
+########
+# NAME tr/// handling of mis-formatted \o characters
+# may only fail with ASAN
+tr/\o-0//;
+EXPECT
+Missing braces on \o{} at - line 2, within string
+Execution of - aborted due to compilation errors.
+########
+# NAME bare <<
+$a = <<;
+
+EXPECT
+Use of bare << to mean <<"" is forbidden at - line 1.
+########
+# NAME bare <<~
+$a = <<~;
+EXPECT
+Use of bare << to mean <<"" is forbidden at - line 1.
+########
+# NAME bare <<~
+$a = <<~ ;
+
+EXPECT
+Use of bare << to mean <<"" is forbidden at - line 1.
+########
+# NAME incomplete floating point decimal exponent (#131725)
+1e--5
+EXPECT
+Bareword found where operator expected at - line 1, near "1e"
+       (Missing operator before e?)
+Number found where operator expected at - line 1, near "--5"
+       (Missing operator before 5?)
+syntax error at - line 1, near "1e"
+Execution of - aborted due to compilation errors.
+########
+# NAME signature with non-"=" assignop #131777
+use feature 'signatures';
+sub foo ($a += 1)
+EXPECT
+Illegal operator following parameter in a subroutine signature at - line 2, near "($a += 1"
+syntax error at - line 2, near "($a += 1"
+Execution of - aborted due to compilation errors.
+########
+# NAME tr/// range with empty \N{} at the start
+tr//\N{}-0/;
+EXPECT
+Unknown charname '' at - line 1, within string
+Execution of - aborted due to compilation errors.
+########
+# NAME octal fp with non-octal digits after the decimal point
+01.1234567p0;
+07.8p0;
+EXPECT
+Bareword found where operator expected at - line 2, near "8p0"
+       (Missing operator before p0?)
+syntax error at - line 2, near "8p0"
+Execution of - aborted due to compilation errors.
+########
+# NAME binary fp with non-binary digits after the decimal point
+0b1.10p0;
+0b1.2p0;
+EXPECT
+Bareword found where operator expected at - line 2, near "2p0"
+       (Missing operator before p0?)
+syntax error at - line 2, near "2p0"
+Execution of - aborted due to compilation errors.
+########
+# NAME dump() must be written as CORE::dump() as of Perl 5.30
+BEGIN { $^C = 1; }
+dump;
+CORE::dump;
+EXPECT
+dump() must be written as CORE::dump() as of Perl 5.30 at - line 2.
+########
+# NAME check Prototype not terminated includes line number (133524)
+sub t1 {}
+sub t2 (}
+EXPECT
+Prototype not terminated at - line 2.
+########
+# NAME [perl #132158] format with syntax errors
+format=
+@
+=h
+=cut
+EXPECT
+syntax error at - line 4, next token ???
+Execution of - aborted due to compilation errors.
+########
+# NAME [perl #134125] [gh #17010] incomplete hex number
+0x x 2;
+0xx 2;
+0x_;
+0b;
+EXPECT
+No digits found for hexadecimal literal at - line 1, near "0x "
+No digits found for hexadecimal literal at - line 2, near "0xx"
+No digits found for hexadecimal literal at - line 3, near "0x_;"
+No digits found for binary literal at - line 4, near "0b;"
+Execution of - aborted due to compilation errors.
+########
+# NAME [perl #130585] close paren in subparse
+qr!@{s{0})(?{!;
+EXPECT
+syntax error at - line 1, near "})"
+Execution of - aborted due to compilation errors.
+########
+# NAME [perl #130585] close paren in subparse - a few more tests
+my ($x, %y, @z);
+qq!$x\U $z[0] $y{a}\E $z[1]!;
+qq!$x\U@{s{0})(?{!;
+EXPECT
+syntax error at - line 3, near ")("
+Execution of - aborted due to compilation errors.
+########
+# NAME [perl #134310] don't confuse S_no_op() with PL_bufptr after s
+0 0x@
+EXPECT
+Number found where operator expected at - line 1, near "0 0x"
+       (Missing operator before  0x?)
+Array found where operator expected at - line 1, near "0x@
+;"
+       (Missing operator before ;?)
+No digits found for hexadecimal literal at - line 1, near "0 0x@"
+syntax error at - line 1, near "0 0x"
+Execution of - aborted due to compilation errors.
+########
+# NAME Forbid illegal \x{} code points
+use Config;
+if ($Config{uvsize} < 8) {
+    my $a = "\x{8000_0000}";
+}
+else {
+    my $a = "\x{8000_0000_0000_0000}";
+}
+EXPECT
+OPTIONS regex
+Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
+########
+# NAME Forbid illegal \o{} code points
+use Config;
+if ($Config{uvsize} < 8) {
+    my $b = "\o{20_000_000_000}";
+}
+else {
+    my $b = "\o{1_000_000_000_000_000_000_000}";
+}
+EXPECT
+OPTIONS regex
+Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
+########
+# NAME gh-17645: conflict marker detection should not read out of bounds
+m/$0[
+==0/
+EXPECT
+syntax error at - line 2, near "[
+=="
+  (Might be a runaway multi-line // string starting on line 1)
+Execution of - aborted due to compilation errors.