Skip to content

Instantly share code, notes, and snippets.

@aliaspooryorik
Created January 11, 2018 15:03
Show Gist options
  • Save aliaspooryorik/ec5d441607d0c5312a3f6bc5af5a4c5e to your computer and use it in GitHub Desktop.
Save aliaspooryorik/ec5d441607d0c5312a3f6bc5af5a4c5e to your computer and use it in GitHub Desktop.
callStackGet - stolen from Ryan Guill
private function expect (required any testValue, required any targetValue, string message = "") {
arguments.message &= "<br /> expected [" & encodeForHtml(toString(arguments.targetValue)) & "] <br /> but received [" & encodeForHtml(toString(testValue)) & "] <br />";
if (arguments.testValue != arguments.targetValue) {
var cs = callStackGet();
var lineRef = "";
for (var line in cs) {
if (structKeyExists(line, "Function") && line["Function"] == getFunctionCalledName()) {
continue;
}
if (structKeyExists(line, "Template")) {
lineRef = lineRef & "<br />" & line["Template"];
}
if (structKeyExists(line, "LineNumber")) {
lineRef = lineRef & ":" & line["LineNumber"];
}
break;
}
assert(false, '<pre>' & arguments.message & trim(lineRef) & '</pre>');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment