Skip to content
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

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

Merged
merged 1 commit into from
Mar 19, 2021
Merged

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

merged 1 commit into from
Mar 19, 2021

Conversation

marsonya
Copy link
Member

@marsonya marsonya commented Mar 9, 2021

add Math.clz32(x) to the test

@nodejs-github-bot nodejs-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
Contributor

@RaisinTen RaisinTen 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
Member Author

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

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

marsonya commented Mar 9, 2021

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

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

aduh95 commented Mar 10, 2021

+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.

@marsonya marsonya closed this Mar 13, 2021
@marsonya marsonya reopened this Mar 13, 2021
@marsonya
Copy link
Member Author

New changes made as per @RaisinTen's idea.

@marsonya marsonya changed the title test: add math function to test-arm-math-illegal-instruction.js test: improve test-arm-math-illegal-instruction.js Mar 13, 2021
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 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
Contributor

aduh95 commented Mar 19, 2021

Landed in 67d2262

@aduh95 aduh95 merged commit 67d2262 into nodejs:master Mar 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>
@ruyadorno ruyadorno 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>
@danielleadams danielleadams mentioned this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants