[#144] Add: test coverage for reverse primitive #146
[#144] Add: test coverage for reverse primitive #146Magnus-Mage wants to merge 4 commits intoDyalog:mainfrom
Conversation
|
For Reverse First, i prefer to use a seperate namespace. However, testing both in same test suite will reduce code reuse. Also, i had some trouble using |
|
Hi @Magnus-Mage, Thanks for the PR. Let me know when you're satisfied I can review it. The meaning of code coverage that we have in the project is checking the sources to see if all the source code written for the primitive is used and covered. So I have unchecked the checkbox in the first message on the PR. :) |
|
Starting out, I had four unnecessary nested loops iterating over I was also using RunVariations incorrectly at first, simply because I didn't fully understand its syntax and argument passing for monadic primitives, which got resolved after working through the documentation more carefully. The model function was also my mistake as I had used Nested arrays, pointer arrays, and bracket-axis tests were initially put in but following the advice I have removed them from the test for now. |
sloorush
left a comment
There was a problem hiding this comment.
Thank you so much, this was very nice for a first PR. I have some comments, mostly nit picks.
tests/reverse.apln
Outdated
| cmplx←{⍵,-⍵}(0J1×⍳100)+⌽⍳100 | ||
| Hcmplx←{⍵,-⍵}(100000000000000J100000000000000×⍳20) | ||
|
|
||
| :For case :In 'bool' 'i1' 'i2' 'i3' 'dbl' 'Hdbl' 'fl' 'Hfl' 'cmplx' 'Hcmplx' |
There was a problem hiding this comment.
Is there a reason why we are not looping the tests over ⎕IO?
There was a problem hiding this comment.
⎕IO should be covered in RunVariations but i can loop for explicit tests.
tests/reverse.apln
Outdated
| :For case :In 'bool' 'i1' 'i2' 'i3' 'dbl' 'Hdbl' 'fl' 'Hfl' 'cmplx' 'Hcmplx' | ||
| data←⍎case | ||
| desc←testDesc |
There was a problem hiding this comment.
All, the data we have here is of the same datatype in the array. Is there a reason cross datatype tests were skipped?
There was a problem hiding this comment.
Cross-datatype numeric tests (e.g., i1,dbl) were skipped because APL type coercion automatically promotes mixed numeric arrays to a homogeneous array of the wider type before reverse operates on them. Per the APL Wiki on Arrays (https://aplwiki.com/wiki/Array)
"When a numeric array is formed from numbers with different types, all numbers are converted to a common type in order to be represented as a flat array."
For mixed numeric/character arrays: per Dyalog 20.0 documentation (https://docs.dyalog.com/20.0/programming-reference-guide/introduction/arrays/display-of-arrays/), these become "mixed arrays" which are displayed alongside "simple numeric" arrays but contain both types. I can add those specifically as provided.
If there's a specific cross-datatype scenario you think would expose different behavior in reverse that current tests miss, i can add accordingly.
… array tests and fixs
|
I was busy with some stuff so i wasn't able to update for the additional tests as we discussed. @sloorush Go ahead and let me know if this looks good. |
|
The remaining tests should be for nested structures for numeric and mixed types. I can add them as soon as possible. I have hit the wall after that, if you think there are any other cases that are still remaining, let me know. Furthermore, i still havent added other axes, better to open a seperate pr to add those or should be continued in this one only? |
Related Issue(s)
R←⌽[K]Y#144Description
Following ULLU framework guidelines, added comprehensive test coverage for the reverse primitive:
testDescfunction for consistent test outputTotal coverage: 6640 assertions across 32 system setting combinations
Note: Not using
RunVariationspattern for this suite - using explicit loops for better clarity and maintainability.PR Checklist (Remove options that are not relevant)