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

Fix failing tests with exit code -1 #17

Closed
ghost opened this issue Aug 24, 2022 · 1 comment
Closed

Fix failing tests with exit code -1 #17

ghost opened this issue Aug 24, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 24, 2022

OS: Windows 11
IDE: IntelliJ Idea
Dart SDK: '>=2.17.6 <3.0.0'
Dependencies:

#dependencies:
dev_dependencies:
  glados: ^1.1.3
  lints: ^2.0.0
  test: ^1.16.0

I've been practicing property-based testing with this library and I've run into a few instances of tests taking a very long time to run and eventually failing with exit code -1.

Here is an implementation of division where I purposefully return multiplication to test division's properties:

double div(double num1, double num2) => num1 * num2;

and my only test is:

Glados<double>().test('div', (num1) => expect(div(num1, num1), 1));

I initially thought that the test was hanging but it actually took 6 minutes to run and eventually failed without telling me on what values. It works fine when I change num1 * num2 to num1 / num2 so I believe the issue has something to do with glados' shrinking in regards to doubles since the following code failed quickly without issues:

double div(int num1, int num2) => (num1 * num2).toDouble();
Glados<int>().test('div2', (num1) => expect(div(num1, num1), 1));
@ghost ghost changed the title Fix failing tests Fix failing tests with exit code -1 Aug 24, 2022
@MarcelGarus
Copy link
Owner

Indeed, this was an error in the shrinking of doubles. In particular, it seems like the shrinking just generated a huuuuge amount of values (which, admittedly, were all smaller than the original).

I simplified the shrinking code to turn 3.2 -> 2.2 etc. (so, move numbers one closer to zero) and after that's not working, round values to some decimal places.

Your test case (which I also added as a regression test) seems to be fixed by that.

The new version is published as 1.1.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant