summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authordiskkid <disk2id@gmail.com>2019-05-16 03:50:54 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-05-15 14:50:54 -0400
commit2508480465a25d5d87c407081feb6160f9707cab (patch)
treecaba9c9a875886e56be25ecbda80973b71c3cb68 /js
parenta00fa7056bb6493e3ca010afc4335f099dac0807 (diff)
Add error handling to dispatch_minimal::ops::read/write (#2349)
Diffstat (limited to 'js')
-rw-r--r--js/files_test.ts43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/files_test.ts b/js/files_test.ts
index 620d95ecd..350c1eb41 100644
--- a/js/files_test.ts
+++ b/js/files_test.ts
@@ -89,6 +89,49 @@ testPerm({ read: false }, async function readPermFailure(): Promise<void> {
assert(caughtError);
});
+testPerm({ write: true }, async function writeNullBufferFailure(): Promise<
+ void
+> {
+ const tempDir = Deno.makeTempDirSync();
+ const filename = tempDir + "hello.txt";
+ const file = await Deno.open(filename, "w");
+
+ // writing null should throw an error
+ let err;
+ try {
+ await file.write(null);
+ } catch (e) {
+ err = e;
+ }
+ // TODO: Check error kind when dispatch_minimal pipes errors properly
+ assert(!!err);
+
+ file.close();
+ await Deno.remove(tempDir, { recursive: true });
+});
+
+testPerm(
+ { write: true, read: true },
+ async function readNullBufferFailure(): Promise<void> {
+ const tempDir = Deno.makeTempDirSync();
+ const filename = tempDir + "hello.txt";
+ const file = await Deno.open(filename, "w+");
+
+ // reading file into null buffer should throw an error
+ let err;
+ try {
+ await file.read(null);
+ } catch (e) {
+ err = e;
+ }
+ // TODO: Check error kind when dispatch_minimal pipes errors properly
+ assert(!!err);
+
+ file.close();
+ await Deno.remove(tempDir, { recursive: true });
+ }
+);
+
testPerm(
{ write: false, read: false },
async function readWritePermFailure(): Promise<void> {