Merge pull request #668 from HigherOrderCO/462-reenable-io-tests

#462 Reenable io tests
This commit is contained in:
imaqtkatt 2024-08-12 14:04:20 +00:00 committed by GitHub
commit d2cc03eae1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 5 deletions

View File

@ -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

View File

@ -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!(),

View File

@ -0,0 +1,6 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/io/load.bend
---
Strict mode:
"Contents\n"

View File

@ -0,0 +1,6 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/io/load_fail.bend
---
Strict mode:
1

View File

@ -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])

View File

@ -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))