Crash on failing self test; add some mitigation for locale variant strings (WIP)
This commit is contained in:
parent
ba177dd0cd
commit
cb90b4c57c
5 changed files with 15 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using AspectedRouting.IO.itinero1;
|
||||
|
@ -280,9 +281,9 @@ namespace AspectedRouting.IO.LuaSkeleton
|
|||
case IExpression e:
|
||||
return ToLua(e);
|
||||
case int i:
|
||||
return "" + i;
|
||||
return i.ToString(CultureInfo.InvariantCulture);
|
||||
case double d:
|
||||
return "" + d;
|
||||
return d.ToString(CultureInfo.InvariantCulture);
|
||||
case string s:
|
||||
return '"' + s.Replace("\"", "\\\"") + '"';
|
||||
case null:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
@ -12,14 +13,14 @@ namespace AspectedRouting.IO.itinero1
|
|||
var contents = tags.Select(kv =>
|
||||
{
|
||||
var (key, value) = kv;
|
||||
var left = "[\"" + key + "\"]";
|
||||
var left = "[\"" + key .ToString(CultureInfo.InvariantCulture)+ "\"]";
|
||||
|
||||
if (Regex.IsMatch(key, "^[a-zA-Z][_a-zA-Z-9]*$"))
|
||||
{
|
||||
left = key;
|
||||
}
|
||||
|
||||
return $"{left} = \"{value}\"";
|
||||
return $"{left.ToString(CultureInfo.InvariantCulture)} = \"{value.ToString(CultureInfo.InvariantCulture)}\"";
|
||||
});
|
||||
return "{" + string.Join(", ", contents) + "}";
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using AspectedRouting.Tests;
|
||||
|
||||
|
@ -94,10 +95,10 @@ namespace AspectedRouting.IO.itinero1
|
|||
tags.Remove("#" + paramName);
|
||||
}
|
||||
|
||||
var expectedPriority = "" + expected.Priority;
|
||||
var expectedPriority = expected.Priority.ToString(CultureInfo.InvariantCulture);
|
||||
if (invertPriority)
|
||||
{
|
||||
expectedPriority = $"inv({expectedPriority})";
|
||||
expectedPriority = $"inv({expectedPriority.ToString(CultureInfo.InvariantCulture)})";
|
||||
}
|
||||
|
||||
// Generates something like:
|
||||
|
@ -106,7 +107,7 @@ namespace AspectedRouting.IO.itinero1
|
|||
$"unit_test_profile(behaviour_{testSuite.Profile.Name.AsLuaIdentifier()}_{testSuite.BehaviourName.AsLuaIdentifier()}, " +
|
||||
$"\"{testSuite.BehaviourName}\", " +
|
||||
$"{index}, " +
|
||||
$"{{access = \"{D(expected.Access)}\", speed = {expected.Speed}, oneway = \"{D(expected.Oneway)}\", priority = {expectedPriority} }}, " +
|
||||
$"{{access = \"{D(expected.Access)}\", speed = {expected.Speed.ToString(CultureInfo.InvariantCulture)}, oneway = \"{D(expected.Oneway)}\", priority = {expectedPriority} }}, " +
|
||||
tags.ToLuaTable() +
|
||||
")";
|
||||
}
|
||||
|
@ -151,8 +152,7 @@ namespace AspectedRouting.IO.itinero1
|
|||
|
||||
_skeleton.AddDep("unitTest");
|
||||
_skeleton.AddDep("debug_table");
|
||||
return
|
||||
$"unit_test({functionToApplyName.AsLuaIdentifier()}, \"{functionToApplyName}\", {index}, \"{expected}\", {parameters.ToLuaTable()}, {tags.ToLuaTable()})";
|
||||
return $"unit_test({functionToApplyName.AsLuaIdentifier()}, \"{functionToApplyName}\", {index.ToString(CultureInfo.InvariantCulture)}, \"{expected.ToString(CultureInfo.InvariantCulture)}\", {parameters.ToLuaTable()}, {tags.ToLuaTable()})";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -151,6 +151,8 @@ namespace AspectedRouting.IO.itinero1
|
|||
"test_all()",
|
||||
"if (not failed_tests and not failed_profile_tests) then",
|
||||
" print(\"Tests OK\")",
|
||||
"else",
|
||||
" error(\"Some tests failed\")",
|
||||
"end"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ namespace AspectedRouting.IO.itinero2
|
|||
"test_all()",
|
||||
"if (not failed_tests and not failed_profile_tests and print ~= nil) then",
|
||||
$" print(\"Tests OK ({_profile.Name}.{_behaviourName})\")",
|
||||
"else",
|
||||
" error(\"Some tests failed\")",
|
||||
"end"
|
||||
}.Lined();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue