use warnings;
use Data::Dumper ();
use Test::More;
+use File::Slurp 'read_file';
use namespace::clean;
use Exporter 'import';
-our @EXPORT_OK = qw/split_name dumper dumper_squashed eval_package_without_redefine_warnings class_path warnings_exist warnings_exist_silent/;
+our @EXPORT_OK = qw/split_name dumper dumper_squashed eval_package_without_redefine_warnings class_path no_warnings warnings_exist warnings_exist_silent slurp_file/;
use constant BY_CASE_TRANSITION =>
qr/(?<=[[:lower:]\d])[\W_]*(?=[[:upper:]])|[\W_]+/;
use constant BY_NON_ALPHANUM =>
qr/[\W_]+/;
+my $LF = "\x0a";
+my $CRLF = "\x0d\x0a";
+
sub split_name($) {
my $name = shift;
return $class_path;
}
+sub no_warnings(&;$) {
+ my ($code, $test_name) = @_;
+
+ my $failed = 0;
+
+ my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
+ local $SIG{__WARN__} = sub {
+ $failed = 1;
+ $warn_handler->(@_);
+ };
+
+ $code->();
+
+ ok ((not $failed), $test_name);
+}
+
sub warnings_exist(&$$) {
my ($code, $re, $test_name) = @_;
ok $matched, $test_name;
}
+sub slurp_file($) {
+ my $data = read_file(shift, binmode => ':encoding(UTF-8)');
+
+ $data =~ s/$CRLF|$LF/\n/g;
+
+ return $data;
+}
1;
# vim:et sts=4 sw=4 tw=0: