fix assert error insertion on windows

This commit is contained in:
2022-06-20 00:55:50 +00:00
parent 321d1973ec
commit c71def4638
2 changed files with 4 additions and 3 deletions

View File

@@ -305,6 +305,7 @@ class Macros {
var b = wholeExp.expBuilder();
var expression = exps[0];
var failureError = KissError.fromExp(wholeExp, "").toString(AssertionFail);
var colonsInPrefix = if (Sys.systemName() == "Windows") 5 else 4;
var messageExp = if (exps.length > 1) {
exps[1];
} else {
@@ -320,7 +321,7 @@ class Macros {
letVal,
letVal,
b.callSymbol("throw", [
b.callSymbol("kiss.Prelude.runtimeInsertAssertionMessage", [messageExp, b.str(failureError)])
b.callSymbol("kiss.Prelude.runtimeInsertAssertionMessage", [messageExp, b.str(failureError), b.int(colonsInPrefix)])
])
])
]);

View File

@@ -723,9 +723,9 @@ class Prelude {
return str.substr(negIdx(startIdx), negIdx(endIdx));
}
public static function runtimeInsertAssertionMessage(message:String, error:String) {
public static function runtimeInsertAssertionMessage(message:String, error:String, colonsInPrefix:Int) {
var colonIdx = 0;
for (_ in 0...4) {
for (_ in 0...colonsInPrefix) {
colonIdx = error.indexOf(":", colonIdx) + 1;
}
colonIdx += 1;