add unittest attributes to std.algorithm.sorting#4685
add unittest attributes to std.algorithm.sorting#4685WalterBright merged 2 commits intodlang:masterfrom
Conversation
Current coverage is 88.68% (diff: 100%)@@ master #4685 diff @@
==========================================
Files 121 121
Lines 73827 73827
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 65471 65472 +1
+ Misses 8356 8355 -1
Partials 0 0
|
|
Why explicit |
I agree its kinda pointless, but at least we can then turn on CI checking. For more infos: http://forum.dlang.org/thread/nkn1g6$b00$1@digitalmars.com?page=1 |
|
I don't understand. For example, why this should be marked as system? @system unittest
{
int[] a = [ 5, 7, 2, 6, 7 ];
int[] b = [ 2, 1, 5, 6, 7, 3, 0 ];
topN(a, b);
sort(a);
assert(a == [0, 1, 2, 2, 3]);
} |
Because |
If that code can't be marked as |
But all of that is internal to |
|
Because anything that is @System should be explicit so that we can grep for them and try to fix the problem |
|
@wilzbach : it's normal for that grep to hit, plenty of the tests have the attribute on the previous line |
|
|
|
You can grep for non @safe tests, but not easily. Explicit is better than implicit. |
59ee0a2 to
016d514
Compare
|
@ all - I didn't want to start this debate - I thought that it was a agreed practice. In any case I think we all can agree that just
Yes :/
Well it would be this line, but I don't know whether we can blindly apply |
std/algorithm/sorting.d
Outdated
| bool lessEqual(T a, T b){ return !less(b, a); } | ||
| bool greater()(T a, T b){ return less(b, a); } | ||
| bool greaterEqual()(T a, T b){ return !less(a, b); } | ||
| bool lessEqual()(T a, T b){ return !less(b, a); } |
|
It was called for by Walter. Step 1 is to mark all unit tests
We can discuss it right here. No, it shouldn't be marked |
We should fix |
Actually, I'm pretty sure that it can't be |
|
@atilaneves is correct. Explicitly marking unittests as @safe or @System makes it clear where things are good and where more engineering is needed. |
|
Looking at RefCounted, the problem is that we conflate the constructor of the ref counted struct with the construction of the actual ref-counted payload. You can't blindly trust the construction of the ref counted struct unless you know the constructor of the payload is also What we need for your idea is a 2-stage construction, which is unwieldy. I had envisioned marking the appropriate construction pieces of RefCounted as |
@atilaneves how did you check that?
grep -r "^unittest" -r stdstill yields a lot.