This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use fnc to force out malformed warnings
[perl5.git] / t / op / lex.t
index 7785445..e50f0eb 100644 (file)
@@ -7,7 +7,7 @@ use warnings;
 
 BEGIN { chdir 't' if -d 't'; require './test.pl'; }
 
-plan(tests => 23);
+plan(tests => 34);
 
 {
     no warnings 'deprecated';
@@ -129,7 +129,7 @@ fresh_perl_is(
   '* <null> ident'
 );
 SKIP: {
-    skip "Different output on EBCDIC (presumably)", 2 if ord("A") != 65;
+    skip "Different output on EBCDIC (presumably)", 3 if $::IS_EBCDIC;
     fresh_perl_is(
       qq'"ab}"ax;&\0z\x8Ao}\x82x;', <<gibberish,
 Bareword found where operator expected at - line 1, near ""ab}"ax"
@@ -150,6 +150,13 @@ gibberish
        { stderr => 1 },
       'gibberish containing &{+z} - used to crash [perl #123753]'
     );
+    fresh_perl_is(
+      "\@{\327\n", <<\gibberisi,
+Unrecognized character \xD7; marked by <-- HERE after @{<-- HERE near column 3 at - line 1.
+gibberisi
+       { stderr => 1 },
+      '@ { \327 \n - used to garble output (or fail asan) [perl #128951]'
+    );
 }
 
 fresh_perl_is(
@@ -199,3 +206,70 @@ fresh_perl_is(
    { stderr => 1 },
   '<\L\L> with no newline [perl #123802]'
 );
+
+is eval "qq'@\x{ff13}'", "\@\x{ff13}",
+  '"@<fullwidth digit>" [perl #123963]';
+
+fresh_perl_is(
+  "s;\@{<<a;\n",
+  "Can't find string terminator \"a\" anywhere before EOF at - line 1.\n",
+   { stderr => 1 },
+  's;@{<<a; [perl #123995]'
+);
+
+fresh_perl_is(
+  '$_ = q-strict.pm-; 1 ? require : die;'
+ .' print qq-ok\n- if $INC{q-strict.pm-}',
+  "ok\n",
+  {},
+  'foo ? require : bar [perl #128307]'
+);
+
+like runperl(prog => 'sub ub(){0} ub ub', stderr=>1), qr/Bareword found/,
+ '[perl #126482] Assert failure when mentioning a constant twice in a row';
+
+fresh_perl_is(
+    "do\0"."000000",
+    "",
+    {},
+    '[perl #129069] - no output and valgrind clean'
+);
+
+fresh_perl_is(
+    "00my sub\0",
+    "Missing name in \"my sub\" at - line 1.\n",
+    {},
+    '[perl #129069] - "Missing name" warning and valgrind clean'
+);
+
+fresh_perl_like(
+    "#!perl -i u\nprint 'OK'",
+    qr/OK/,
+    {},
+    '[perl #129336] - #!perl -i argument handling'
+);
+SKIP:
+{
+    ord("A") == 65
+      or skip "These tests won't work on EBCIDIC", 3;
+    fresh_perl_is(
+        "BEGIN{\$^H=hex ~0}\xF3",
+        "Integer overflow in hexadecimal number at - line 1.\n"
+      . "Malformed UTF-8 character: \\xf3 (too short; 1 byte available, need 4) at - line 1.\n"
+      . "Malformed UTF-8 character (fatal) at - line 1.",
+        {},
+        '[perl #128996] - use of PL_op after op is freed'
+    );
+    fresh_perl_like(
+        qq(BEGIN{\$0="";\$^H=-hex join""=>1}""\xFF),
+        qr/Malformed UTF-8 character: \\xff \(too short; 1 byte available, need 13\) at - line 1\./,
+        {},
+        '[perl #128997] - buffer read overflow'
+    );
+    fresh_perl_like(
+        qq(BEGIN{\$^H=0x800000}\n   0m 0\xB5\xB500\xB5\0),
+        qr/Malformed UTF-8 character: \\xb5 \(unexpected continuation byte 0xb5, with no preceding start byte\)/,
+        {},
+        '[perl #129000] read before buffer'
+    );
+}