-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
additional IO tests, along with their Bend implementations
Add io programs that test basic functionality, including failures. This also updates the "smoke test" file, that does a sequence of open, read, write, close io calls on a file.
- Loading branch information
Showing
11 changed files
with
372 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
def unwrap(res): | ||
match res: | ||
case Result/Ok: | ||
return res.val | ||
case Result/Err: | ||
return res.val | ||
|
||
def main(): | ||
with IO: | ||
f <- call("OPEN", ("./README.md", "r")) | ||
f = unwrap(f) | ||
bytes <- call("READ", (f, 30)) | ||
bytes = unwrap(bytes) | ||
* <- call("WRITE", (1, bytes)) | ||
* <- call("WRITE", (1, "\n")) | ||
res <- call("CLOSE", f) | ||
|
||
return wrap(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
@IO/Call = (a (b (c (d ((@IO/Call/tag (a (b (c (d e))))) e))))) | ||
|
||
@IO/Call/tag = 1 | ||
|
||
@IO/Done = (a (b ((@IO/Done/tag (a (b c))) c))) | ||
|
||
@IO/Done/tag = 0 | ||
|
||
@IO/MAGIC = (13683217 16719857) | ||
|
||
@IO/bind = ((@IO/bind__C2 a) a) | ||
|
||
@IO/bind__C0 = (* (b (a c))) | ||
& @undefer ~ (a (b c)) | ||
|
||
@IO/bind__C1 = (* (* (a (b ((c d) (e g)))))) | ||
& @IO/Call ~ (@IO/MAGIC (a (b ((c f) g)))) | ||
& @IO/bind ~ (d (e f)) | ||
|
||
@IO/bind__C2 = (?((@IO/bind__C0 @IO/bind__C1) a) a) | ||
|
||
@IO/wrap = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@String/Cons = (a (b ((@String/Cons/tag (a (b c))) c))) | ||
|
||
@String/Cons/tag = 1 | ||
|
||
@String/Nil = ((@String/Nil/tag a) a) | ||
|
||
@String/Nil/tag = 0 | ||
|
||
@call = (a (b c)) | ||
& @IO/Call ~ (@IO/MAGIC (a (b (@call__C0 c)))) | ||
|
||
@call__C0 = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@main = mc | ||
& @IO/bind ~ (q ((((ic (r kc)) (@IO/wrap lc)) lc) mc)) | ||
& @call ~ (d ((o p) q)) | ||
& @String/Cons ~ (79 (c d)) | ||
& @String/Cons ~ (80 (b c)) | ||
& @String/Cons ~ (69 (a b)) | ||
& @String/Cons ~ (78 (@String/Nil a)) | ||
& @String/Cons ~ (46 (n o)) | ||
& @String/Cons ~ (47 (m n)) | ||
& @String/Cons ~ (82 (l m)) | ||
& @String/Cons ~ (69 (k l)) | ||
& @String/Cons ~ (65 (j k)) | ||
& @String/Cons ~ (68 (i j)) | ||
& @String/Cons ~ (77 (h i)) | ||
& @String/Cons ~ (69 (g h)) | ||
& @String/Cons ~ (46 (f g)) | ||
& @String/Cons ~ (109 (e f)) | ||
& @String/Cons ~ (100 (@String/Nil e)) | ||
& @String/Cons ~ (114 (@String/Nil p)) | ||
& @IO/bind ~ (x ((((dc (ec (db gc))) (hc (ic jc))) jc) kc)) | ||
& @unwrap ~ (r {w hc}) | ||
& @call ~ (v ((w 30) x)) | ||
& @String/Cons ~ (82 (u v)) | ||
& @String/Cons ~ (69 (t u)) | ||
& @String/Cons ~ (65 (s t)) | ||
& @String/Cons ~ (68 (@String/Nil s)) | ||
& @IO/bind ~ (fb ((((zb (ac (* cc))) (dc (ec fc))) fc) gc)) | ||
& @call ~ (cb ((1 eb) fb)) | ||
& @String/Cons ~ (87 (bb cb)) | ||
& @String/Cons ~ (82 (ab bb)) | ||
& @String/Cons ~ (73 (z ab)) | ||
& @String/Cons ~ (84 (y z)) | ||
& @String/Cons ~ (69 (@String/Nil y)) | ||
& @unwrap ~ (db eb) | ||
& @IO/bind ~ (mb ((((sb (wb (* yb))) (zb (ac bc))) bc) cc)) | ||
& @call ~ (kb ((1 lb) mb)) | ||
& @String/Cons ~ (87 (jb kb)) | ||
& @String/Cons ~ (82 (ib jb)) | ||
& @String/Cons ~ (73 (hb ib)) | ||
& @String/Cons ~ (84 (gb hb)) | ||
& @String/Cons ~ (69 (@String/Nil gb)) | ||
& @String/Cons ~ (10 (@String/Nil lb)) | ||
& @IO/bind ~ (tb ((((ub ub) (wb xb)) xb) yb)) | ||
& @call ~ (rb (sb tb)) | ||
& @String/Cons ~ (67 (qb rb)) | ||
& @String/Cons ~ (76 (pb qb)) | ||
& @String/Cons ~ (79 (ob pb)) | ||
& @String/Cons ~ (83 (nb ob)) | ||
& @String/Cons ~ (69 (@String/Nil nb)) | ||
|
||
@undefer = (((a a) b) b) | ||
|
||
@unwrap = ((@unwrap__C0 a) a) | ||
|
||
@unwrap__C0 = (?(((a a) (* (b b))) c) c) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def main(): | ||
with IO: | ||
f <- call("INVALID-NAME", ("./README.md", "r")) | ||
|
||
return wrap(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
@IO/Call = (a (b (c (d ((@IO/Call/tag (a (b (c (d e))))) e))))) | ||
|
||
@IO/Call/tag = 1 | ||
|
||
@IO/Done = (a (b ((@IO/Done/tag (a (b c))) c))) | ||
|
||
@IO/Done/tag = 0 | ||
|
||
@IO/MAGIC = (13683217 16719857) | ||
|
||
@IO/bind = ((@IO/bind__C2 a) a) | ||
|
||
@IO/bind__C0 = (* (b (a c))) | ||
& @undefer ~ (a (b c)) | ||
|
||
@IO/bind__C1 = (* (* (a (b ((c d) (e g)))))) | ||
& @IO/Call ~ (@IO/MAGIC (a (b ((c f) g)))) | ||
& @IO/bind ~ (d (e f)) | ||
|
||
@IO/bind__C2 = (?((@IO/bind__C0 @IO/bind__C1) a) a) | ||
|
||
@IO/wrap = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@String/Cons = (a (b ((@String/Cons/tag (a (b c))) c))) | ||
|
||
@String/Cons/tag = 1 | ||
|
||
@String/Nil = ((@String/Nil/tag a) a) | ||
|
||
@String/Nil/tag = 0 | ||
|
||
@call = (a (b c)) | ||
& @IO/Call ~ (@IO/MAGIC (a (b (@call__C0 c)))) | ||
|
||
@call__C0 = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@main = cb | ||
& @IO/bind ~ (y ((((z z) (@IO/wrap bb)) bb) cb)) | ||
& @call ~ (l ((w x) y)) | ||
& @String/Cons ~ (73 (k l)) | ||
& @String/Cons ~ (78 (j k)) | ||
& @String/Cons ~ (86 (i j)) | ||
& @String/Cons ~ (65 (h i)) | ||
& @String/Cons ~ (76 (g h)) | ||
& @String/Cons ~ (73 (f g)) | ||
& @String/Cons ~ (68 (e f)) | ||
& @String/Cons ~ (45 (d e)) | ||
& @String/Cons ~ (78 (c d)) | ||
& @String/Cons ~ (65 (b c)) | ||
& @String/Cons ~ (77 (a b)) | ||
& @String/Cons ~ (69 (@String/Nil a)) | ||
& @String/Cons ~ (46 (v w)) | ||
& @String/Cons ~ (47 (u v)) | ||
& @String/Cons ~ (82 (t u)) | ||
& @String/Cons ~ (69 (s t)) | ||
& @String/Cons ~ (65 (r s)) | ||
& @String/Cons ~ (68 (q r)) | ||
& @String/Cons ~ (77 (p q)) | ||
& @String/Cons ~ (69 (o p)) | ||
& @String/Cons ~ (46 (n o)) | ||
& @String/Cons ~ (109 (m n)) | ||
& @String/Cons ~ (100 (@String/Nil m)) | ||
& @String/Cons ~ (114 (@String/Nil x)) | ||
|
||
@undefer = (((a a) b) b) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def main(): | ||
with IO: | ||
f <- call("OPEN", ("./README.md", "r")) | ||
|
||
return wrap(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@IO/Call = (a (b (c (d ((@IO/Call/tag (a (b (c (d e))))) e))))) | ||
|
||
@IO/Call/tag = 1 | ||
|
||
@IO/Done = (a (b ((@IO/Done/tag (a (b c))) c))) | ||
|
||
@IO/Done/tag = 0 | ||
|
||
@IO/MAGIC = (13683217 16719857) | ||
|
||
@IO/bind = ((@IO/bind__C2 a) a) | ||
|
||
@IO/bind__C0 = (* (b (a c))) | ||
& @undefer ~ (a (b c)) | ||
|
||
@IO/bind__C1 = (* (* (a (b ((c d) (e g)))))) | ||
& @IO/Call ~ (@IO/MAGIC (a (b ((c f) g)))) | ||
& @IO/bind ~ (d (e f)) | ||
|
||
@IO/bind__C2 = (?((@IO/bind__C0 @IO/bind__C1) a) a) | ||
|
||
@IO/wrap = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@String/Cons = (a (b ((@String/Cons/tag (a (b c))) c))) | ||
|
||
@String/Cons/tag = 1 | ||
|
||
@String/Nil = ((@String/Nil/tag a) a) | ||
|
||
@String/Nil/tag = 0 | ||
|
||
@call = (a (b c)) | ||
& @IO/Call ~ (@IO/MAGIC (a (b (@call__C0 c)))) | ||
|
||
@call__C0 = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@main = u | ||
& @IO/bind ~ (q ((((r r) (@IO/wrap t)) t) u)) | ||
& @call ~ (d ((o p) q)) | ||
& @String/Cons ~ (79 (c d)) | ||
& @String/Cons ~ (80 (b c)) | ||
& @String/Cons ~ (69 (a b)) | ||
& @String/Cons ~ (78 (@String/Nil a)) | ||
& @String/Cons ~ (46 (n o)) | ||
& @String/Cons ~ (47 (m n)) | ||
& @String/Cons ~ (82 (l m)) | ||
& @String/Cons ~ (69 (k l)) | ||
& @String/Cons ~ (65 (j k)) | ||
& @String/Cons ~ (68 (i j)) | ||
& @String/Cons ~ (77 (h i)) | ||
& @String/Cons ~ (69 (g h)) | ||
& @String/Cons ~ (46 (f g)) | ||
& @String/Cons ~ (109 (e f)) | ||
& @String/Cons ~ (100 (@String/Nil e)) | ||
& @String/Cons ~ (114 (@String/Nil p)) | ||
|
||
@undefer = (((a a) b) b) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def main(): | ||
with IO: | ||
f <- call("OPEN", ("fake-file", "r")) | ||
|
||
return wrap(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@IO/Call = (a (b (c (d ((@IO/Call/tag (a (b (c (d e))))) e))))) | ||
|
||
@IO/Call/tag = 1 | ||
|
||
@IO/Done = (a (b ((@IO/Done/tag (a (b c))) c))) | ||
|
||
@IO/Done/tag = 0 | ||
|
||
@IO/MAGIC = (13683217 16719857) | ||
|
||
@IO/bind = ((@IO/bind__C2 a) a) | ||
|
||
@IO/bind__C0 = (* (b (a c))) | ||
& @undefer ~ (a (b c)) | ||
|
||
@IO/bind__C1 = (* (* (a (b ((c d) (e g)))))) | ||
& @IO/Call ~ (@IO/MAGIC (a (b ((c f) g)))) | ||
& @IO/bind ~ (d (e f)) | ||
|
||
@IO/bind__C2 = (?((@IO/bind__C0 @IO/bind__C1) a) a) | ||
|
||
@IO/wrap = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@String/Cons = (a (b ((@String/Cons/tag (a (b c))) c))) | ||
|
||
@String/Cons/tag = 1 | ||
|
||
@String/Nil = ((@String/Nil/tag a) a) | ||
|
||
@String/Nil/tag = 0 | ||
|
||
@call = (a (b c)) | ||
& @IO/Call ~ (@IO/MAGIC (a (b (@call__C0 c)))) | ||
|
||
@call__C0 = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@main = s | ||
& @IO/bind ~ (o ((((p p) (@IO/wrap r)) r) s)) | ||
& @call ~ (d ((m n) o)) | ||
& @String/Cons ~ (79 (c d)) | ||
& @String/Cons ~ (80 (b c)) | ||
& @String/Cons ~ (69 (a b)) | ||
& @String/Cons ~ (78 (@String/Nil a)) | ||
& @String/Cons ~ (102 (l m)) | ||
& @String/Cons ~ (97 (k l)) | ||
& @String/Cons ~ (107 (j k)) | ||
& @String/Cons ~ (101 (i j)) | ||
& @String/Cons ~ (45 (h i)) | ||
& @String/Cons ~ (102 (g h)) | ||
& @String/Cons ~ (105 (f g)) | ||
& @String/Cons ~ (108 (e f)) | ||
& @String/Cons ~ (101 (@String/Nil e)) | ||
& @String/Cons ~ (114 (@String/Nil n)) | ||
|
||
@undefer = (((a a) b) b) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def main(): | ||
with IO: | ||
# calling open with an unexpected type of arg | ||
f <- call("OPEN", 123) | ||
|
||
return wrap(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
@IO/Call = (a (b (c (d ((@IO/Call/tag (a (b (c (d e))))) e))))) | ||
|
||
@IO/Call/tag = 1 | ||
|
||
@IO/Done = (a (b ((@IO/Done/tag (a (b c))) c))) | ||
|
||
@IO/Done/tag = 0 | ||
|
||
@IO/MAGIC = (13683217 16719857) | ||
|
||
@IO/bind = ((@IO/bind__C2 a) a) | ||
|
||
@IO/bind__C0 = (* (b (a c))) | ||
& @undefer ~ (a (b c)) | ||
|
||
@IO/bind__C1 = (* (* (a (b ((c d) (e g)))))) | ||
& @IO/Call ~ (@IO/MAGIC (a (b ((c f) g)))) | ||
& @IO/bind ~ (d (e f)) | ||
|
||
@IO/bind__C2 = (?((@IO/bind__C0 @IO/bind__C1) a) a) | ||
|
||
@IO/wrap = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@String/Cons = (a (b ((@String/Cons/tag (a (b c))) c))) | ||
|
||
@String/Cons/tag = 1 | ||
|
||
@String/Nil = ((@String/Nil/tag a) a) | ||
|
||
@String/Nil/tag = 0 | ||
|
||
@call = (a (b c)) | ||
& @IO/Call ~ (@IO/MAGIC (a (b (@call__C0 c)))) | ||
|
||
@call__C0 = a | ||
& @IO/Done ~ (@IO/MAGIC a) | ||
|
||
@main = i | ||
& @IO/bind ~ (e ((((f f) (@IO/wrap h)) h) i)) | ||
& @call ~ (d (123 e)) | ||
& @String/Cons ~ (79 (c d)) | ||
& @String/Cons ~ (80 (b c)) | ||
& @String/Cons ~ (69 (a b)) | ||
& @String/Cons ~ (78 (@String/Nil a)) | ||
|
||
@undefer = (((a a) b) b) | ||
|
||
|
Oops, something went wrong.