Benchmark-Perl-Formance-Cargo
view release on metacpan or search on metacpan
share/RegexpCommonTS/t/comment/single_or_multiline.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use lib "blib/lib";
use Regexp::Common qw /RE_comment_ALL/;
use t::Common qw /run_new_tests ww/;
use warnings;
BEGIN {$^W = 0 if $[ < 5.006;}
# 1. tokens for single line comments.
# 2. start/end tokens for multi-line comments.
# 3. list of languages this applies to.
my @data = do {
no warnings;
(
[[qw {//}] =>
[[qw {/* */}]] =>
[qw {C++ C# Cg ECMAScript FPL Java JavaScript}],
],
[[qw {#}] =>
[[qw {/* */}]] =>
[qw {Nickle}],
],
[[qw {//}] =>
[[qw !{ }!], [qw !(* *)!]] =>
[[qw /Pascal Delphi/], [qw /Pascal Free/], [qw /Pascal GPC/]],
],
[[qw {!}] =>
[[qw {/* */}]] =>
[qw {PEARL}]
],
[[qw {# //}] =>
[[qw {/* */}]] =>
[qw {PHP}]
],
[[qw {--}] =>
[[qw {/* */}]] =>
[qw {PL/SQL}]
]
);
};
# Grab the single line tokens.
my @s_tokens = do {my %h; grep {!$h {$_} ++} map {@{$$_ [0]}} @data};
# Grab the multiline line tokens.
my @mo_tokens = do {my %h; grep {!$h {$_} ++}
map {map {$$_ [0]} @{$$_ [1]}} @data};
my @mc_tokens = do {my %h; grep {!$h {$_} ++}
map {map {$$_ [1]} @{$$_ [1]}} @data};
my @comments = ("", "This is a comment", "This is a\nmultiline comment",
"\n", (map {" $_ "} @s_tokens, @mo_tokens, @mc_tokens));
my @no_eol = grep {!/\n/} @comments;
# Targets, and test suites.
my %targets;
my @tests;
my @bad;
# Tests for the single line comments (including failures).
foreach my $token (@s_tokens) {
my $key = "single_$token";
my $fkey = "single_fail_$token";
$targets {$key} = {
( run in 0.753 second using v1.01-cache-2.11-cpan-97f6503c9c8 )