6 $teststring = "1\n12\n123\n1234\n1234\n12345\n\n123456\n1234567\n";
8 # Create our test datafile
9 open TESTFILE, ">./foo" or die "error $! $^E opening";
11 print TESTFILE $teststring;
14 open TESTFILE, "<./foo";
17 # Check the default $/
19 if ($bar eq "1\n") {print "ok 1\n";} else {print "not ok 1\n";}
21 # explicitly set to \n
24 if ($bar eq "12\n") {print "ok 2\n";} else {print "not ok 2\n";}
26 # Try a non line terminator
29 if ($bar eq "123") {print "ok 3\n";} else {print "not ok 3\n";}
31 # Eat the line terminator
35 # How about a larger terminator
38 if ($bar eq "1234") {print "ok 4\n";} else {print "not ok 4\n";}
40 # Eat the line terminator
44 # Does paragraph mode work?
47 if ($bar eq "1234\n12345\n\n") {print "ok 5\n";} else {print "not ok 5\n";}
49 # Try slurping the rest of the file
52 if ($bar eq "123456\n1234567\n") {print "ok 6\n";} else {print "not ok 6\n";}
54 # try the record reading tests. New file so we don't have to worry about
58 open TESTFILE, ">./foo";
59 print TESTFILE "1234567890123456789012345678901234567890";
62 open TESTFILE, "<./foo";
65 # Test straight number
68 if ($bar eq "12") {print "ok 7\n";} else {print "not ok 7\n";}
70 # Test stringified number
73 if ($bar eq "34") {print "ok 8\n";} else {print "not ok 8\n";}
79 if ($bar eq "56") {print "ok 9\n";} else {print "not ok 9\n";}
85 if ($bar eq "78") {print "ok 10\n";} else {print "not ok 10\n";}
87 # Get rid of the temp file
90 # Now for the tricky bit--full record reading
92 # Create a temp file. We jump through these hoops 'cause CREATE really
93 # doesn't like our methods for some reason.
94 open FDLFILE, "> ./foo.fdl";
95 print FDLFILE "RECORD\n FORMAT VARIABLE\n";
97 open CREATEFILE, "> ./foo.com";
98 print CREATEFILE '$ DEFINE/USER SYS$INPUT NL:', "\n";
99 print CREATEFILE '$ DEFINE/USER SYS$OUTPUT NL:', "\n";
100 print CREATEFILE '$ OPEN YOW []FOO.BAR/WRITE', "\n";
101 print CREATEFILE '$ CLOSE YOW', "\n";
102 print CREATEFILE "\$EXIT\n";
104 $throwaway = `\@\[\]foo`, "\n";
105 open(TEMPFILE, ">./foo.bar") or print "# open failed $! $^E\n";
106 print TEMPFILE "foo\nfoobar\nbaz\n";
109 open TESTFILE, "<./foo.bar";
112 if ($bar eq "foo\n") {print "ok 11\n";} else {print "not ok 11\n";}
114 if ($bar eq "foobar\n") {print "ok 12\n";} else {print "not ok 12\n";}
115 # can we do a short read?
118 if ($bar eq "ba") {print "ok 13\n";} else {print "not ok 13\n";}
119 # do we get the rest of the record?
121 if ($bar eq "z\n") {print "ok 14\n";} else {print "not ok 14\n";}
126 # Nobody else does this at the moment (well, maybe OS/390, but they can
127 # put their own tests in) so we just punt
128 foreach $test (11..14) {print "ok $test # skipped on non-VMS system\n"};