Ejemplo n.º 1
0
        public void SkipWhitespaces_NewLines_ShouldStopOnNewLine(string code, int pos)
        {
            var lexer = new VBScriptLexer(code);

            lexer.SkipWhitespaces();
            Assert.Equal(pos, lexer.Index);
        }
Ejemplo n.º 2
0
        public void NextToken_ValidExtendedIdentifier_ReturnsIdentifier(string code)
        {
            var lexer = new VBScriptLexer(code);
            var token = Assert.IsType <ExtendedIdentifierToken>(lexer.NextToken());

            Assert.Equal(code.Trim(), token.Name);
        }
Ejemplo n.º 3
0
        public void NextToken_ValidDateLiteral_ReturnsDate(string code, string dt)
        {
            var lexer = new VBScriptLexer(code);
            var token = Assert.IsType <DateLiteralToken>(lexer.NextToken());

            Assert.Equal(DateTime.Parse(dt), token.Value);
        }
Ejemplo n.º 4
0
        public void NextToken_NewLines_ShouldReturnLineTerminationToken(string code)
        {
            var lexer = new VBScriptLexer(code);

            Assert.IsAssignableFrom <LineTerminationToken>(lexer.NextToken());
            Assert.IsType <EofToken>(lexer.NextToken());
        }
Ejemplo n.º 5
0
        public void NextToken_ValidComment_ShouldReturnCommentToken(string code, string expected)
        {
            var lexer = new VBScriptLexer(code);
            var token = Assert.IsType <CommentToken>(lexer.NextToken());

            Assert.Equal(expected, token !.Comment);
        }
Ejemplo n.º 6
0
        public void SkipWhitespaces_Whitespaces_ShouldStopAtEnd(string code)
        {
            var lexer = new VBScriptLexer(code);

            lexer.SkipWhitespaces();
            Assert.Equal(code.Length, lexer.Index);
        }
Ejemplo n.º 7
0
        public void NextToken_ValidDecIntLiteral_ShouldReturnIntLiteralToken(
            string code, int expected)
        {
            var lexer = new VBScriptLexer(code);
            var token = Assert.IsType <DecIntegerLiteralToken>(lexer.NextToken());

            Assert.Equal(expected, token !.Value);
        }
Ejemplo n.º 8
0
        public void NextToken_ValidTwoCharPunctuation_ShourdReturnValidPunctuationToken(
            string code, Punctuation type)
        {
            var lexer = new VBScriptLexer(code);
            var token = Assert.IsType <PunctuationToken>(lexer.NextToken());

            Assert.Equal(type, token.Type);
        }
Ejemplo n.º 9
0
        public void NextToken_ValidFloatLiteral_ShouldReturnFloatLiteralToken(
            string code, double expected)
        {
            var lexer = new VBScriptLexer(code);
            var token = Assert.IsType <FloatLiteralToken>(lexer.NextToken());

            Assert.Equal(expected, token !.Value, 9);
        }
Ejemplo n.º 10
0
        public void NextToken_InvalidOctIntLiteral_ThrowsException(string code)
        {
            var lexer = new VBScriptLexer(code);
            var ex    = Assert.Throws <VBSyntaxErrorException>(() => lexer.NextToken());

            Assert.True(VBSyntaxErrorCode.ExpectedEndOfStatement == ex.Code ||
                        VBSyntaxErrorCode.SyntaxError == ex.Code);
        }
Ejemplo n.º 11
0
        public void NextToken_InvalidStringLiteral_ThrowsUnterminatedStringConstant(
            string code, int line, int pos)
        {
            var lexer = new VBScriptLexer(code);
            var ex    = Assert.Throws <VBSyntaxErrorException>(() => lexer.NextToken());

            Assert.Equal(VBSyntaxErrorCode.UnterminatedStringConstant, ex.Code);
            Assert.Equal(line, ex.Line);
            Assert.Equal(pos, ex.Position);
        }
Ejemplo n.º 12
0
        public void NextToken_ValidStringLiteral_ShouldReturnStringLiteralToken(
            string code, string expected, int start, int end)
        {
            var lexer = new VBScriptLexer(code);
            var token = Assert.IsType <StringLiteralToken>(lexer.NextToken());

            Assert.Equal(expected, token !.Value);
            Assert.Equal(start, token.Start);
            Assert.Equal(end, token.End);
        }
Ejemplo n.º 13
0
        public void NextToken_InvalidDecIntLiteral_ThrowsException(
            string code)
        {
            var lexer = new VBScriptLexer(code);
            var ex    = Assert.Throws <VBSyntaxErrorException>(() => lexer.NextToken());

            Assert.Equal(VBSyntaxErrorCode.ExpectedEndOfStatement, ex.Code);
            //Assert.Equal(line, ex.Line);
            //Assert.Equal(pos, ex.Position);
        }
Ejemplo n.º 14
0
        public void NextToken_Whitespaces_ShouldReturnEofToken(string code)
        {
            var lexer = new VBScriptLexer(code);

            Assert.IsType <EofToken>(lexer.NextToken());
        }
Ejemplo n.º 15
0
        public void NextToken_NothingLiteral(string code)
        {
            var lexer = new VBScriptLexer(code);

            Assert.IsType <NothingLiteralToken>(lexer.NextToken());
        }