public void SimpleOutcome_RunWithWords() { var src = @"a nifty rule displayAs tunafish rep conditions a is b dialogs :player 1 speaking line text multi line outcomes run a with b as 5 with c as 2 "; var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); var v = new ProgramToTree(); var result = v.Visit(program.ProgramContext.rule(0).outcomes().singleOutcome(0)); Assert.AreEqual("(run target=[a] args=[(arg name=[b] expr=[5]),(arg name=[c] expr=[2])])", result); }
public void ValidRuleWithNotInText() { var src = @"a nifty rule displayAs tunafish rep conditions yaday first is blahblah some more another line of fun = twice the pain dialogs :player1 I am not the villain multi line :player2 is this what you think a villain is not outcomes set a to b set a to b again "; // if thething is theotherthing: // muffin is true var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ValidRule() { var src = @"a nifty to set rule displayAs tunafish to set bell tolls rep conditions yaday.first is not blahblah some more another line of fun = twice the pain dialogs :player 1 speaking line text set to bell tolls multi line :player2 something meaningful outcomes set a to b set a to b again "; // if thething is theotherthing: // muffin is true var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ConditionalMath_AddRefRight() { var src = @"A Nifty Rule dispLaYaS conditions x is y + z dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ConditionalMath_AddLiteralLeftSeveral() { var src = @"A Nifty Rule dispLaYaS conditions x + 25 + z + 1205 is y dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ValidNoEndOfLine() { var src = @"A Nifty Rule dispLaYaS test conditions x is y dialogs :plr hello world outcomes set a to b"; var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void OutcomesCanPass() { var src = @"A Nifty Rule dispLaYaS conditions x is y dialogs :plr this is the 5th time I ate 3 apple pies outcomes pass "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void CommaInName() { var src = @"A Nifty Rule dispLaYaS conditions x is y dialogs :plr, the great hello world! I am here, to give you a lesson on rythm anatomy. outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ApostrophieInDialog() { var src = @"A Nifty Rule dispLaYaS conditions x is y dialogs :plr This isn't yours outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void StupidQuotes() { var src = @"A Nifty Rule dispLaYaS conditions x is ‘okay’ dialogs :plr This is okay outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ValidRefs() { var src = @"A Nifty Rule dispLaYaS monkey conditions player.name is enemy.archNemesis dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void WithInDialog() { var src = @"A Nifty Rule dispLaYaS conditions x is y dialogs :plr come with me to the market outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void SpeakerAsEpxression() { var src = @"A Nifty Rule dispLaYaS conditions x is y dialogs :{player.name} My name is a myster outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void AsInTheRuleName() { var src = @"Astronomy Assist dispLaYaS conditions player item5 is 'cool' dialogs :plr This is okay outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ValidNegation_NotLessWordSpaceFlipped() { var src = @"A Nifty Rule dispLaYaS monkey conditions x < not y dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void IsInVariable() { var src = @"A Nifty Rule dispLaYaS conditions plr flags isCool is true dialogs :plr This isn't yours outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void DotDotDot() { var src = @"A Nifty Rule dispLaYaS conditions x is y dialogs :plr hello world… outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void NumbersInConditions() { var src = @"A Nifty Rule dispLaYaS conditions player item5 is 'cool' dialogs :plr This is okay outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void IsInname() { var src = @"A Nifty Rule dispLaYaS conditions isto is x dialogs :plr I am as cool as sliced break outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ConditionGreatherThan0() { var src = @"A Nifty Rule dispLaYaS monkey conditions x > 0 dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); Assert.AreEqual(false, program.LexerErrors.AnyErrors); }
public void DialogCanHaveBoldMarkup() { var src = @"A Nifty Rule dispLaYaS monkey conditions x > 0 dialogs :plr hello <b> world </b> outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void CanDialogHaveEllipses() { var src = @"A Nifty Rule dispLaYaS monkey conditions x > 0 dialogs :plr ...hello... there... outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void DialogCanHaveColorHexCode() { var src = @"A Nifty Rule dispLaYaS monkey conditions x > 0 dialogs :plr hello <color=#ff000000> world </color> outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ValidLiteralStringEmpty() { var src = @"A Nifty Rule dispLaYaS monkey conditions x = '' dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void AsInDisplayAs() { var src = @"A Nifty Rule dispLaYaS Im as cool as you conditions x is y dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ValidLiteralBool() { var src = @"A Nifty Rule dispLaYaS monkey conditions x = true dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); // Assert.AreEqual(L.TRUE, program.Tokens[14].Type); Assert.AreEqual(false, program.LexerErrors.AnyErrors); Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ValidOutcomeModifierNegativeRef() { var src = @"A Nifty Rule dispLaYaS monkey conditions x < y dialogs :plr hello world outcomes set globalToast.count to -player.toastCount "; var program = new WordLangResults(src); var names = L.tokenNames; Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ValidOutcomeSetterBool() { var src = @"A Nifty Rule dispLaYaS monkey conditions x < y dialogs :plr hello world outcomes sEt Egg.NoG To fAlSE "; var program = new WordLangResults(src); var names = L.tokenNames; var expectedTokenTypes = new int[] { L.NAME, L.WHITESPACE, L.NAME, L.WHITESPACE, L.NAME, L.NEWLINE, L.DISPLAYAS, L.NEWLINE, L.NAME, L.NEWLINE, L.CONDITIONS, L.NEWLINE, L.NAME, L.WHITESPACE, L.LESSTHAN, L.WHITESPACE, L.NAME, L.NEWLINE, L.DIALOGS, L.NEWLINE, L.COLON, L.NAME, L.NEWLINE, L.NAME, L.WHITESPACE, L.NAME, L.NEWLINE, L.OUTCOMES, L.NEWLINE, L.SET, L.NAME, L.DOT, L.NAME, L.TO, L.FALSE }; for (var i = 0; i < Math.Min(expectedTokenTypes.Length, program.Tokens.Count); i++) { var expectedType = expectedTokenTypes[i]; var actualType = program.Tokens[i].Type; Assert.AreEqual(expectedType, actualType); } Assert.AreEqual(false, program.ParserErrors.AnyErrors); }
public void ConditionalMath_SubtractRight() { var src = @"A Nifty Rule dispLaYaS conditions x - 5 is y dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); var v = new ProgramToTree(); var firstExpr = program.ProgramContext.rule(0).conditions().booleanExpr(0).expression(0); var output = v.VisitExpression(firstExpr); Assert.AreEqual("(- x 5)", output); }
public void ConditionalMath_AddLotsOfSpaces() { var src = @"A Nifty Rule dispLaYaS conditions x + 25 + z + 1205 is y + 12 dialogs :plr hello world outcomes set a to b "; var program = new WordLangResults(src); Assert.AreEqual(false, program.ParserErrors.AnyErrors); var v = new ProgramToTree(); var firstExpr = program.ProgramContext.rule(0).conditions().booleanExpr(0).expression(0); var output = v.VisitExpression(firstExpr); Assert.AreEqual("(+ x (+ 25 (+ z 1205)))", output); }