-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Saturday 22 November 2003 13:15, Torsten Foertsch wrote: > I'll provide a test case for linux and windows. I think there are more OSes > that return an error on reading a directory file. But some let it go > without error like Solaris. For UNIX-like systems I could check if 'cat .' > succeeds and skip the test in that case. But what about the others? And how > to catch that it is a UNIX-like system? $^O returns a string but not > UNIX-likeness. Is there a portable solution for that? > > Is it better to put the new test in an existing file (e.g. t/io/read.t) or > should I create a new test file? Ok, here is a test. I think, it is portable. - --- perl-5.8.2/t/io/readline.t 1970-01-01 01:00:00.000000000 +0100 +++ perl-5.8.2.new/t/io/readline.t 2003-11-22 14:13:30.000000000 +0100 @@ -0,0 +1,32 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require './test.pl'; +} + +use strict; +use File::Spec; + +plan tests => 2; + +open F, File::Spec->curdir and sysread F, $_, 1; +my $err=$!+0; +close F; + +SKIP: { + skip 2 => "you can read directories as plain files" unless( $err ); + + $!=0; + open F, File::Spec->curdir and $_=<F>; + ok( $!==$err && !defined($_) => 'readline( DIRECTORY )' ); + close F; + + $!=0; + { local $/; + open F, File::Spec->curdir and $_=<F>; + ok( $!==$err && !defined($_) => 'readline( DIRECTORY ) slurp mode' ); + close F; + } +} -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/v2LswicyCTir8T4RAhDDAKCU6GwvqosqDNGRhytkFLydWaYPUwCcC6CZ nDyw02k3jg8TZTGluE0Hj0w= =1Nhy -----END PGP SIGNATURE-----Thread Previous | Thread Next