Skip to content

Commit

Permalink
Check for blank choices
Browse files Browse the repository at this point in the history
  • Loading branch information
joethephish committed Jan 30, 2018
1 parent c10d2df commit 4718d07
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions inklecate/InkParser/InkParser_Choices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ protected Choice Choice()
if (emptyContent && diverts == null)
Warning ("Choice is completely empty. Interpretting as a default fallback choice. Add a divert arrow to remove this warning: * ->");

// * [] some text
else if (!startContent && hasWeaveStyleInlineBrackets && !optionOnlyContent)
Warning ("Blank choice - if you intended a default fallback choice, use the `* ->` syntax");

if (!innerContent) innerContent = new ContentList ();

var tags = Parse (Tags);
Expand Down
17 changes: 14 additions & 3 deletions tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2893,13 +2893,24 @@ public void TestVariousDefaultChoices ()
* ->
- - 2
- 3
* [] ->
- 4
-> END
";

var story = CompileString (storyStr);
Assert.AreEqual ("1\n2\n3\n4\n", story.ContinueMaximally ());
Assert.AreEqual ("1\n2\n3\n", story.ContinueMaximally ());
}


[Test ()]
public void TestVariousBlankChoiceWarning ()
{
var storyStr =
@"
* [] blank
";

CompileString (storyStr, testingErrors:true);
Assert.IsTrue (HadWarning ("Blank choice"));
}

[Test ()]
Expand Down

0 comments on commit 4718d07

Please sign in to comment.