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

runTest tests are generating false-positives #66

Closed
saadtazi opened this issue Sep 9, 2017 · 1 comment
Closed

runTest tests are generating false-positives #66

saadtazi opened this issue Sep 9, 2017 · 1 comment
Labels

Comments

@saadtazi
Copy link
Contributor

saadtazi commented Sep 9, 2017

I found out that this line is causing problem: some runTest tests that are suppose to fail are not failing because you are comparing 0 with 0 because isNaN('a string') or isNaN([1, 2]) returns true: all the tests that tries to compare strings or arrays are not valid.

repro step:
Try to modify any runTest test in test/string_operators.js or test/array_operators.js to make it fail (hint: it won't!).

I think the proper way to fix it is to do the following:

-          if (isNaN(actual) && isNaN(expected)) actual = expected = 0
+          if (actual !== actual && expected !== expected) actual = expected = 0

because NaN === NaN returns false.

There are 3 tests that fails with the suggested changes, 2 related to unicode characters and string operators, that I am not sure how to solve.

@kofrasa
Copy link
Owner

kofrasa commented Sep 9, 2017

Thanks.

Your fix is correct. I skipped the fact that other types with isNaN evaluate to true.

Will look at and address the broken operators

kofrasa added a commit that referenced this issue Sep 9, 2017
* filter out empty values from collection. fix #65
* correct NaN comparison in unit tests. fixes #66
* fix tests for $substrCP
* fix $substrBytes
* fix comparison operators by type checkin
kofrasa added a commit that referenced this issue Sep 9, 2017
* filter out empty values from collection. fix #65
* correct NaN comparison in unit tests. fixes #66
* fix tests for $substrCP
* fix $substrBytes
* fix comparison operators by type checkin
@kofrasa kofrasa closed this as completed in 1a66f12 Sep 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants