Skip to content

Commit 497489f

Browse files
Add tests for READFILE.
1 parent 5a9faba commit 497489f

6 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
IMPORT(path)
2+
3+
STR: missing = path.TEMPFILE("prefix-readfile-missing.txt")
4+
TRY{ DELETEFILE(missing) } CATCH { }
5+
READFILE(missing)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
IMPORT(path)
2+
3+
STR: p = JOIN(path.script_dir, "/plain.txt")
4+
5+
READFILE(p, coding = "UTF-7")

tests/cases/passing/plain.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prefix
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
IMPORT(path)
2+
3+
STR: p = JOIN(path.script_dir, "/plain.txt")
4+
5+
ASSERT(EQ(READFILE(p, coding = "ANSI"), "Prefix"))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
IMPORT(path)
2+
3+
STR: p = JOIN(path.script_dir, "/plain.txt")
4+
5+
ASSERT(EQ(READFILE(p, coding = "binary"), "010100000111001001100101011001100110100101111000"))
6+
ASSERT(EQ(READFILE(p, coding = "hex"), "507265666978"))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
IMPORT(path)
2+
3+
STR: p = JOIN(path.script_dir, "/plain.txt")
4+
5+
ASSERT(EQ(READFILE(p), "Prefix"))
6+
ASSERT(EQ(READFILE(p, coding = "uTf-8"), "Prefix"))

0 commit comments

Comments
 (0)