Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 25
0
        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);
        }
Exemplo n.º 26
0
        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);
        }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 29
0
        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);
        }
Exemplo n.º 30
0
        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);
        }