Language-FormulaEngine

 view release on metacpan or  search on metacpan

t/10-scanner.t  view on Meta::CPAN

#! /usr/bin/env perl
use Test2::V0 -target => 'Language::FormulaEngine::Parser';
use Try::Tiny;

# capture error message of code that should die
sub error_of(&) { my $sub= shift; try { $sub->(); 'No Exception Thrown' } catch { $_ } }

my %_str_escapes= ("\0" => '\0', "\n" => '\n', "\r" => '\r', "\t" => '\t', "\f" => '\f', "\b" => '\b', "\a" => '\a', "\e" => '\e', "\\" => '\\' );
sub str_escape_char { exists $_str_escapes{$_[0]}? $_str_escapes{$_[0]} : sprintf((ord $_[0] <= 0xFF)? "\\x%02X" : "\\x{%X}", ord $_[0]); }
sub str_escape { my $str= shift; $str =~ s/([^\x20-\x7E])/str_escape_char($1)/eg; $str; }

sub test_scanner {
	my @tests= (
		[ ''
		],
		[ " \t\r\n\t   \r\n"



( run in 0.554 second using v1.01-cache-2.11-cpan-49f99fa48dc )