Skip to content

Commit

Permalink
Updated the tagging test.
Browse files Browse the repository at this point in the history
There a chance for shared textual lines but with different line tags (one manually added, one curated) to be skipped being checked depending on their ordering in the string table.
Modified the test Yarn for this test so that this happens, and then also fixed the test by running through the known tagged lines firs before the generated lines.
Fixes #363
  • Loading branch information
McJones committed May 19, 2023
1 parent ca6d8d7 commit 2f098b7
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions YarnSpinner.Tests/ProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ A line with a conditional and no line tag. <<if false>>
// single symbol tests
🧑🏾‍❤️‍💋‍🧑🏻
🧑🏾‍❤️‍💋‍🧑🏻 // with comment
🧑🏾‍❤️‍💋‍🧑🏻#line:abc122
🧑🏾‍❤️‍💋‍🧑🏻 // with comment
🧑🏾‍❤️‍💋‍🧑🏻 #line:abc124 // with a comment
// after emoji tests
Expand Down Expand Up @@ -186,7 +186,7 @@ text before emoji 🧑🏾‍❤️‍💋‍🧑🏻 // with a comment
lineTagAfterComment.IsMatch(line).Should().BeFalse($"'{line}' should not contain a tag after a comment");
}

var expectedResults = new (string tag, string line)[]
var expectedResults = new List<(string tag, string line)>
{
("line:expected_abc123", "A single line, with a line tag."),
("line:expected_def456", "An option, with a line tag."),
Expand Down Expand Up @@ -238,8 +238,26 @@ text before emoji 🧑🏾‍❤️‍💋‍🧑🏻 // with a comment
("line:abc131", "🧑🏾‍❤️‍💋‍🧑🏻🧑🏾‍❤️‍💋‍🧑🏻"),
("line:abc132", "🧑🏾‍❤️‍💋‍🧑🏻🧑🏾‍❤️‍💋‍🧑🏻"),
};

lineTagRegexMatches.Should().Be(expectedResults.Length);
expectedResults.Sort((a,b) => {
if (a.tag == null)
{
if (b.tag == null)
{
return 0;
}
else
{
return 1;
}
}
else if (b.tag == null)
{
return -1;
}
return a.tag.CompareTo(b.tag);
});

lineTagRegexMatches.Should().Be(expectedResults.Count);

// used to keep track of all line ids we have already seen
// this is because we need to make sure we see every line in the string table
Expand Down Expand Up @@ -273,6 +291,7 @@ text before emoji 🧑🏾‍❤️‍💋‍🧑🏻 // with a comment
}

// we now should have seen every line ID
compilationResult.StringTable.Count.Should().Be(expectedResults.Count);
compilationResult.StringTable.Count.Should().Be(visitedIDs.Count);
}

Expand Down

0 comments on commit 2f098b7

Please sign in to comment.