diff options
author | Dmitry Sharshakov <sh7dm@outlook.com> | 2019-02-08 23:59:38 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-08 15:59:38 -0500 |
commit | 9ab03389f047e5520c184b9fce4cd5fb2e4804bd (patch) | |
tree | c1b3295aa6788595e4b73d28aeba0b8fdc8f3205 /js/test_util.ts | |
parent | 3abaf9edb6877c328402b94fa0bcb6a9e0bbe86d (diff) |
Add --allow-read (#1689)
Co-authored-by: Greg Altman <g.s.altman@gmail.com>
Diffstat (limited to 'js/test_util.ts')
-rw-r--r-- | js/test_util.ts | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/js/test_util.ts b/js/test_util.ts index d3af0f12e..6791a5f3b 100644 --- a/js/test_util.ts +++ b/js/test_util.ts @@ -18,6 +18,7 @@ export { testing.setFilter(deno.args[1]); interface DenoPermissions { + read?: boolean; write?: boolean; net?: boolean; env?: boolean; @@ -25,24 +26,26 @@ interface DenoPermissions { } function permToString(perms: DenoPermissions): string { + const r = perms.read ? 1 : 0; const w = perms.write ? 1 : 0; const n = perms.net ? 1 : 0; const e = perms.env ? 1 : 0; - const r = perms.run ? 1 : 0; - return `permW${w}N${n}E${e}R${r}`; + const u = perms.run ? 1 : 0; + return `permR${r}W${w}N${n}E${e}U${u}`; } function permFromString(s: string): DenoPermissions { - const re = /^permW([01])N([01])E([01])R([01])$/; + const re = /^permR([01])W([01])N([01])E([01])U([01])$/; const found = s.match(re); if (!found) { throw Error("Not a permission string"); } return { - write: Boolean(Number(found[1])), - net: Boolean(Number(found[2])), - env: Boolean(Number(found[3])), - run: Boolean(Number(found[4])) + read: Boolean(Number(found[1])), + write: Boolean(Number(found[2])), + net: Boolean(Number(found[3])), + env: Boolean(Number(found[4])), + run: Boolean(Number(found[5])) }; } @@ -52,7 +55,10 @@ export function testPerm(perms: DenoPermissions, fn: testing.TestFunction) { } export function test(fn: testing.TestFunction) { - testPerm({ write: false, net: false, env: false, run: false }, fn); + testPerm( + { read: false, write: false, net: false, env: false, run: false }, + fn + ); } test(function permSerialization() { @@ -60,8 +66,10 @@ test(function permSerialization() { for (const net of [true, false]) { for (const env of [true, false]) { for (const run of [true, false]) { - const perms: DenoPermissions = { write, net, env, run }; - testing.assertEqual(perms, permFromString(permToString(perms))); + for (const read of [true, false]) { + const perms: DenoPermissions = { write, net, env, run, read }; + testing.assertEqual(perms, permFromString(permToString(perms))); + } } } } |