-
-
Notifications
You must be signed in to change notification settings - Fork 655
Bug 5547 (assertPred) #263
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
Conversation
If you add a requires line to the description the autotester will be able to process this pull, currently it fails with link errors (naturally). |
Because of how the code was rewritten and bug 7546, a Phobos unit test will fail in 64-bit. A workaround is diff --git a/std/math.d b/std/math.d
index 9709dbb..6998853 100644
--- a/std/math.d
+++ b/std/math.d
@@ -2664,7 +2664,7 @@ unittest
assert(sgn(168.1234) == 1);
assert(sgn(-168.1234) == -1);
assert(sgn(0.0) == 0);
- assert(sgn(-0.0) == 0);
+ assert(sgn(-0.0f) == 0);
}
// Functions for NaN payloads |
fails auto tester |
@WalterBright that's because dlang/druntime#41 is required, and that pull request in turn requires #725, and the auto tester does not resolve the dependency. |
This commit makes expressions following some patterns in unittests emit some more useful information. See assertpred.c for explanation.
Let's see what the auto tester says now. |
Conflicts: src/posix.mak src/win32.mak
@alexrp : One does not simply expect a 5-month-old pull request still work automatically ☺. Fixed the merge break, waiting for the auto-testing to update the result. |
I have two problems with this:
|
On further reflection, I think that this is more properly the domain of a library template, such as testEqual(arg1, arg2); std.math.approxEqual can easily be extended to print its args on failure. |
|
Add @safe and pure to enforce family
This was introduced as part of GitHub pull request dlang#41, which was questionable (!) support code for dlang/dmd#263. However, the latter never materialized and __unittest_toString plus version(druntime_unittest) were just confusing oddities at this point.
This pull request implements bug 5547: Improve assert to give information on values given to it when it fails.
Important: The pull request dlang/druntime#41 should be merged before pulling this.
The improved assert is activated only if it is in the
unittest
block, and there is no message (the 2nd argument).Currently, it only recognizes expressions of the form:
where
<rel>
is one of the comparison operators (==
,>=
,!<>=
etc) or thein
,is
,!is
,&&
,||
operators, ande1
, etc can be any expressions of the form above. When the assert fails, an AssertError with message e.g.will be thrown.
Users who want the old behavior can provide an explicit message:
Internally, the assert will be transformed into
where the function
__unittest_toString
is effectivelystd.conv.to!string
, but it is put into druntime to ensure a certain degree of library-independence.requires: druntime git://github.com/kennytm/druntime.git bug5547_assertPred