From: Jarkko Hietaniemi Date: Sun, 12 Nov 2000 23:54:22 +0000 (+0000) Subject: (Subsumed by #7664) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3b7ee3f0b5b79d2ee18566e69885aff23a5ec6ee;p=p5sagit%2Fp5-mst-13.2.git (Subsumed by #7664) p4raw-id: //depot/perl@7660 --- diff --git a/MANIFEST b/MANIFEST index eb1ec5c..3161168 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1554,6 +1554,7 @@ t/op/subst_wamp.t See if substitution works with $& present t/op/substr.t See if substr works t/op/sysio.t See if sysread and syswrite work t/op/taint.t See if tainting works +t/op/tell.t See if tell works t/op/tie.t See if tie/untie functions work t/op/tiearray.t See if tie for arrays works t/op/tiehandle.t See if tie for handles works diff --git a/t/op/tell.t b/t/op/tell.t new file mode 100644 index 0000000..a4500d1 --- /dev/null +++ b/t/op/tell.t @@ -0,0 +1,53 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +# NOTE: we cannot use seek() here because using that *portably* would mean +# using Fcntl and the principle is not to use any extensions in the t/op/* + +print "1..6\n"; + +{ +no warnings 'io'; +print "not " unless tell(TEST) == -1; +print "ok 1\n"; +} + +open(TEST, "TEST") || die "$0: failed to open 'TEST' for reading: $!\n"; + +print "not " unless tell(TEST) == 0; +print "ok 2\n"; + +my ($s, $read); + +$read = read(TEST, $s, 2); + +$read == 2 || warn "$0: read() returned $read, expected 2\n"; +$s eq '#!' || warn "$0: read() read '$s', expected '#!'\n"; + +print "not " unless tell(TEST) == 2; +print "ok 3\n"; + +print "not " unless tell() == 2; +print "ok 4\n"; + +my $TEST = 'TEST'; + +print "not " unless tell($TEST) == 2; +print "ok 5\n"; + +close(TEST) || warn "$0: close() failed: $!\n"; + +{ +no warnings 'io'; +print "not " unless tell(TEST) == -1; +print "ok 6\n"; +} + +# ftell(STDIN) (or any std streams) is undefined, it can return -1 or +# something else. ftell() on pipes, fifos, and sockets is defined to +# return -1. +