-
Notifications
You must be signed in to change notification settings - Fork 148
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
new test for shuffle #636
new test for shuffle #636
Conversation
addons/arrays/test_shuffle.sqf
Outdated
@@ -21,18 +21,14 @@ TEST_OP(count _result,==,count _original,_fn); | |||
TEST_OP(_x,in,_original,_fn); | |||
} forEach _result; | |||
|
|||
// Test depecated version. | |||
// test modify original |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remove what the old test checked. Add a new one that modifies the input array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior of the functions will change. It won't support the old deprecated Version anymore.
mentioned from commy #635 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactorise the old tests to do what they did before and add a new one that checks if the original array is modified if the function is asked to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[1,2,3,4,5,6,7] call CBA_fnc_shuffle;
Old version returns: [4,7,2,1,3,5,6]
New version returns: []
Old version threw a warning to rpt, but still worked.
I am a little worried some people would use it like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That aswell - use of the "direct array" parameter form is discouraged, but the function still works. Why break it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning has been in there since 2009.
My personal opinion is, that the CBA-users should have changed their functions after 8 years of warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Killswitch00 the new feature is not compatible with the old deprecated behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough (re 8 year warning). The unit test refactorisation need remains, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, but I don't understand, what you want from me.
Could you please be so kind and point it out for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at the last unit test you altered (line 31). That one is refactorised for the new parameter format. The first two tests in the original version should be kept, but updated in the same way. Then add the new test you added for the "modify input array" option.
@@ -21,18 +21,17 @@ TEST_OP(count _result,==,count _original,_fn); | |||
TEST_OP(_x,in,_original,_fn); | |||
} forEach _result; | |||
|
|||
// Test depecated version. | |||
_original = [1, 2, 3]; | |||
_result = _original call CBA_fnc_shuffle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Update the way the function is called and then do the same two checks that the original unit test performs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it would be the same test like in line 16. So you run the test twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't see that one. Good. All cases are covered.
commys wish from #635 (depending on this pull request)