# These tests are from the Perl distribution
# 'Lingua::JA::Regular::Unicode' authored by MATSUNO★Tokuhiro
use warnings;
use strict;
use Lingua::JA::Moji ':all';
use Test::More tests => 10;
use utf8;
binmode STDOUT, ":utf8";
my $input = <<EOF;
--- input: およよABCDEFGbfege123123
--- expected: およよABCDEFGbfege123123
test: wide2ascii
--- input: およよABCDEFGbfege123123オヨヨオヨヨ
--- expected: オヨヨABCDEFGbfege123123オヨヨオヨヨ
test: hira2kata
--- input: "\x{3000}eee"
--- expected: "\x{0020}eee"
test: wide2ascii
--- input: およよABCDEFGbfege123123オヨヨオヨヨ
--- expected: およよABCDEFGbfege123123およよおよよ
test: hw2katakana + kata2hira
--- input: およよABCDEFGbfege123123オヨヨオヨヨ
--- expected: およよABCDEFGbfege123123オヨヨオヨヨ
test: hw2katakana
--- input: ガ
--- expected: ガ
test:hw2katakana
--- input: ・・
--- expected: ・・
test:hw2katakana
--- input: およよABCDEFGbfege123123オヨヨオヨヨ
--- expected: およよABCDEFGbfege123123オヨヨオヨヨ
test:katakana2hw
--- input: ガ
--- expected: ガ
test: kana2hw
--- input: およよABCDEFGbfe123123
--- expected: およよABCDEFGbfe123123
test: ascii2wide
EOF
no strict 'refs';
my @guff = split /\n/, $input;
while (@guff) {
my $input = shift @guff;
$input =~ s/^.*input:\s*// or die;
my $expected = shift @guff;
$expected =~ s/^.*expected:\s*// or die;
my $routines = shift @guff;
$routines =~ s/test:\s*// or die;
my @routines = split /\s*\+\s*/, $routines;
my $output = $input;
for my $routine (@routines) {
$output = &{$routine} ($output);
}
if ($output ne $expected) {
print "BAD $routines.\n";
print "A: $output\nB: $expected\n";
}
else {
print "OK $routines.\n";
}
ok ($expected eq $output);
}