-bin/sql_translator.pl
-bin/validator_test.pl
BUGS
Changes
-lib/SQL/Translator/Parser/MySQL.pm
+MANIFEST
+MANIFEST.SKIP
+Makefile.PL
+TODO
+bin/auto-dia.pl
+bin/sql_translator.pl
+bin/validator_test.pl
+lib/SQL/Translator.pm
lib/SQL/Translator/Parser.pm
+lib/SQL/Translator/Parser/MySQL.pm
+lib/SQL/Translator/Parser/PostGreSQL.pm
lib/SQL/Translator/Parser/Sybase.pm
lib/SQL/Translator/Parser/xSV.pm
-lib/SQL/Translator.pm
+lib/SQL/Translator/Producer.pm
lib/SQL/Translator/Producer/MySQL.pm
lib/SQL/Translator/Producer/Oracle.pm
-lib/SQL/Translator/Producer.pm
lib/SQL/Translator/Producer/PostgreSQL.pm
-lib/SQL/Translator/Producer/XML.pm
lib/SQL/Translator/Producer/Raw.pm
+lib/SQL/Translator/Producer/XML.pm
lib/SQL/Translator/Validator.pm
-Makefile.PL
-MANIFEST
-MANIFEST.SKIP
t/01load.t
t/02mysql-parser.t
t/03mysql-to-oracle.t
t/07p_args.t
t/data/mysql/Apache-Session-MySQL.sql
t/data/mysql/BGEP-RE-create.sql
-TODO
use strict;
use ExtUtils::MakeMaker;
-use Config;
WriteMakefile(
'NAME' => __PACKAGE__,
'bin/sql_translator.pl',
],
'PREREQ_PM' => {
+ 'Class::Base' => 0,
+ 'File::Basename' => 0,
+ 'File::Spec' => 0,
+ 'IO::Dir' => 0,
'Parse::RecDescent' => 0, # Is a particular version needed?
- 'XML::Dumper' => 0,
'Pod::Usage' => 0,
- 'Class::Base' => 0,
+ 'Text::ParseWords' => 0,
+ 'XML::Dumper' => 0,
},
clean => {
FILES => '$(DISTNAME)-$(VERSION).tar.gz',
#
my @perlmods;
-my $count = 0;
+
+use Test::More;
+use SQL::Translator;
unless (open MANIFH, "MANIFEST") {
- print "1..1\n";
- print "not ok 1\n";
+ plan skip_all => "Can't open MANIFEST! ($!)";
exit;
}
+
while (<MANIFH>) {
chomp;
if (s/\.pm$//) {
s,/,::,g;
- s/^lib:://;
push @perlmods, $_
}
}
-print "1.." . scalar @perlmods . "\n";
-
close MANIFH;
+@perlmods = sort { length $a <=> length $b } @perlmods; # aesthetics
+plan tests => scalar @perlmods;
+
for my $mod (@perlmods) {
- $count++;
- $mod =~ s,/,::,g;
- eval "use $mod;";
- print "not " if ($@);
- print "ok $count # $mod\n";
+ SQL::Translator::load($mod);
+ ok(!$@, "use $mod");
}
#
use strict;
+
+use Test::More tests => 11;
use SQL::Translator;
use SQL::Translator::Parser::MySQL qw(parse);
-$SQL::Translator::DEBUG = 0;
-
my $tr = SQL::Translator->new;
my $data = q|create table sessions (
id char(32) not null primary key,
a_session text
);|;
-BEGIN { print "1..11\n"; }
-
my $val = parse($tr, $data);
# $val holds the processed data structure.
# The data structure should have one key:
-print "not " if (scalar keys %{$val} != 1);
-print "ok 1\n";
+is(scalar keys %{$val}, 1);
# The data structure should have a single key, named sessions
-print "not " unless (defined $val->{'sessions'});
-print qq(ok 2 # has a key named "sessions"\n);
+ok(defined $val->{'sessions'});
# $val->{'sessions'} should have a single index (since we haven't
# defined an index, but have defined a primary key)
my $indices = $val->{'sessions'}->{'indices'};
-print "not " unless (scalar @{$indices} == 1);
-print "ok 3 # correct index number\n";
+is(scalar @{$indices}, 1, "correct index number");
-print "not " unless ($indices->[0]->{'type'} eq 'primary_key');
-print "ok 4 # correct index type\n";
-print "not " unless ($indices->[0]->{'fields'}->[0] eq 'id');
-print "ok 5 # correct index name\n";
+is($indices->[0]->{'type'}, 'primary_key', "correct index type");
+is($indices->[0]->{'fields'}->[0], 'id', "correct index name");
# $val->{'sessions'} should have two fields, id and a_sessionn
my $fields = $val->{'sessions'}->{'fields'};
-print "not " unless (scalar keys %{$fields} == 2);
-print "ok 6 # correct fields number\n";
+is(scalar keys %{$fields}, 2, "correct fields number");
-print "not " unless ($fields->{'id'}->{'data_type'} eq 'char');
-print "ok 7 # correct field type: id (char)\n";
+is($fields->{'id'}->{'data_type'}, 'char',
+ "correct field type: id (char)");
-print "not " unless ($fields->{'a_session'}->{'data_type'} eq 'text');
-print "ok 8 # correct field type: a_session (text)\n";
+is ($fields->{'a_session'}->{'data_type'}, 'text',
+ "correct field type: a_session (text)");
-print "not " unless ($fields->{'id'}->{'is_primary_key'} == 1);
-print "ok 9 # correct key identification (id == key)\n";
+is($fields->{'id'}->{'is_primary_key'}, 1,
+ "correct key identification (id == key)");
-print "not " if (defined $fields->{'a_session'}->{'is_primary_key'});
-print "ok 10 # correct key identification (a_session != key)\n";
+ok(! defined $fields->{'a_session'}->{'is_primary_key'},
+ "correct key identification (a_session != key)");
# Test that the order is being maintained by the internal order
# data element
<=>
$fields->{$b}->{'order'}
} keys %{$fields};
-print "not " unless ($order[0] eq 'id' && $order[1] eq 'a_session');
-print "ok 11 # ordering of fields\n";
+
+ok($order[0] eq 'id' && $order[1] eq 'a_session', "ordering of fields");
#
#
-BEGIN { print "1..6\n"; }
-
use strict;
use SQL::Translator;
-$SQL::Translator::DEBUG = 0;
+use Test::More tests => 6;
sub silly_parser {
my ($tr, $data) = @_;
my $pargs = $tr->parser_args;
my $parsed = $tr->translate(\$data);
-print "not " unless ($pargs->{'delimiter'} eq '\|');
-print "ok 1 # parser_args works when called directly\n";
-
-print "not " unless (scalar @{$parsed} == 4);
-print "ok 2 # right number of fields\n";
+is($pargs->{'delimiter'}, '\|',
+ "parser_args works when called directly");
+is(scalar @{$parsed}, 4,
+ "right number of fields");
# Now, pass parser_args indirectly...
$tr->parser(\&silly_parser, { delimiter => "\t" });
$pargs = $tr->parser_args;
$parsed = $tr->translate(\$data);
-print "not " unless ($pargs->{'delimiter'} eq "\t");
-print "ok 3 # parser_args works when called indirectly\n";
+is($pargs->{'delimiter'}, "\t",
+ "parser_args works when called indirectly");
-print "not " unless (scalar @{$parsed} == 4);
-print "ok 4 # right number of fields with new delimiter\n";
+is(scalar @{$parsed}, 4,
+ "right number of fields with new delimiter");
undef $tr;
$tr = SQL::Translator->new(parser => \&silly_parser,
$pargs = $tr->parser_args;
$parsed = $tr->translate(\$data);
-print "not " unless ($pargs->{'delimiter'} eq ":");
-print "ok 5 # parser_args works when called as constructor arg\n";
+is($pargs->{'delimiter'}, ":",
+ "parser_args works when called as constructor arg");
-print "not " unless (scalar @{$parsed} == 4);
-print "ok 6 # right number of fields with new delimiter\n";
+is(scalar @{$parsed}, 4,
+ "right number of fields with new delimiter");