From 704c2d2d3cfea308e4cbe058cfec06e5375b439f Mon Sep 17 00:00:00 2001 From: Laurent Dami Date: Sat, 25 Oct 2014 05:32:24 +0200 Subject: [PATCH] fix RT#99747 - skip tests if Unicode::UCD is not installed --- t/virtual_table/21_perldata_charinfo.t | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/t/virtual_table/21_perldata_charinfo.t b/t/virtual_table/21_perldata_charinfo.t index 6ae5522..3a14cff 100644 --- a/t/virtual_table/21_perldata_charinfo.t +++ b/t/virtual_table/21_perldata_charinfo.t @@ -10,13 +10,22 @@ BEGIN { use t::lib::Test qw/connect_ok/; use Test::More; -use Test::NoWarnings; -use Unicode::UCD 'charinfo'; +BEGIN { + # check for old Perls which did not have Unicode::UCD in core + if (eval "use Unicode::UCD 'charinfo'; 1") { + plan tests => 10; + } + else { + plan skip_all => "Unicode::UCD does not seem to be installed"; + } +} + +use Test::NoWarnings; our $chars = [map {charinfo($_)} 0x300..0x400]; -plan tests => 10; +my $sigma_block = charinfo(0x3A3)->{block}; my $dbh = connect_ok( RaiseError => 1, AutoCommit => 1 ); @@ -31,14 +40,14 @@ ok $dbh->do(<<""), "create table"; my $sql = "SELECT * FROM charinfo WHERE script='Greek' AND name LIKE '%SIGMA%'"; my $res = $dbh->selectall_arrayref($sql, {Slice => {}}); ok scalar(@$res), "found sigma letters"; -is $res->[0]{block}, "Greek and Coptic", "letter in proper block"; +is $res->[0]{block}, $sigma_block, "letter in proper block"; # The former example used SQLite's LIKE operator; now do the same with MATCH # which gets translated to a Perl regex $sql = "SELECT * FROM charinfo WHERE script='Greek' AND name MATCH 'SIGMA'"; $res = $dbh->selectall_arrayref($sql, {Slice => {}}); ok scalar(@$res), "found sigma letters"; -is $res->[0]{block}, "Greek and Coptic", "letter in proper block"; +is $res->[0]{block}, $sigma_block, "letter in proper block"; # the following does not work because \b gets escaped as a literal #$sql = "SELECT * FROM charinfo WHERE script='Greek' AND name MATCH '\\bSIGMA\\b'"; @@ -49,4 +58,4 @@ is $res->[0]{block}, "Greek and Coptic", "letter in proper block"; $sql = "SELECT * FROM charinfo WHERE script='Greek' AND name REGEXP '\\bSIGMA\\b'"; $res = $dbh->selectall_arrayref($sql, {Slice => {}}); ok scalar(@$res), "found sigma letters"; -is $res->[0]{block}, "Greek and Coptic", "letter in proper block"; +is $res->[0]{block}, $sigma_block, "letter in proper block";