diff --git a/node/os.ts b/node/os.ts index 8facde2921c0..51e5bbd93075 100644 --- a/node/os.ts +++ b/node/os.ts @@ -133,12 +133,12 @@ export function hostname(): string { return Deno.hostname(); } -/** Not yet implemented */ +/** Returns an array containing the 1, 5, and 15 minute load averages */ export function loadavg(): number[] { if (Deno.build.os == "win") { return [0, 0, 0]; } - notImplemented(SEE_GITHUB_ISSUE); + return Deno.loadavg(); } /** Not yet implemented */ diff --git a/node/os_test.ts b/node/os_test.ts index f13589a4bcdf..f825ae192b63 100644 --- a/node/os_test.ts +++ b/node/os_test.ts @@ -1,10 +1,5 @@ const { test } = Deno; -import { - assert, - assertThrows, - assertEquals, - AssertionError -} from "../testing/asserts.ts"; +import { assert, assertThrows, assertEquals } from "../testing/asserts.ts"; import * as os from "./os.ts"; test({ @@ -168,26 +163,14 @@ test({ } }); -// Method is currently implemented correctly for windows but not for any other os test({ name: "Load average is an array of 3 numbers", fn() { - try { - const result = os.loadavg(); - assert(result.length == 3); - assertEquals(typeof result[0], "number"); - assertEquals(typeof result[1], "number"); - assertEquals(typeof result[2], "number"); - } catch (error) { - if (!(Object.getPrototypeOf(error) === Error.prototype)) { - const errMsg = `Unexpected error class: ${error.name}`; - throw new AssertionError(errMsg); - } else if (!error.message.includes("Not implemented")) { - throw new AssertionError( - "Expected this error to contain 'Not implemented'" - ); - } - } + const result = os.loadavg(); + assert(result.length == 3); + assertEquals(typeof result[0], "number"); + assertEquals(typeof result[1], "number"); + assertEquals(typeof result[2], "number"); } });