Пример #1
0
        public void HandleEscapedSlashBeforeQuote()
        {
            var codeLines = new[]
            {
                "var k = ' \\\\' '; // Not a comment ",
            };
            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
Пример #2
0
        public void HandleLineeEndsWithQuote()
        {
            var codeLines = new[]
            {
                $"var i = '",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
Пример #3
0
        public void HandleUnclosedLiteralString2()
        {
            var codeLines = new[]
            {
                "var s = ' // Not a comment' + ' // Not a comment", // " // Not a comment" + " // Not a comment
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
        public void HandleLineEndsWithSingleSlash()
        {
            var codeLines = new[]
            {
                $"var i = 2; /",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
        public void UnclosedTemplateLiteral_TickOnly()
        {
            var codeLines = new[]
            {
                "var s = `",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
        public void HandleUnclosedLiteralStringAfterAnother()
        {
            var codeLines = new[]
            {
                " var s = \" // Not a comment\" + ' // Not a comment",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
        public void UnclosedTemplateLiteral()
        {
            var codeLines = new[]
            {
                "var s = `First line",
                "// Not a comment",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
Пример #8
0
        public void NoComment_InsideStringLiteral_Multiline()
        {
            var codeLines = new[]
            {
                "var s = 'starting line\\",
                "// Not a comment \\",
                $"end line';",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
        public void IgnoreCommentLikeInTemplateLiterals()
        {
            var codeLines = new[]
            {
                "var s = `First line",
                "// Not a comment ",
                "end line`",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
Пример #10
0
        public void NoComment_InsideStandardStringLiteral_SingleQuote()
        {
            var codeLines = new[]
            {
                "double d = 234.3",
                "var s = '// not a comment';", // var s = '// not a comment'
                "var i = 2343;"
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
Пример #11
0
        public void HandleUnclosedStringAfterMultilineString()
        {
            var codeLines = new[]
            {
                "var s = 'starting line\\",
                "// middle line \\",
                "end line' + ' // Not a comment",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Empty(results);
        }
        public void ConcatToDoubleQuote()
        {
            var codeLines = new[]
            {
                "var s = `First line",
                "end line`" + "\"// Not a comment\"" + FullComment,
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(COMMENT_CONTENT, results[0].Content);
        }
        public void CommentAfterTemplateLiteral_FirstLineTickOnly()
        {
            var codeLines = new[]
            {
                "var s = `",
                "// Not a comment`" + FullComment,
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(COMMENT_CONTENT, results[0].Content);
        }
        public void CommentAfterMultiline_LongLine()
        {
            var codeLines = new[]
            {
                "var s = `First line",
                "long last line for testing`" + FullComment,
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(COMMENT_CONTENT, results[0].Content);
        }
        public void HandleEscapedSlashInTickString()
        {
            var codeLines = new[]
            {
                "var s = `First line",
                "// Not a comment \\\\`" + FullComment,
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(COMMENT_CONTENT, results[0].Content);
        }
        public void Comment_AfterTickString()
        {
            var codeLines = new[]
            {
                "var s = \"string\"",
                "var k = `// Not a comment`" + FullComment,
                "var i = 23;",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(COMMENT_CONTENT, results[0].Content);
        }
Пример #17
0
        public void Comment_AfterStandardStringLiteral_SingleQuote()
        {
            var codeLines = new[]
            {
                "var s = \"string\"",
                // var k = '// todo Not a comment'; //todo This is a comment
                "var k = '// {TODO_TOKEN} Not a comment';" + FullComment,
                "var i = 23;",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(COMMENT_CONTENT, results[0].Content);
        }
Пример #18
0
        public void HandleEscapedQuote_SingleQuote()
        {
            var codeLines = new[]
            {
                "var s = \"string\"",
                // var k = ' \' '; //todo This is a comment
                "var k = ' \\' ';" + FullComment,
                "var i = 23;",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(COMMENT_CONTENT, results[0].Content);
        }
        public void Comment_AfterConcat_Mix()
        {
            var codeLines = new[]
            {
                "var s = \"string\"",
                // var k = '// not a comment' + "//Not a comment"; //todo This is a comment
                "var k = '// Not a \"\" comment' + \" //Not a comment \";" + FullComment,
                "var i = 23;",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(COMMENT_CONTENT, results[0].Content);
        }
Пример #20
0
        public void Comment_AfterStringLiteral_Multiline2()
        {
            var codeLines = new[]
            {
                "var s = 'starting line\\",
                "middle line\\",
                "end';" + FullComment,
                "var s = \"hello\""
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(3, results[0].Line);
            Assert.Equal(COMMENT_CONTENT, results[0].Content);
        }
Пример #21
0
        public void HandleMultilineStringEndsWithDoubleSlash()
        {
            var comment     = $"This is a comment";
            var fullComment = $"// {TODO_TOKEN} {comment}";

            var codeLines = new[]
            {
                "var s = 'starting line\\\\",
                fullComment,
                $"end line' // Some comment",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
        }
Пример #22
0
        public void Comment_AfterConcat_SingleQuote()
        {
            var comment     = $"This \"is\" comment";
            var fullComment = $"// {TODO_TOKEN} {comment}";
            var codeLines   = new[]
            {
                "var s = \"string\"",
                // var k = '// not a \' comment' + '//Not a comment'; //todo This is a comment
                "var k = '// Not a \\' comment' + ' //Not a comment ';" + fullComment,
                "var i = 23;",
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Single(results);
            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(2, results[0].Line);
            Assert.Equal(comment, results[0].Content);
        }
        public void Comment_LineBeginning_Classified()
        {
            var codeLines = new[]
            {
                "var s = \"string\"",
                FullComment,
                "var i = 23;",
                "var c = 234;" + FullComment
            };

            var results = JSExtractor.Extract(codeLines);

            Assert.Equal(2, results.Count);

            Assert.Equal(TODO_TOKEN, results[0].Classification.Token);
            Assert.Equal(TODO_TOKEN, results[1].Classification.Token);

            Assert.Equal(2, results[0].Line);
            Assert.Equal(4, results[1].Line);

            Assert.Equal(COMMENT_CONTENT, results[0].Content);
            Assert.Equal(COMMENT_CONTENT, results[1].Content);
        }