On 4/27/15 10:30 AM, Ivan Kazmenko wrote:
On Monday, 27 April 2015 at 11:30:04 UTC, Steven Schveighoffer wrote:
The problem is as follows:

1. Unit tests for some library are written for that library. They are
written to run tests during unit tests of that library only (possibly
with certain requirements of environment, including build lines, or
expectations of system resource availability).

By the way, a unittest-related issue still stands in DMD 2.067.1 for
RedBlackTree:
https://issues.dlang.org/show_bug.cgi?id=12246

A similar matter got resolved quickly for BinaryHeap:
https://issues.dlang.org/show_bug.cgi?id=12245

BinaryHeap's case was handled by putting the container's unittests into
"debug(BinaryHeap)".

RedBlackTree's case is controlled via "debug(RBDoChecks)" (formerly
"version(RBDoChecks)").  The difference is the presence of a
"version(unittest) debug = RBDoChecks;" line.  This looks inconsistent.

For RedBlackTree, compile the following with or without -unittest option
and run for a visible difference in speed (runs momentarily or for a few
seconds):
-----
import std.container;
void main() {
     auto t = redBlackTree!int;
     foreach (i; 0..3000) t.insert(i);
}
-----

Ivan Kazmenko.

It's an anecdotal fix. I remember arguing over the change to debug, that was done for purity (pure functions need debug mode to print out something, which rbdochecks will do if there is an issue), but I can't find the conversation.

But someone else will complain that when they try to debug their code, adding -debug to the command line debugs RBTree's algorithm (similarly to how they complained BinaryHeap was doing this). This really should only EVER run during phobos unit tests.

I don't know how to fix this properly without something like I outlined above, or without doing some global version(PhobosUnitTests) hack.

In fact, I don't agree with the BinaryHeap change. At this point, phobos unit tests are NOT testing the binary heap structure. Sure that makes user code run faster, but at the cost of never testing it even when it should be tested.

-Steve

Reply via email to