addon-sdk/source/test/test-node-os.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4 "use strict";
michael@0 5
michael@0 6 let os = require("node/os");
michael@0 7 let system = require("sdk/system");
michael@0 8
michael@0 9 exports["test os"] = function (assert) {
michael@0 10 assert.equal(os.tmpdir(), system.pathFor("TmpD"), "os.tmpdir() matches temp dir");
michael@0 11 assert.ok(os.endianness() === "BE" || os.endianness() === "LE", "os.endianness is BE or LE");
michael@0 12
michael@0 13 assert.ok(os.arch().length > 0, "os.arch() returns a value");
michael@0 14 assert.equal(typeof os.arch(), "string", "os.arch() returns a string");
michael@0 15 assert.ok(os.type().length > 0, "os.type() returns a value");
michael@0 16 assert.equal(typeof os.type(), "string", "os.type() returns a string");
michael@0 17 assert.ok(os.platform().length > 0, "os.platform() returns a value");
michael@0 18 assert.equal(typeof os.platform(), "string", "os.platform() returns a string");
michael@0 19
michael@0 20 assert.ok(os.release().length > 0, "os.release() returns a value");
michael@0 21 assert.equal(typeof os.release(), "string", "os.release() returns a string");
michael@0 22 assert.ok(os.hostname().length > 0, "os.hostname() returns a value");
michael@0 23 assert.equal(typeof os.hostname(), "string", "os.hostname() returns a string");
michael@0 24 assert.ok(os.EOL === "\n" || os.EOL === "\r\n", "os.EOL returns a correct EOL char");
michael@0 25
michael@0 26 assert.deepEqual(os.loadavg(), [0, 0, 0], "os.loadavg() returns an array of 0s");
michael@0 27
michael@0 28 ["uptime", "totalmem", "freemem", "cpus"].forEach(method => {
michael@0 29 assert.throws(() => os[method](), "os." + method + " throws");
michael@0 30 });
michael@0 31 };
michael@0 32
michael@0 33 require("test").run(exports);

mercurial