Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Fs.readFileSync #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Fs.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Fs.re */

let readFileSync = (path) => {
let chan = open_in_bin(path);
let data = ref("");
try ({
while (true) {
data := data ++ "\n" ++ input_line(chan);
}
data;
}) {
| End_of_file => {
close_in(chan);
data;
}
}:
};
3 changes: 3 additions & 0 deletions src/Fs.rei
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* Fs.re */

let readFileSync: (path: string) => string;
9 changes: 9 additions & 0 deletions test/Rench_Test/FsTest.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
open TestFramework;

module Event = Rench.Event;

describe("Fs", ({test, _}) => {
test("readFileSync", ({expect}) => {
expect.int(0).toBe(1);
});
});
2 changes: 2 additions & 0 deletions test/bin/TestFile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Line 1: A
Line 2: B
5 changes: 5 additions & 0 deletions test/bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
(public_name TestRunner.exe)
(libraries Rench_Test)
(package Rench_Test))

(install
(section bin)
(package Rench_Test)
(files TestFile.txt))