|
Revision 243, 1.7 kB
(checked in by JarrettBillingsley, 1 year ago)
|
--
|
| Line | |
|---|
| 1 |
// NOTE TO SELF: This does not run successfully with -cov enabled in the host. Causes a Heisenbug. |
|---|
| 2 |
module tests.iando; |
|---|
| 3 |
|
|---|
| 4 |
io.changeDir(`tests\files`); |
|---|
| 5 |
|
|---|
| 6 |
io.File("foo", io.FileMode.OutNew).close(); |
|---|
| 7 |
io.rename("foo", "bar"); |
|---|
| 8 |
io.copy("bar", "foo"); |
|---|
| 9 |
io.size("foo"); |
|---|
| 10 |
io.exists("foo"); |
|---|
| 11 |
io.isFile("foo"); |
|---|
| 12 |
io.isDir("bar"); |
|---|
| 13 |
io.currentDir(); |
|---|
| 14 |
io.makeDir("dir"); |
|---|
| 15 |
io.removeDir("dir"); |
|---|
| 16 |
io.listFiles(io.currentDir()); |
|---|
| 17 |
io.listFiles(io.currentDir(), "*.md"); |
|---|
| 18 |
io.listDirs(io.currentDir()); |
|---|
| 19 |
io.listDirs(io.currentDir(), "*x"); |
|---|
| 20 |
|
|---|
| 21 |
local f = io.File("foo"); |
|---|
| 22 |
try io.File("FOASAF"); catch(e){} |
|---|
| 23 |
f.seek(0, 'c'); |
|---|
| 24 |
f.seek(0, 'e'); |
|---|
| 25 |
f.seek(0, 'b'); |
|---|
| 26 |
try f.seek(0, 'n'); catch(e){} |
|---|
| 27 |
f.position(); |
|---|
| 28 |
f.position(0); |
|---|
| 29 |
f.size(); |
|---|
| 30 |
f.close(); |
|---|
| 31 |
|
|---|
| 32 |
f = io.File("foo", io.FileMode.In | io.FileMode.Out); |
|---|
| 33 |
f.isOpen(); |
|---|
| 34 |
f.writeInt(4); |
|---|
| 35 |
f.writeString("hi"); |
|---|
| 36 |
f.write("hi "); |
|---|
| 37 |
f.writeln("hello"); |
|---|
| 38 |
f.writef("bye"); |
|---|
| 39 |
f.writefln("foo"); |
|---|
| 40 |
f.writeChars("xyz"); |
|---|
| 41 |
f.writeJSON({}); |
|---|
| 42 |
f.writeJSON([], true); |
|---|
| 43 |
f.flush(); |
|---|
| 44 |
f.position(0); |
|---|
| 45 |
f.output().writeInt(4); |
|---|
| 46 |
f.output().writeString("hi"); |
|---|
| 47 |
f.output().write("hi "); |
|---|
| 48 |
f.output().writeln("hello"); |
|---|
| 49 |
f.output().writef("bye"); |
|---|
| 50 |
f.output().writefln("foo"); |
|---|
| 51 |
f.output().writeChars("xyz"); |
|---|
| 52 |
f.output().writeJSON({}); |
|---|
| 53 |
f.output().writeJSON([], true); |
|---|
| 54 |
f.output().flush(); |
|---|
| 55 |
f.position(0); |
|---|
| 56 |
f.position(); |
|---|
| 57 |
f.readInt(); |
|---|
| 58 |
f.readString(); |
|---|
| 59 |
f.readln(); |
|---|
| 60 |
// f.readf("%s"); |
|---|
| 61 |
f.readChars(1); |
|---|
| 62 |
f.position(0); |
|---|
| 63 |
f.input().readInt(); |
|---|
| 64 |
f.input().readString(); |
|---|
| 65 |
f.input().readln(); |
|---|
| 66 |
f.input().readChars(1); |
|---|
| 67 |
f.close(); |
|---|
| 68 |
|
|---|
| 69 |
f = io.File("lines.txt"); |
|---|
| 70 |
foreach(line; f){} |
|---|
| 71 |
f.close(); |
|---|
| 72 |
f = io.File("lines.txt"); |
|---|
| 73 |
foreach(line; f.input()){} |
|---|
| 74 |
f.close(); |
|---|
| 75 |
|
|---|
| 76 |
io.remove("foo"); |
|---|
| 77 |
io.remove("bar"); |
|---|
| 78 |
io.changeDir(`..\..`); |
|---|