sub test_encodings { my ($fh, $fn) = tempfile(); $fh->print($file_string); $fh->close(); is_deeply( [ Fancy::Open::fancy_open($fn) ], [ map encode('utf8', $_), @wanted_array ], "testing an array opened with no encoding" ); my @encodings = qw(UTF-8 ascii cp1252 iso-8859-1); for my $encoding (@encodings) { is_deeply( [ Fancy::Open::fancy_open($fn, { 'encoding' => $encoding }) ], [ map encode($encoding, $_), @wanted_array ], "testing an array opened with $encoding encoding" ); } } sub test_with_file_that_ends_with_a_newline { my ($fh, $fn) = tempfile(); $fh->print("$file_string\n"); $fh->close(); is_deeply( [ Fancy::Open::fancy_open($fn) ], [ @wanted_array ], "testing a plain array with file that ends with a newline" ); is_deeply( [ Fancy::Open::fancy_open($fn, { 'before' => 'solid ' }) ], [ @solid_array ], "testing an array with before option with file that ends with a newline" ); is_deeply( [ Fancy::Open::fancy_open($fn, { 'after' => ' bead' }) ], [ @bead_array ], "testing an array with after option with file that ends with a newline" ); is_deeply( [ Fancy::Open::fancy_open($fn, { 'before' => 'solid ', 'after' => ' bead' }) ], [ @solid_bead_array ], "testing an array with before and after options with file that ends with a newline" ); }