Permalink
Browse files

Rearrange tests. Need EXPR eval, not BLOCK, for require

  • Loading branch information...
1 parent 99512c0 commit 675b3048898865290fe1094d4c83586a19d61e9b @ctfouts ctfouts committed Mar 22, 2012
Showing with 30 additions and 17 deletions.
  1. +1 −4 lib/Xape/Enumerator.pm
  2. +4 −13 t/001-enum.t
  3. +25 −0 t/002-charset-he.t
@@ -14,10 +14,7 @@ around BUILDARGS => func($orig, $class, @args) {
if (@args == 1) {
unless (ref $args[0]) {
my $package_name = "Xape::Charset::$args[0]";
- eval {
- require $package_name;
- import $package_name;
- };
+ eval "require $package_name;"; ## no critic
$args[0] = $package_name->new;
}
@args = (charset => $args[0]);
View
@@ -10,28 +10,19 @@ use Test::More;
BEGIN {
use_ok 'Xape::Enumerator';
- use_ok 'Xape::Charset::he';
}
-my $charset = Xape::Charset::he->new();
-isa_ok $charset, 'Xape::Charset::he';
-is $charset->lookup("\x{5cf}"), undef;
-is $charset->lookup("\x{5d0}"), 1;
-is $charset->lookup("\x{5da}"), 20;
-is $charset->lookup("\x{5db}"), 20;
-is $charset->lookup("\x{5ea}"), 400;
-is $charset->lookup("\x{5eb}"), undef;
-
my $enum;
+$enum = Xape::Enumerator->new('he');
+isa_ok $enum, 'Xape::Enumerator', 'Dynamic charset load';
+
+my $charset = Xape::Charset::he->new;
$enum = Xape::Enumerator->new(charset => $charset);
isa_ok $enum, 'Xape::Enumerator';
$enum = Xape::Enumerator->new($charset);
isa_ok $enum, 'Xape::Enumerator';
-$enum = Xape::Enumerator->new('he');
-isa_ok $enum, 'Xape::Enumerator';
-
is $enum->sum("\x{5d0}"), 1, 'Single sum';
is $enum->sum('A'), 1, 'Single sum (xlit)';
is $enum->sum("\x{5d0}\x{5ea}"), 401, 'Multiple sum';
View
@@ -0,0 +1,25 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use utf8;
+binmode(STDOUT, ':encoding(UTF-8)');
+binmode(STDERR, ':encoding(UTF-8)');
+
+use Test::More;
+
+BEGIN {
+ use_ok 'Xape::Charset::he';
+}
+
+my $charset = Xape::Charset::he->new();
+isa_ok $charset, 'Xape::Charset::he';
+
+is $charset->lookup("\x{5cf}"), undef;
+is $charset->lookup("\x{5d0}"), 1;
+is $charset->lookup("\x{5da}"), 20;
+is $charset->lookup("\x{5db}"), 20;
+is $charset->lookup("\x{5ea}"), 400;
+is $charset->lookup("\x{5eb}"), undef;
+
+done_testing;

0 comments on commit 675b304

Please sign in to comment.