Exemple #1
0
        public void Wrong_Number_Literal()
        {
            string code     = " 123.45.45 ";
            var    iterator = new SourceCodeIterator(code);

            iterator.MoveToContent();
            var state = new NumberLexerState();

            Assert.Throws <SyntaxErrorException>(() => state.ReadNextLexem(iterator));

            code     = " 12jk";
            iterator = new SourceCodeIterator(code);
            iterator.MoveToContent();
            Assert.Throws <SyntaxErrorException>(() => state.ReadNextLexem(iterator));
        }
Exemple #2
0
        public void NumberLiteral_State_Works_Fine()
        {
            string code     = " 123.45 ";
            var    iterator = new SourceCodeIterator(code);

            iterator.MoveToContent();
            var state = new NumberLexerState();
            var lex   = state.ReadNextLexem(iterator);

            Assert.True(lex.Type == LexemType.NumberLiteral);
            Assert.Equal("123.45", lex.Content);
        }