1use strict; 2use warnings; 3use utf8; 4use Regexp::Lexer qw(tokenize); 5use Regexp::Lexer::TokenType; 6 7use Test::More; 8use Test::Deep; 9 10# Very edge case!! 11subtest 'has not meta newline' => sub { 12 my $tokens = tokenize(qr{h\\\r\n\\ 13 14w\\\\}); 15 16 my $i = 0; 17 my @expected = ( 18 { 19 char => "h", 20 index => ++$i, 21 type => Regexp::Lexer::TokenType::Character, 22 }, 23 { 24 char => "\\\\", 25 index => ++$i, 26 type => Regexp::Lexer::TokenType::EscapedCharacter, 27 }, 28 { 29 char => "\\r", 30 index => ++$i, 31 type => Regexp::Lexer::TokenType::EscapedReturn, 32 }, 33 { 34 char => "\\n", 35 index => ++$i, 36 type => Regexp::Lexer::TokenType::EscapedNewline, 37 }, 38 { 39 char => "\\\\", 40 index => ++$i, 41 type => Regexp::Lexer::TokenType::EscapedCharacter, 42 } 43 ); 44 45 if ($^O ne 'MSWin32') { 46 push @expected, { 47 char => "\\r", 48 index => ++$i, 49 type => Regexp::Lexer::TokenType::Return, 50 }; 51 } 52 53 push @expected, ( 54 { 55 char => "\\n", 56 index => ++$i, 57 type => Regexp::Lexer::TokenType::Newline, 58 }, 59 { 60 char => "w", 61 index => ++$i, 62 type => Regexp::Lexer::TokenType::Character, 63 }, 64 { 65 char => "\\\\", 66 index => ++$i, 67 type => Regexp::Lexer::TokenType::EscapedCharacter, 68 }, 69 { 70 char => "\\\\", 71 index => ++$i, 72 type => Regexp::Lexer::TokenType::EscapedCharacter, 73 }, 74 ); 75 76 cmp_deeply($tokens->{tokens}, \@expected); 77}; 78 79done_testing; 80 81