Exemple #1
0
        void ReturnsEof_WhenWhitespace()
        {
            //act
            var tokens = Lexer.AnalyseExpression(" ");

            //assert
            Assert.Single(tokens, t => t is EofToken);
        }
Exemple #2
0
        void AnalysesParensWithoutWhitespace(string expression)
        {
            //act
            var tokens = Lexer.AnalyseExpression(expression).ToList();

            //assert
            Assert.IsType <OrElseToken>(tokens[0]);
            Assert.IsType <LeftParenToken>(tokens[1]);
            Assert.IsType <AndAlsoToken>(tokens[2]);
            Assert.IsType <RightParenToken>(tokens[3]);
            Assert.IsType <OrElseToken>(tokens[4]);
        }
Exemple #3
0
        void ReturnsTokens_WhenMatchingEverything(string expression)
        {
            //act
            var tokens = Lexer.AnalyseExpression(expression).ToList();

            //assert
            Assert.IsType <AndAlsoToken>(tokens[0]);
            Assert.IsType <ArgsToken>(tokens[1]);
            Assert.IsType <LeftParenToken>(tokens[2]);
            Assert.IsType <NotToken>(tokens[3]);
            Assert.IsType <OrElseToken>(tokens[4]);
            Assert.IsType <RightParenToken>(tokens[5]);
            Assert.IsType <StringToken>(tokens[6]);
            Assert.IsType <SymbolToken>(tokens[7]);
            Assert.IsType <WithinToken>(tokens[8]);
            Assert.IsType <EofToken>(tokens[9]);
        }
Exemple #4
0
 void Throws_WhenNotMatchingEverything(string expression)
 {
     //assert
     Assert.Throws <WeavingException>(() => Lexer.AnalyseExpression(expression).ToList());
 }