You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
modulecalypso.util;
pragma(inline, true)
voidexpect(string file=__FILE__, int line=__LINE__, string fun=__FUNCTION__, T)(autoref T a){
if(a) return;
writeln(file, ":", line,"", fun, " expect FAIL");
// increment counter of expect failures// can add more logic here if needed, eg assert on 1st expect failure if needed, etc
}
ldc uses CHECK in places where expect would be hard to use, eg to check the IR eg
// https://github.com/ldc-developers/ldc/blob/3b63effd3fa3200d4137260ce68541a55dcde21c/tests/debuginfo/gline_tables_only2.d#L10intmain() {
// CHECK: ret i32 0, !dbgreturn0;
}
however in the test cases of calypso, what's advantage over more straightforward (and easier to read/write) library call such as expect?
The text was updated successfully, but these errors were encountered:
timotheecour
changed the title
for tests why not use library-based expect instead of comment-based CHECK hack?
for tests why not use library-based expect instead of comment-based CHECK hack?
Jan 22, 2018
But you're right, CHECK directives are better suited for cases where we can't use a solution like assert or your expect, e.g: checking the IR, compiler errors/warnings, etc.
assert/expect would make debugging possible without adding breakpoints, and also benefits from D syntax and code highlighting.
I'll stop using CHECK and replace every CHECK by expect at some point. (to make the IR easier to read, it'd be better not to inline expect though)
to make the IR easier to read, it'd be better not to inline expect though
if keeping IR clean is a concern, maybe also optionally making expect nothrow to avoid adding exception handling boilerplate, eg:
version(calypso_expect_simple){
nothrowpragma(inline, true) // needed to apply the body (which does nothing) inline and avoid affecting the IRvoidexpect(string file=__FILE__, int line=__LINE__, string fun=__FUNCTION__, T)(autoref T a){
// do nothing
}
} else {
pragma(inline, true)
voidexpect(string file=__FILE__, int line=__LINE__, string fun=__FUNCTION__, T)(autoref T a){
}
}
#62 (comment)
what's a
lit test
? is that things like// CHECK: xyz = 3, 9.81
intests/calypso/constexpr_ctor.d
?on that note, why use comment-based
CHECK
instead of something more straightforward such as library callexpect
?tests/calypso/constexpr_ctor.d:
instead how about:
eg implementation of expect
ldc uses CHECK in places where expect would be hard to use, eg to check the IR eg
however in the test cases of calypso, what's advantage over more straightforward (and easier to read/write) library call such as expect?
The text was updated successfully, but these errors were encountered: