Exemplo n.º 1
0
        public void NoCommentsWithinLiteralStrings()
        {
            // No comments within literal strings
            string src = " \"// /* */\" ";

            int[] exp = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
Exemplo n.º 2
0
        public void IgnoreLiteralStringsWithinComments()
        {
            // Ignore literal strings within comments
            string src = " /* \" */ // \" \n ";

            int[] exp = { 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
Exemplo n.º 3
0
        public void LineCommentEndsAsEoS()
        {
            // Line comment ends at EOS
            string src = " // ";

            int[] exp = { 0, 1, 1, 1, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
Exemplo n.º 4
0
        public void LineCommentEndsAtUnescapedNewLine()
        {
            // Line comment ends at unescaped new line (exclusive)
            string src = " // \\\n \n ";

            int[] exp = { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
Exemplo n.º 5
0
        public void NoSubstringMatchingWithinBlockCommentMarkers()
        {
            // No substring matching within block comment markers
            string src = "/*/*/ /**/*/";

            int[] exp = { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
Exemplo n.º 6
0
        public void SimpleBlockComment()
        {
            // Simple block comment
            string src = " /**/ ";

            int[] exp = { 0, 1, 1, 1, 1, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
Exemplo n.º 7
0
 public StripComments(Src src, InLiteral.EFlags literal_flags = InLiteral.EFlags.Escaped | InLiteral.EFlags.SingleLineStrings, InComment.Patterns?comment_patterns = null)
     : base(src)
 {
     m_com = new InComment(comment_patterns ?? new InComment.Patterns(), literal_flags);
 }