Skip to content

Commit 6407e92

Browse files
committed
added some more culture specific tests around floats
1 parent 8f97971 commit 6407e92

File tree

4 files changed

+59
-4
lines changed

4 files changed

+59
-4
lines changed

Tests/TestCases/Commands.testplan

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ command: `show 1`
2222
command: `0`
2323
command: `2 {0}`
2424
command: `regular old command`
25+
command: `zorp 2.1`
2526

2627
stop

Tests/TestCases/Commands.yarn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,6 @@ title: Start
6666
// another weird but allowed situation
6767
<<set $replacement = "ular old co">>
6868
<<reg{$replacement}mmand>>
69+
70+
<<zorp {2.1}>>
6971
===

YarnSpinner.Tests/MarkupTests.cs

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,9 +1235,62 @@ public void TestMarkupMultiplePropertyParsing()
12351235
[InlineData("[p=-1,1 /]")]
12361236
public void TestMarkupPropertyParsingUsesInvariantNumberParsingFails(string input)
12371237
{
1238-
var lineParser = new LineParser();
1239-
var markup = lineParser.ParseStringWithDiagnostics(input, "en");
1240-
markup.diagnostics.Should().ContainSingle();
1238+
var targetCultures = new[] {
1239+
"en",
1240+
"zh-Hans",
1241+
"ru",
1242+
"es-US",
1243+
"es",
1244+
"sw",
1245+
"ar",
1246+
"pt-BR",
1247+
"de",
1248+
"fr",
1249+
"fr-FR",
1250+
"ja",
1251+
"pl",
1252+
"ko",
1253+
};
1254+
1255+
foreach (var culture in targetCultures)
1256+
{
1257+
System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo(culture);
1258+
var lineParser = new LineParser();
1259+
var markup = lineParser.ParseStringWithDiagnostics(input, culture);
1260+
markup.diagnostics.Should().ContainSingle();
1261+
}
1262+
}
1263+
1264+
[Theory]
1265+
[InlineData("[p=1.1 /]", 1.1)]
1266+
[InlineData("[p=-1.1 /]",-1.1)]
1267+
public void TestMarkupPropertyParsingUsesInvariantNumber(string input, float propertyValue)
1268+
{
1269+
var targetCultures = new[] {
1270+
"en",
1271+
"zh-Hans",
1272+
"ru",
1273+
"es-US",
1274+
"es",
1275+
"sw",
1276+
"ar",
1277+
"pt-BR",
1278+
"de",
1279+
"fr",
1280+
"fr-FR",
1281+
"ja",
1282+
"pl",
1283+
"ko",
1284+
};
1285+
1286+
foreach (var culture in targetCultures)
1287+
{
1288+
System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo(culture);
1289+
var lineParser = new LineParser();
1290+
var markup = lineParser.ParseStringWithDiagnostics(input, culture);
1291+
markup.diagnostics.Should().BeEmpty();
1292+
markup.markup.Attributes[0].Properties["p"].FloatValue.Should().Be(propertyValue);
1293+
}
12411294
}
12421295

12431296

YarnSpinner/VirtualMachine.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ internal void RunInstruction(Instruction i)
567567
// passes it to the client as a line
568568
string stringKey = i.RunLine.LineID;
569569

570-
571570
var expressionCount = i.RunLine.SubstitutionCount;
572571

573572
var strings = new string[expressionCount];

0 commit comments

Comments
 (0)