VerseGrammarValidation: canonical names by character class, not Regex

The Regex form could not be mutated on the verification path (the mutant runner collapsed its backslashes), and a
character loop with named length constants states the same rule without the dependency. Adds refusals for a capital
inside a name, a hyphen, and a direct empty-name case. Builds (not yet run when committed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-10 10:21:11 +02:00
commit b772b13d43
2 changed files with 27 additions and 7 deletions

View file

@ -96,6 +96,8 @@ public sealed class VerseGrammarTests : IDisposable
new object[] { "name with a space", (Action<VerseVerb>)(v => v.Name = "bad name"), "VerseVerb.Name", "bad name" },
new object[] { "name starting with a digit", (Action<VerseVerb>)(v => v.Name = "9haul"), "VerseVerb.Name", "9haul" },
new object[] { "upper-case name", (Action<VerseVerb>)(v => v.Name = "Haul"), "VerseVerb.Name", "Haul" },
new object[] { "upper-case letter inside a name", (Action<VerseVerb>)(v => v.Name = "haUl"), "VerseVerb.Name", "haUl" },
new object[] { "name with a hyphen", (Action<VerseVerb>)(v => v.Name = "ha-ul"), "VerseVerb.Name", "ha-ul" },
new object[] { "name one past 48 characters", (Action<VerseVerb>)(v => v.Name = "a" + new string('b', 48)), "VerseVerb.Name", new string('b', 48) },
new object[] { "render path zero", (Action<VerseVerb>)(v => v.RenderPath = 0), "RenderPath", null },
new object[] { "undefined render path", (Action<VerseVerb>)(v => v.RenderPath = (VerseRenderPath)3), "RenderPath", null },
@ -127,6 +129,15 @@ public sealed class VerseGrammarTests : IDisposable
}
}
// The rule itself, without a store: an empty name is a refusal, not an index error.
[Fact]
public void Validate_refuses_an_empty_name_as_a_refusal()
{
var verb = Good("alpha");
verb.Name = "";
Assert.Contains("VerseVerb.Name", Assert.Throws<InvalidOperationException>(() => VerseGrammarValidation.Validate(verb)).Message);
}
[Fact]
public void The_longest_canonical_names_are_accepted()
{