Skip to content

Commit

Permalink
Merge pull request #668 from HigherOrderCO/462-reenable-io-tests
Browse files Browse the repository at this point in the history
#462 Reenable io tests
  • Loading branch information
imaqtkatt authored Aug 12, 2024
2 parents c3d86e3 + 5a5c52c commit d2cc03e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/fun/builtins.bend
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,14 @@ def IO/FS/read_line.read_chunks(fd, chunks):
# Writes a list of bytes to a file given by a path.
def IO/FS/write_file(path, bytes):
with IO:
f <- IO/done_on_err(IO/FS/open(path, "w"))
* <- IO/done_on_err(IO/FS/write(f, bytes))
* <- IO/done_on_err(IO/FS/close(f))
return wrap(bytes)
f <- IO/FS/open(path, "w")
match f:
case Result/Err:
return wrap(Result/Err(f.val))
case Result/Ok:
* <- IO/done_on_err(IO/FS/write(f.val, bytes))
* <- IO/done_on_err(IO/FS/close(f.val))
return wrap(Result/Ok(bytes))

### Standard input and output utilities

Expand Down
1 change: 0 additions & 1 deletion tests/golden_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ fn mutual_recursion() {
}

#[test]
#[ignore = "while IO is not implemented for hvm32"]
fn io() {
run_golden_test_dir_multiple(
function_name!(),
Expand Down
6 changes: 6 additions & 0 deletions tests/snapshots/io__load.bend.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/io/load.bend
---
Strict mode:
"Contents\n"
6 changes: 6 additions & 0 deletions tests/snapshots/io__load_fail.bend.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/io/load_fail.bend
---
Strict mode:
1
6 changes: 6 additions & 0 deletions tests/snapshots/io__store.bend.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/io/store.bend
---
Strict mode:
λa (a Result/Ok/tag [40, 77, 97, 105, 110, 41, 32, 61, 32, 48])
6 changes: 6 additions & 0 deletions tests/snapshots/io__store_fail.bend.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/io/store_fail.bend
---
Strict mode:
λa (a Result/Err/tag λb (b 2 +2))

0 comments on commit d2cc03e

Please sign in to comment.