summaryrefslogtreecommitdiff
path: root/testdata
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-05-27 12:49:20 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-05-27 12:49:20 -0400
commit4e55928063b4f3378d2e9425c551ce0288ca39a2 (patch)
tree7c7959f3aaaf11ebd6f229ec9fd36d30035597f2 /testdata
parenta831d1e2391e67f6d6ad3284ab9858d9b8d610c1 (diff)
Add readFileSync
Diffstat (limited to 'testdata')
-rw-r--r--testdata/read_file_sync.ts14
-rw-r--r--testdata/read_file_sync.ts.out1
2 files changed, 15 insertions, 0 deletions
diff --git a/testdata/read_file_sync.ts b/testdata/read_file_sync.ts
new file mode 100644
index 000000000..cb0904d35
--- /dev/null
+++ b/testdata/read_file_sync.ts
@@ -0,0 +1,14 @@
+import { readFileSync } from "deno";
+
+let data = 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.name !== "deno") {
+ throw Error(`Expected "deno" but got "${pkg.name}"`)
+}
+console.log("package.name ", pkg.name);
diff --git a/testdata/read_file_sync.ts.out b/testdata/read_file_sync.ts.out
new file mode 100644
index 000000000..53d818f44
--- /dev/null
+++ b/testdata/read_file_sync.ts.out
@@ -0,0 +1 @@
+package.name deno