fix assert error insertion on windows

This commit is contained in:
2022-06-20 00:55:50 +00:00
parent 1353b47b6c
commit b2a5d36075
3 changed files with 7 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;

View File

@@ -50,6 +50,9 @@
(method &override :Void update [:Float elapsed]
(super.update elapsed)
(when FlxG.keys.justPressed.ESCAPE
(Sys.exit 0))
// Press ENTER to type a command to run
(when (and !textInput FlxG.keys.justPressed.ENTER)
(typeCommand))