Skip to content

Commit

Permalink
Some extra unit tests for default choices and variable divert targets…
Browse files Browse the repository at this point in the history
… that get given parameters
  • Loading branch information
joethephish committed Jun 6, 2017
1 parent 7018559 commit ded0c8c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2850,6 +2850,64 @@ public void TestTunnelOnwardsDivertAfterWithArg ()
Assert.AreEqual ("8\n", story.ContinueMaximally ());
}

[Test ()]
public void TestVariousDefaultChoices ()
{
var storyStr =
@"
* -> hello
Unreachable
- (hello) 1
* ->
- - 2
- 3
* [] ->
- 4
-> END
";

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

[Test ()]
public void TestTunnelOnwardsWithParamDefaultChoice ()
{
var storyStr =
@"
-> tunnel ->
== tunnel ==
* ->-> elsewhere (8)
== elsewhere (x) ==
{x}
-> END
";

var story = CompileString (storyStr);
Assert.AreEqual ("8\n", story.ContinueMaximally ());
}

[Test ()]
public void TestDivertTargetsWithParameters ()
{
var storyStr =
@"
VAR x = ->place
->x (5)
== place (a) ==
{a}
-> DONE
";

var story = CompileString (storyStr);

Assert.AreEqual ("5\n", story.ContinueMaximally ());
}

// Helper compile function
protected Story CompileString(string str, bool countAllVisits = false, bool testingErrors = false)
{
Expand Down

0 comments on commit ded0c8c

Please sign in to comment.