From: Darren Chamberlain Date: Wed, 20 Aug 2003 14:32:49 +0000 (+0000) Subject: Forgot to add my new test, and made the use of CGI vs. CGI::Pretty more consistent. X-Git-Tag: v0.04~287 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=29ecbf4e7f0a1d2a7061906fbdea25ec091219b5;p=dbsrgits%2FSQL-Translator.git Forgot to add my new test, and made the use of CGI vs. CGI::Pretty more consistent. --- diff --git a/MANIFEST b/MANIFEST index 6dd4cae..275aba1 100644 --- a/MANIFEST +++ b/MANIFEST @@ -73,4 +73,3 @@ t/data/mysql/entire_syntax.sql t/data/pgsql/entire_syntax.sql t/data/sybase/create.sql t/data/xml/schema-basic-attribs.xml -t/data/xml/schema-basic-no_ns.xml diff --git a/lib/SQL/Translator/Producer/HTML.pm b/lib/SQL/Translator/Producer/HTML.pm index 0894a79..b332389 100644 --- a/lib/SQL/Translator/Producer/HTML.pm +++ b/lib/SQL/Translator/Producer/HTML.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::HTML; # ------------------------------------------------------------------- -# $Id: HTML.pm,v 1.7 2003-08-20 13:50:47 dlc Exp $ +# $Id: HTML.pm,v 1.8 2003-08-20 14:32:49 dlc Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark # @@ -21,10 +21,9 @@ package SQL::Translator::Producer::HTML; # ------------------------------------------------------------------- use strict; -use CGI; use Data::Dumper; use vars qw[ $VERSION ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/; use SQL::Translator::Schema::Constants; use SQL::Translator::Utils qw(header_comment); @@ -36,8 +35,12 @@ sub produce { my $schema_name = $schema->name || 'Schema'; my $args = $t->producer_args; my $q = defined $args->{'pretty'} - ? do { require CGI::Pretty; CGI::Pretty->new } - : CGI->new; + ? do { require CGI::Pretty; + import CGI::Pretty; + CGI::Pretty->new } + : do { require CGI; + import CGI; + CGI->new }; my $title = $args->{'title'} || "Description of $schema_name"; my $html = $q->start_html( diff --git a/t/20format_X_name.t b/t/20format_X_name.t new file mode 100644 index 0000000..d3556a9 --- /dev/null +++ b/t/20format_X_name.t @@ -0,0 +1,80 @@ +#!/usr/bin/perl +# vim: set ft=perl: + +use strict; + +use SQL::Translator; +use Test::More tests => 25; + +my (%format_X_name, $tr, $ret); + +my %format_X_name = ( + format_table_name => sub { "table_$_[0]" }, + format_package_name => sub { "package_$_[0]" }, + format_fk_name => sub { "fk_$_[0]" }, + format_pk_name => sub { "pk_$_[0]" }, +); + +ok($tr = SQL::Translator->new); + +is(($ret = $tr->format_table_name("foo")), "foo", + '$tr->format_table_name("foo") == "foo"'); +is(($ret = $tr->format_package_name("foo")), "foo", + '$tr->format_package_name("foo") == "foo"'); +is(($ret = $tr->format_fk_name("foo")), "foo", + '$tr->format_fk_name("foo") == "foo"'); +is(($ret = $tr->format_pk_name("foo")), "foo", + '$tr->format_pk_name("foo") == "foo"'); + +ok($tr->format_table_name($format_X_name{format_table_name}), + '$tr->format_table_name(sub { "table_$_[0]" })'); +is(($ret = $tr->format_table_name("foo")), "table_foo", + '$tr->format_table_name("foo") == "table_foo"'); + +ok($tr->format_package_name($format_X_name{format_package_name}), + '$tr->format_package_name(sub { "package_$_[0]" })'); +is(($ret = $tr->format_package_name("foo")), "package_foo", + '$tr->format_package_name("foo") == "package_foo"'); + +ok($tr->format_fk_name($format_X_name{format_fk_name}), + '$tr->format_fk_name(sub { "fk_$_[0]" })'); +is(($ret = $tr->format_fk_name("foo")), "fk_foo", + '$tr->format_fk_name("foo") == "fk_foo"'); + +ok($tr->format_pk_name($format_X_name{format_pk_name}), + '$tr->format_pk_name(sub { "pk_$_[0]" })'); +is(($ret = $tr->format_pk_name("foo")), "pk_foo", + '$tr->format_pk_name("foo") == "pk_foo"'); + + +ok($tr->format_table_name($format_X_name{format_table_name}), + '$tr->format_table_name(sub { "table_$_[0]" })'); +is(($ret = $tr->format_table_name("foo")), "table_foo", + '$tr->format_table_name("foo") == "table_foo"'); + +ok($tr->format_package_name($format_X_name{format_package_name}), + '$tr->format_package_name(sub { "package_$_[0]" })'); +is(($ret = $tr->format_package_name("foo")), "package_foo", + '$tr->format_package_name("foo") == "package_foo"'); + +ok($tr->format_fk_name($format_X_name{format_fk_name}), + '$tr->format_fk_name(sub { "fk_$_[0]" })'); +is(($ret = $tr->format_fk_name("foo")), "fk_foo", + '$tr->format_fk_name("foo") == "fk_foo"'); + +ok($tr->format_pk_name($format_X_name{format_pk_name}), + '$tr->format_pk_name(sub { "pk_$_[0]" })'); +is(($ret = $tr->format_pk_name("foo")), "pk_foo", + '$tr->format_pk_name("foo") == "pk_foo"'); + +is(($ret = $tr->format_table_name($format_X_name{format_table_name}, "foo")), "table_foo", + '$tr->format_table_name(sub { "table_$_[0]" }, "foo") == "table_foo"'); + +is(($ret = $tr->format_package_name($format_X_name{format_package_name}, "foo")), "package_foo", + '$tr->format_package_name(sub { "package_$_[0]" }, "foo") == "package_foo"'); + +is(($ret = $tr->format_fk_name($format_X_name{format_fk_name}, "foo")), "fk_foo", + '$tr->format_fk_name(sub { "fk_$_[0]" }, "foo") == "fk_foo"'); + +is(($ret = $tr->format_pk_name($format_X_name{format_pk_name}, "foo")), "pk_foo", + '$tr->format_pk_name(sub { "pk_$_[0]" }, "foo") == "pk_foo"');