-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
test: increase test coverage for os.js #14098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bf4b193
test: increase test coverage for os.js
viktor-ku 3233b4d
test: add os.networkInterfaces test case for aix
viktor-ku 4c6aaab
test: add PASS,FLAKY in parallel.status
viktor-ku fdd2780
test: Resolve conflicts, remove aix test case
viktor-ku c923d4e
Unset aix flaky, remove loop for toPrimitive tests
viktor-ku eced626
Change to + and string templates
viktor-ku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Unset aix flaky, remove loop for toPrimitive tests
- Loading branch information
commit c923d4e4a6459169bdee230582e6fcda04e3f3fd
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,8 +27,11 @@ const path = require('path'); | |
| const { inspect } = require('util'); | ||
|
|
||
| const is = { | ||
| number: (value, key) => { | ||
| assert(!isNaN(value), `${key} should not be NaN`); | ||
| assert.strictEqual(typeof value, 'number'); | ||
| }, | ||
| string: (value) => { assert.strictEqual(typeof value, 'string'); }, | ||
| number: (value) => { assert.strictEqual(typeof value, 'number'); }, | ||
| array: (value) => { assert.ok(Array.isArray(value)); }, | ||
| object: (value) => { | ||
| assert.strictEqual(typeof value, 'object'); | ||
|
|
@@ -217,17 +220,20 @@ assert.ok(pwd.homedir.includes(path.sep)); | |
| assert.strictEqual(pwd.username, pwdBuf.username.toString('utf8')); | ||
| assert.strictEqual(pwd.homedir, pwdBuf.homedir.toString('utf8')); | ||
|
|
||
| // Test Symbol.toPrimitive on these functions | ||
| [ | ||
| [+os.freemem, os.freemem()], | ||
| [+os.totalmem, os.totalmem()], | ||
| [+os.uptime, os.uptime()], | ||
| [`${os.hostname}`, os.hostname()], | ||
| [`${os.homedir}`, os.homedir()], | ||
| [`${os.release}`, os.release()], | ||
| [`${os.type}`, os.type()], | ||
| [`${os.endianness}`, os.endianness()], | ||
| [`${os.tmpdir}`, os.tmpdir()], | ||
| [`${os.arch}`, os.arch()], | ||
| [`${os.platform}`, os.platform()] | ||
| ].forEach(([expected, actual]) => assert.strictEqual(expected, actual)); | ||
| assert.strictEqual(String(os.hostname), os.hostname()); | ||
| assert.strictEqual(String(os.homedir), os.homedir()); | ||
| assert.strictEqual(String(os.release), os.release()); | ||
| assert.strictEqual(String(os.type), os.type()); | ||
| assert.strictEqual(String(os.endianness), os.endianness()); | ||
| assert.strictEqual(String(os.tmpdir), os.tmpdir()); | ||
| assert.strictEqual(String(os.arch), os.arch()); | ||
| assert.strictEqual(String(os.platform), os.platform()); | ||
|
|
||
| assert.strictEqual(Number(os.totalmem), os.totalmem()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think it is easier to read to stick to the template strings and to |
||
|
|
||
| // At least we can check that these values are numbers | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: change comment to: // Assert that the following values are coercible to numbers. |
||
| is.number(Number(os.uptime), 'uptime'); | ||
| is.number(os.uptime(), 'uptime'); | ||
|
|
||
| is.number(Number(os.freemem), 'freemem'); | ||
| is.number(os.freemem(), 'freemem'); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change. Please add that back in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's odd because I have this last line in my editor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shows two lines at the end of the file (i.e. the file ends in
\n\n- one shows up as a new line, and the other as an EOF\nwhich is required...)