1898184e3Ssthen#!./perl 2898184e3Ssthen 3898184e3SsthenBEGIN { 4b8851fccSafresh1 chdir 't' if -d 't'; 5*9f11ffb7Safresh1 require './test.pl'; 6*9f11ffb7Safresh1 set_up_inc('../lib'); 7*9f11ffb7Safresh1 require './charset_tools.pl'; 8898184e3Ssthen} 9898184e3Ssthen 10c0dd97bfSafresh1plan(tests => 9); 11898184e3Ssthen 12898184e3Ssthen{ 13898184e3Ssthen local $SIG{__WARN__} = sub {}; 14898184e3Ssthen eval "evalbytes 'foo'"; 15898184e3Ssthen like $@, qr/syntax error/, 'evalbytes outside feature scope'; 16898184e3Ssthen} 17898184e3Ssthen 18898184e3Ssthen# We enable unicode_eval just to test that it does not interfere. 19898184e3Ssthenuse feature 'evalbytes', 'unicode_eval'; 20898184e3Ssthen 21898184e3Ssthenis evalbytes("1+7"), 8, 'evalbytes basic sanity check'; 22898184e3Ssthen 23898184e3Ssthenmy $code = qq('\xff\xfe'); 24898184e3Ssthenis evalbytes($code), "\xff\xfe", 'evalbytes on extra-ASCII bytes'; 25898184e3Ssthenchop((my $upcode = $code) .= chr 256); 26898184e3Ssthenis evalbytes($upcode), "\xff\xfe", 'evalbytes on upgraded extra-ASCII'; 27898184e3Ssthen{ 28898184e3Ssthen use utf8; 29898184e3Ssthen is evalbytes($code), "\xff\xfe", 'evalbytes ignores outer utf8 pragma'; 30898184e3Ssthen} 31b8851fccSafresh1my $U_100 = byte_utf8a_to_utf8n("\xc4\x80"); 32b8851fccSafresh1is evalbytes "use utf8; $U_100", chr 256, 'use utf8 within evalbytes'; 33b8851fccSafresh1chop($upcode = "use utf8; $U_100" . chr 256); 34898184e3Ssthenis evalbytes $upcode, chr 256, 'use utf8 within evalbytes on utf8 string'; 35898184e3Sstheneval { evalbytes chr 256 }; 36898184e3Ssthenlike $@, qr/Wide character/, 'evalbytes croaks on non-bytes'; 37c0dd97bfSafresh1 38c0dd97bfSafresh1eval 'evalbytes S'; 39c0dd97bfSafresh1ok 1, '[RT #129196] evalbytes S should not segfault'; 40c0dd97bfSafresh1 41