summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-08-09 13:24:30 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-08-09 14:27:46 -0700
commit413bcf20425992762a9a5a6e19caddc5ff160303 (patch)
tree4606305c26969bdaf955e7a74a860c73f2796c1f /tests
parent72544de443701a1d9907db9583db4c948517338e (diff)
Add readFileSync
Diffstat (limited to 'tests')
-rw-r--r--tests/read_file_sync.ts18
-rw-r--r--tests/read_file_sync.ts.out1
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/read_file_sync.ts b/tests/read_file_sync.ts
new file mode 100644
index 000000000..9e6c555c8
--- /dev/null
+++ b/tests/read_file_sync.ts
@@ -0,0 +1,18 @@
+// TODO(ry) Once unit_tests.js lands (#448) this file should be removed
+// and replaced with a faster version like was done in the prototype.
+// https://github.com/denoland/deno/blob/golang/tests.ts#L34-L45
+import * as deno from "deno";
+
+const data = deno.readFileSync("package.json");
+if (!data.byteLength) {
+ throw Error(
+ `Expected positive value for data.byteLength ${data.byteLength}`
+ );
+}
+const decoder = new TextDecoder("utf-8");
+const json = decoder.decode(data);
+const pkg = JSON.parse(json);
+if (pkg['devDependencies'] == null) {
+ throw Error("Expected a positive number of devDependencies");
+}
+console.log("ok");
diff --git a/tests/read_file_sync.ts.out b/tests/read_file_sync.ts.out
new file mode 100644
index 000000000..9766475a4
--- /dev/null
+++ b/tests/read_file_sync.ts.out
@@ -0,0 +1 @@
+ok