4 # This tests that the same file can be passed in using a filename,
5 # a filehandle, and a string, and return identical results. There's
6 # a lot of setup here, because we have to emulate the various ways
7 # that $tr->translate might be called: with a string (filename),
8 # with a filehandle (IO::File, FileHandle, or \*FOO), and with a
9 # scalar reference (data in a string).
16 use Test::More tests => 3;
18 # The filename, holder for all the data, and the filehandle
19 my $datafile = "t/data/mysql/Apache-Session-MySQL.sql";
21 my $fh = IO::File->new($datafile);
25 my $tr = SQL::Translator->new;
26 # Pass filename: simplest way
27 $tr->translate($datafile);
32 my $tr = SQL::Translator->new;
33 # Pass string reference
34 read($fh, $data, -s $datafile);
35 $tr->translate(\$data);
39 # XXX- Hack to remove Graph hack!
40 $_->translator (undef) for ($v1, $v2);
42 ok(length $v1, "passing string (filename) works");
43 ok(length $v2, "passing string as SCALAR reference");
44 is_deeply($v1, $v2, "from file == from string");