Skip to content

Commit

Permalink
Merge pull request #2588 from qorelanguage/bugfix/1720_QUnit_location…
Browse files Browse the repository at this point in the history
…_fix

refs #1720 final (hopefully) 1720 fix; show the location first (alway…
  • Loading branch information
pvanek committed Jan 4, 2018
2 parents c30f242 + d22fab4 commit 80970a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/test/qlib/QUnit/exception.qtest
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public class ExceptionTest inherits Test {
));
string str = TestCase::getPos(ex);
#printf("str: %y\n", str);
assertRegex("test.*->.*MyTest1.*->.*MyTest2", str);
assertRegex("MyTest2.*<-.*MyTest1.*<-.*test", str);
}
}
26 changes: 12 additions & 14 deletions qlib/QUnit.qm
Original file line number Diff line number Diff line change
Expand Up @@ -463,17 +463,15 @@ public class QUnit::TestCase {
}
if (!ok)
continue;
string fn = callSite.file;
fn =~ s/<run-time-loaded: (.*)>/$1/;
# try to add function/method call name
if (*string f = stack[$# + 1].function)
fn = sprintf("%s() at %s", f, fn);
else
fn = "<start> " + fn;
l += fn;
string loc = callSite.file;
loc =~ s/<run-time-loaded: (.*)>/$1/;
int ln = callSite.line + callSite.offset;
if (ln > 0)
l += sprintf(":%d", ln);
loc += sprintf(":%d", ln);
# try to add function/method call name
if (*string f = stack[$# + 1].function)
loc = sprintf("%s [%s()]", loc, f);
l += loc;
}
}
return l;
Expand All @@ -485,7 +483,7 @@ public class QUnit::TestCase {
list<string> l = TestCase::getStackList(ex.callstack, !qunit);
if (!qunit)
unshift l, pos;
return (foldr $1 + " -> " + $2, l) ?? "<unknown>";
return (foldl $1 + " <- " + $2, l) ?? "<unknown>";
}

#! handles exceptions raised while running the TestCase
Expand Down Expand Up @@ -749,7 +747,7 @@ public class QUnit::TestReporter {
print("\n");
if (testcase.result != TEST_SUCCESS) {
string out = "";
printf("%s in %s\n", testcase.error, testcase.pos);
printf("%s at %s\n", testcase.error, testcase.pos);
ListIterator errorDescription(testcase.detail.split("\n"));
while (errorDescription.next()) {
out += sprintf("\t>> %s\n", errorDescription.getValue());
Expand Down Expand Up @@ -777,7 +775,7 @@ public class QUnit::TestReporter {
hash testcase;

testcase."^attributes^".name = it.getValue().testcase.getName();
string errmsg = sprintf("%s in %s:\n%s", it.getValue().error, it.getValue().pos, it.getValue().detail);
string errmsg = sprintf("%s at %s:\n%s", it.getValue().error, it.getValue().pos, it.getValue().detail);

int status = it.getValue().result;
testcase."^attributes^"."status" = RESULT_TYPE_DESCRIPTION{status}.desc;
Expand Down Expand Up @@ -2004,9 +2002,9 @@ fail("Unexpected code executed");
{
list<string> l = TestCase::getStackList(get_thread_call_stack());
if (l)
np = foldr $1 + " -> " + $2, l;
np = foldl $1 + " <- " + $2, l;
}
return np ? sprintf("in %s", np) : "<no name>";
return np ? sprintf("at %s", np) : "<no name>";
}
}

Expand Down

0 comments on commit 80970a9

Please sign in to comment.