Skip to content

test: improve test-arm-math-illegal-instruction.js - #37670

Merged
aduh95 merged 1 commit into
nodejs:masterfrom
marsonya:test-improve-1
Mar 19, 2021
Merged

test: improve test-arm-math-illegal-instruction.js#37670
aduh95 merged 1 commit into
nodejs:masterfrom
marsonya:test-improve-1

Conversation

@marsonya

Copy link
Copy Markdown
Member

add Math.clz32(x) to the test

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Mar 9, 2021

@RaisinTenRaisinTen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about doing something like this instead:

Object.getOwnPropertyNames(Math).forEach(function(functionName){if(!/[A-Z]/.test(functionName)){// The function names don't have capital letters.Math[functionName](-0.5);}});

That way, we don't have to manually keep a track of all the function names.

@marsonya

Copy link
Copy Markdown
MemberAuthor

What do you think about doing something like this instead:

Object.getOwnPropertyNames(Math).forEach(function(functionName){if(!/[A-Z]/.test(functionName)){// The function names don't have capital letters.Math[functionName](-0.5);}});

That way, we don't have to manually keep a track of all the function names.

This seems like a great idea.
But, for some reason, the test considers only single parameter functions.
Functions like min, max, pow, etc are excluded.

@RaisinTen

Copy link
Copy Markdown
Member

I don't think that will be a problem given the purpose of the test:
https://github.com/nodejs/node/blob/f355549f7faa96f976284e178a7fbe5ac109350a/test/parallel/test-arm-math-illegal-instruction.js#L4-L7
I think it's just checking whether calling any of these Math functions end up failing with an illegal instruction error, so it does not really matter what we feed into these functions provided the error does not happen.

@marsonya

Copy link
Copy Markdown
MemberAuthor

I don't think that will be a problem given the purpose of the test:
https://github.com/nodejs/node/blob/f355549f7faa96f976284e178a7fbe5ac109350a/test/parallel/test-arm-math-illegal-instruction.js#L4-L7

I think it's just checking whether calling any of these Math functions end up failing with an illegal instruction error, so it does not really matter what we feed into these functions provided the error does not happen.

That sounds fair. The functions that require more than one parameters are simply returning NaN.

@marsonya

marsonya commented Mar 9, 2021

Copy link
Copy Markdown
MemberAuthor

What do you think about doing something like this instead:

Object.getOwnPropertyNames(Math).forEach(function(functionName){if(!/[A-Z]/.test(functionName)){// The function names don't have capital letters.Math[functionName](-0.5);}});

That way, we don't have to manually keep a track of all the function names.

This seems a great solution to me. Let's wait for more reviews.
If there is consensus around this, I will change the test.

@aduh95

Copy link
Copy Markdown
Contributor

+1 on @RaisinTen idea.

FWIW we could use _function_.length to determine how many parameters it expects (Math.abs.length === 1 and Math.pow.length === 2), although getting NaN seems OK too.

@marsonyamarsonya reopened this Mar 13, 2021
@marsonya

Copy link
Copy Markdown
MemberAuthor

New changes made as per @RaisinTen's idea.

@marsonyamarsonya changed the title test: add math function to test-arm-math-illegal-instruction.jstest: improve test-arm-math-illegal-instruction.jsMar 13, 2021
Comment threadtest/parallel/test-arm-math-illegal-instruction.js Outdated
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@aduh95aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 15, 2021
Instead of writing each Math function and keeping track, loop over Math
functions and test each one of them.
PR-URL: #37670
Reviewed-By: Darshan Sen <raisinten@gmail.com>
@aduh95

Copy link
Copy Markdown
Contributor

Landed in 67d2262

@aduh95
aduh95 merged commit 67d2262 into nodejs:masterMar 19, 2021
ruyadorno pushed a commit that referenced this pull request Mar 24, 2021
Instead of writing each Math function and keeping track, loop over Math
functions and test each one of them.
PR-URL: #37670
Reviewed-By: Darshan Sen <raisinten@gmail.com>
@ruyadornoruyadorno mentioned this pull request Mar 30, 2021
targos pushed a commit that referenced this pull request May 1, 2021
Instead of writing each Math function and keeping track, loop over Math
functions and test each one of them.
PR-URL: #37670
Reviewed-By: Darshan Sen <raisinten@gmail.com>
@danielleadamsdanielleadams mentioned this pull request May 3, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs that need a full CI run.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@marsonya@RaisinTen@aduh95@nodejs-github-bot