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).
20 # Our object; uses the default parser and producer
21 my $tr = SQL::Translator->new;
23 # The filename, holder for all the data, and the filehandle
24 my $datafile = "t/data/mysql/Apache-Session-MySQL.sql";
26 my $fh = IO::File->new($datafile);
28 # Pass filename: simplest way
29 my $translated_datafile = $tr->translate($datafile);
31 # Pass string reference
32 read($fh, $data, -s $datafile);
33 my $translated_data = $tr->translate(\$data);
35 ok(length $translated_datafile, "passing string (filename) works");
36 ok(length $translated_data, "passing string as SCALAR reference");
37 is($translated_datafile, $translated_data, "from file == from string");