diff --git a/src/Fs.re b/src/Fs.re new file mode 100644 index 0000000..a11ee60 --- /dev/null +++ b/src/Fs.re @@ -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; + } + }: +}; diff --git a/src/Fs.rei b/src/Fs.rei new file mode 100644 index 0000000..7e50318 --- /dev/null +++ b/src/Fs.rei @@ -0,0 +1,3 @@ +/* Fs.re */ + +let readFileSync: (path: string) => string; diff --git a/test/Rench_Test/FsTest.re b/test/Rench_Test/FsTest.re new file mode 100644 index 0000000..ae166c0 --- /dev/null +++ b/test/Rench_Test/FsTest.re @@ -0,0 +1,9 @@ +open TestFramework; + +module Event = Rench.Event; + +describe("Fs", ({test, _}) => { + test("readFileSync", ({expect}) => { + expect.int(0).toBe(1); + }); +}); diff --git a/test/bin/TestFile.txt b/test/bin/TestFile.txt new file mode 100644 index 0000000..6fd9ce9 --- /dev/null +++ b/test/bin/TestFile.txt @@ -0,0 +1,2 @@ +Line 1: A +Line 2: B diff --git a/test/bin/dune b/test/bin/dune index 4249217..c3b1a8c 100644 --- a/test/bin/dune +++ b/test/bin/dune @@ -3,3 +3,8 @@ (public_name TestRunner.exe) (libraries Rench_Test) (package Rench_Test)) + +(install + (section bin) + (package Rench_Test) + (files TestFile.txt))