Skip to content

Conversation

@marsonya
Copy link
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
Copy link
Member

@RaisinTenRaisinTen left a comment

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
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
Member

I don't think that will be a problem given the purpose of the test:

// This test ensures Math functions don't fail with an "illegal instruction"
// error on ARM devices (primarily on the Raspberry Pi 1)
// See https://github.com/nodejs/node/issues/1376
// and https://code.google.com/p/v8/issues/detail?id=4019

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
MemberAuthor

I don't think that will be a problem given the purpose of the test:

// This test ensures Math functions don't fail with an "illegal instruction"
// error on ARM devices (primarily on the Raspberry Pi 1)
// See https://github.com/nodejs/node/issues/1376
// and https://code.google.com/p/v8/issues/detail?id=4019

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
Copy link
MemberAuthor

marsonya commented Mar 9, 2021

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
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
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
@nodejs-github-bot
Copy link
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 <[email protected]>
@aduh95
Copy link
Contributor

Landed in 67d2262

@aduh95aduh95 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 <[email protected]>
@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 <[email protected]>
@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