1 # This tests that the same file can be passed in using a filename,
2 # a filehandle, and a string, and return identical results. There's
3 # a lot of setup here, because we have to emulate the various ways
4 # that $tr->translate might be called: with a string (filename),
5 # with a filehandle (IO::File, FileHandle, or \*FOO), and with a
6 # scalar reference (data in a string).
12 use Test::More tests => 3;
14 # The filename, holder for all the data, and the filehandle
15 my $datafile = "t/data/mysql/Apache-Session-MySQL.sql";
17 my $fh = IO::File->new($datafile);
21 my $tr = SQL::Translator->new;
22 # Pass filename: simplest way
23 $tr->translate(fh => $fh);
28 my $tr = SQL::Translator->new;
29 # Pass string reference
30 read($fh, $data, -s $datafile);
31 $tr->translate(\$data);
35 # XXX- Hack to remove Graph hack!
36 $_->translator (undef) for ($v1, $v2);
38 ok(length $v1, "passing string (filename) works");
39 ok(length $v2, "passing string as SCALAR reference");
40 is_deeply($v1, $v2, "from file == from string");