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

Tests for 2.0-rc1 #12

Closed
sorinsarca opened this issue Dec 3, 2020 · 3 comments
Closed

Tests for 2.0-rc1 #12

sorinsarca opened this issue Dec 3, 2020 · 3 comments
Assignees
Labels

Comments

@sorinsarca
Copy link

sorinsarca commented Dec 3, 2020

Here are some tests

Numbers

$a = [1];
$b = [PHP_FLOAT_EPSILON + 1];


$r = ArrayDiffMultidimensional::compare($a, $b);
// expected: [1], actual: []
var_dump($r);

Arrays

$a = [[]];
$b = [1];


$r = ArrayDiffMultidimensional::compare($a, $b);
// expected: [[]], actual: []
var_dump($r);

References

$a = [1, 2, &$a];
$b = [1, 2, &$b];

$r = ArrayDiffMultidimensional::compare($a, $b);
// expected: [], actual: infinite recursion
var_dump($r);
@rogervila
Copy link
Owner

Thank you @sorinsarca!
I will add them on the test suite

@rogervila rogervila mentioned this issue Dec 4, 2020
@rogervila rogervila self-assigned this Dec 15, 2020
@rogervila rogervila added the bug label Dec 15, 2020
@rogervila
Copy link
Owner

The references issue is quite a corner case, and since I do not have a lot of time I think I will not add support for it.

I suggest to use ArrayObject to create a copy of the array before passing it to the compare call: https://www.php.net/manual/es/arrayobject.getarraycopy.php

@rogervila
Copy link
Owner

I have released 2.0.0
Thank you for opening this issue.

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