Skip Menu |

This queue is for tickets about the Text-Unidecode CPAN distribution.

Report information
The Basics
Id: 63336
Status: patched
Priority: 0/
Queue: Text-Unidecode

People
Owner: Nobody in particular
Requestors: DOHERTY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.04
Fixed in: (no value)



Subject: Wide character in print at test.pl line xx
Hello, The test suite for Text::Unidecode is doing something to generate spurious errors. It might be nice to use Test::More too...
Subject: Re: [rt.cpan.org #63336] [PATCH] Rewrite test suite using Test::More
Date: Thu, 25 Nov 2010 12:31:04 -0400
To: bug-Text-Unidecode [...] rt.cpan.org
From: Mike Doherty <doherty [...] cs.dal.ca>
Rewrite test suite using Test::More This fixes #63336: Wide character in print at test.pl line xx --- t/01-basic.t | 22 +++++++++++++ t/02-complex.t | 38 ++++++++++++++++++++++ test.pl | 96 -------------------------------------------------------- 3 files changed, 60 insertions(+), 96 deletions(-) create mode 100644 t/01-basic.t create mode 100644 t/02-complex.t delete mode 100644 test.pl diff --git a/t/01-basic.t b/t/01-basic.t new file mode 100644 index 0000000..c79fe73 --- /dev/null +++ b/t/01-basic.t @@ -0,0 +1,22 @@ +require 5.006; +use strict; +use warnings; +use utf8; +use Test::More; +use Text::Unidecode; + +my @tests = ( + # Basic string tests + "", + 1/10, + "I like pie.", + "\n", + "\cm\cj", + "I like pie.\n", +); +plan tests => scalar @tests; + +foreach my $line (@tests) { + my $is = unidecode($line); + is($is, $line, "$line comes through unidecode unscathed"); +} \ No newline at end of file diff --git a/t/02-complex.t b/t/02-complex.t new file mode 100644 index 0000000..e91f35c --- /dev/null +++ b/t/02-complex.t @@ -0,0 +1,38 @@ +require 5.006; +use strict; +use warnings; +use utf8; +use Test::More; +use Text::Unidecode; + +# Avoid "Wide character in print" warning +my $builder = Test::More->builder; +binmode $builder->output, ":utf8"; +binmode $builder->failure_output, ":utf8"; +binmode $builder->todo_output, ":utf8"; + +my $tests = { + # Complex tests + "\x{C6}neid" => "AEneid", + "\x{E9}tude" => "etude", + "\x{5317}\x{4EB0}" => "Bei Jing ", # Chinese + "\x{1515}\x{14c7}\x{14c7}" => "shanana", # Canadian syllabics + "\x{13d4}\x{13b5}\x{13c6}" => "taliqua", # Cherokee + "\x{0726}\x{071b}\x{073d}\x{0710}\x{073a}" => "ptu'i", # Syriac + "\x{0905}\x{092d}\x{093f}\x{091c}\x{0940}\x{0924}" => "abhijiit", # Devanagari + "\x{0985}\x{09ad}\x{09bf}\x{099c}\x{09c0}\x{09a4}" => "abhijiit", # Bangali + "\x{0d05}\x{0d2d}\x{0d3f}\x{0d1c}\x{0d40}\x{0d24}" => "abhijiit", # Malayalaam + # The Malayalaam word for "Malayalaam" + # If we were doing this right, it should come out as "malayalaam" - not "mlyaalm" + "\x{0d2e}\x{0d32}\x{0d2f}\x{0d3e}\x{0d32}\x{0d2e}\x{0d4d}" => "mlyaalm", + "\x{3052}\x{3093}\x{307e}\x{3044}\x{8336}" => "genmaiCha ", # Japanese +}; +plan tests => scalar keys %$tests; + +foreach my $line (keys %$tests) { + my $was = $line; + my $should = $tests->{$line}; + my $is = unidecode($was); + + is($is, $should, "$was -> $is (should be: $should)"); +} diff --git a/test.pl b/test.pl deleted file mode 100644 index 51d5d66..0000000 --- a/test.pl +++ /dev/null @@ -1,96 +0,0 @@ - -# Before `make install' is performed this script should be runnable with -# `make test'. After `make install' it should work as `perl test.pl' - -######################### We start with some black magic to print on failure. - # Time-stamp: "2001-07-14 01:48:48 MDT" - -require 5.006; - # This is a Perl program. -use strict; -use utf8; -use Test; - -BEGIN { plan tests => 17 } - -use Text::Unidecode; - -ok 1; -print "# Text::Unidecode v$Text::Unidecode::VERSION\n", - "# Perl v$]\n", - "# Starting tests...\n"; - -my $in = "\x{0d9c}\x{0d8e}!\n"; -my($was, $should, $is); -foreach my $line ( - -#"# 7-bit purity tests: all chars 00 to 7F\n", -#map(\ord($_), 0x00 .. 0x7f), - -"# Basic string tests\n", -\( - "", - 1/10, - "I like pie.", - "\n", - "\cm\cj", - "I like pie.\n", -), - -"#\n", -"# COMPLEX TESTS\n", - -split(m/\n/, <<"EOTESTS"), -<\x{C6}neid> <AEneid> -<\x{E9}tude> <etude> -<\x{5317}\x{4EB0}> <Bei Jing > - ; Chinese -<\x{1515}\x{14c7}\x{14c7}> <shanana> - ; Canadian syllabics -<\x{13d4}\x{13b5}\x{13c6}> <taliqua> - ; Cherokee -<\x{0726}\x{071b}\x{073d}\x{0710}\x{073a}> <ptu'i> - ; Syriac -<\x{0905}\x{092d}\x{093f}\x{091c}\x{0940}\x{0924}> <abhijiit> - ; Devanagari -<\x{0985}\x{09ad}\x{09bf}\x{099c}\x{09c0}\x{09a4}> <abhijiit> - ; Bengali -<\x{0d05}\x{0d2d}\x{0d3f}\x{0d1c}\x{0d40}\x{0d24}> <abhijiit> - ; Malayalaam -<\x{0d2e}\x{0d32}\x{0d2f}\x{0d3e}\x{0d32}\x{0d2e}\x{0d4d}> <mlyaalm> - ; the Malayaalam word for "Malayaalam" - ; Yes, if we were doing it right, that'd be "malayaalam", not "mlyaalm" - -<\x{3052}\x{3093}\x{307e}\x{3044}\x{8336}> <genmaiCha > - ; Japanese, astonishingly unmangled. - -EOTESTS - -# TODO: more tests, I guess. - -"# End of test data\n", -) { - if(ref $line) { # it should pass thru untouched - #print ref($line), "\n"; - $was = $should = $$line; - } else { - if($line =~ m/<(.*?)>\s*<(.*?)>/ or $line =~ m/\[(.*?)\]\s*\[(.*?)\]/ ){ - ($was, $should) = ($1,$2); - } else { - print $line if $line =~ m/^\s*#/s; - next; - } - } - $is = unidecode($was); - if($should eq $is) { - ok 1; - for($should, $is, $was) { s/\n/\\n/g; s/\cm/\\cm/g; s/\cj/\\cj/g; } - print " # <$was> -> <$is> (ok)\n"; - } else { - ok 0; - for($should, $is, $was) { s/\n/\\n/g } - print " # <$was> -> <$is>, but should be <$should>\n"; - } -} -print "# Byebye\n"; -