| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
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.
Sorry, something went wrong.
This seems like a great idea. |
Sorry, something went wrong.
|
I don't think that will be a problem given the purpose of the test: |
Sorry, something went wrong.
That sounds fair. The functions that require more than one parameters are simply returning NaN. |
Sorry, something went wrong.
This seems a great solution to me. Let's wait for more reviews. |
Sorry, something went wrong.
|
+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. |
Sorry, something went wrong.
|
New changes made as per @RaisinTen's idea. |
Sorry, something went wrong.
Sorry, something went wrong.
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>
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>
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>
| Back | FazBrowse Home | New Git URL |
add Math.clz32(x) to the test