summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-04-25 14:48:32 -0700
committerJames M Snell <jasnell@gmail.com>2017-05-01 11:44:56 -0700
commit473572ea2512cbe71e3423f8094657986352c32d (patch)
tree55e476006103b217a0148aa1fd2d2a106d8b72d8 /test
parentea9eed56433c714b08930b906b292a21650b3928 (diff)
downloadandroid-node-v8-473572ea2512cbe71e3423f8094657986352c32d.tar.gz
android-node-v8-473572ea2512cbe71e3423f8094657986352c32d.tar.bz2
android-node-v8-473572ea2512cbe71e3423f8094657986352c32d.zip
os: refactor os structure, add Symbol.toPrimitive
Refactor the structure of the os module to use more efficient module.exports = {} pattern. Add Symbol.toPrimitive support to os methods that return simple primitives. This is a minor tweak that makes using these slightly more friendly when doing things like: ```js var m = `${os.tmpdir}/foo` ``` PR-URL: https://github.com/nodejs/node/pull/12654 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-os.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js
index 1c92100818..6b76d7506d 100644
--- a/test/parallel/test-os.js
+++ b/test/parallel/test-os.js
@@ -191,3 +191,12 @@ is.string(pwd.username);
assert.ok(pwd.homedir.includes(path.sep));
assert.strictEqual(pwd.username, pwdBuf.username.toString('utf8'));
assert.strictEqual(pwd.homedir, pwdBuf.homedir.toString('utf8'));
+
+// Test that the Symbol.toPrimitive functions work correctly
+[
+ [`${os.hostname}`, os.hostname()],
+ [`${os.homedir}`, os.homedir()],
+ [`${os.release}`, os.release()],
+ [`${os.type}`, os.type()],
+ [`${os.endianness}`, os.endianness()]
+].forEach((set) => assert.strictEqual(set[0], set[1]));