diff options
Diffstat (limited to 'js/test_util.ts')
-rw-r--r-- | js/test_util.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/js/test_util.ts b/js/test_util.ts index 34a920d47..93fc67491 100644 --- a/js/test_util.ts +++ b/js/test_util.ts @@ -18,17 +18,19 @@ interface DenoPermissions { write?: boolean; net?: boolean; env?: boolean; + run?: boolean; } function permToString(perms: DenoPermissions): string { const w = perms.write ? 1 : 0; const n = perms.net ? 1 : 0; const e = perms.env ? 1 : 0; - return `permW${w}N${n}E${e}`; + const r = perms.run ? 1 : 0; + return `permW${w}N${n}E${e}R${r}`; } function permFromString(s: string): DenoPermissions { - const re = /^permW([01])N([01])E([01])$/; + const re = /^permW([01])N([01])E([01])R([01])$/; const found = s.match(re); if (!found) { throw Error("Not a permission string"); @@ -36,7 +38,8 @@ function permFromString(s: string): DenoPermissions { return { write: Boolean(Number(found[1])), net: Boolean(Number(found[2])), - env: Boolean(Number(found[3])) + env: Boolean(Number(found[3])), + run: Boolean(Number(found[4])) }; } @@ -53,8 +56,10 @@ test(function permSerialization() { for (const write of [true, false]) { for (const net of [true, false]) { for (const env of [true, false]) { - const perms: DenoPermissions = { write, net, env }; - testing.assertEqual(perms, permFromString(permToString(perms))); + for (const run of [true, false]) { + const perms: DenoPermissions = { write, net, env, run }; + testing.assertEqual(perms, permFromString(permToString(perms))); + } } } } |