void () { String s1 = """ class X {{ // This is some comment /* This is another comment*/ // Some garbage /** And now third comment*/ /** Some garbage*/ }}"""; assertEquals("Comment matching", 3, findMatchesCount(s1, "// 'Comment:[regex( .*(?:comment).* )]")); assertEquals("Comment matching, 2", 3, findMatchesCount(s1, "/* 'Comment:[regex( .*(?:comment).* )] */")); assertEquals("Java doc matching", 1, findMatchesCount(s1, "/** 'Comment:[regex( .*(?:comment).* )] */")); assertEquals("Comment matching with negate", 2, findMatchesCount(s1, "// 'not_comment:[!regex( .*(?:comment).* )]")); assertEquals("Multi line", 1, findMatchesCount(s1, "//'_comment:[regex( .*another.* )]")); assertEquals("Multi line negated", 4, findMatchesCount(s1, "//'_comment:[!regex( .*another.* )]")); String s4 = "class X {{ java.util.Arrays.asList(\"'test\", \"another test\", \"garbage\"); }}"; assertEquals("Literal content", 2, findMatchesCount(s4, "\"'test:[regex( .*test.* )]\"")); assertEquals("Literal content with escaping", 1, findMatchesCount(s4, "\"''test\"")); String s7 = "class X {{ String s = \"aaa\"; }}"; assertEquals("Simple literal content", 1, findMatchesCount(s7, "\"'test:[regex( aaa )]\"")); String s9 = "class X {{ java.util.Arrays.asList(\" aaa \",\" bbb \",\" ccc ccc aaa\"); }}"; assertEquals("Whole word literal content with alternations", 2, findMatchesCount(s9, "\"'test:[regexw( aaa|ccc )]\"")); assertEquals("Whole word literal content", 1, findMatchesCount(s9, "\"'test:[regexw( bbb )]\"")); String s12 = """ class X {{ assert agentInfo != null : "agentInfo is null"; assert addresses != null : "addresses is null"; }}"""; assertEquals("reference to substitution in comment", 2, findMatchesCount(s12, "assert '_exp != null : \"'_exp is null\";")); String s14 = """ class X {{ java.util.Arrays.asList( "(some text with special chars)", " some", "(some)" ); }}"""; assertEquals("meta char in literal", 2, findMatchesCount(s14, "\"('a:[regexw( some )])\"")); String s16 = """ /** * Created by IntelliJ IDEA. * User: cdr * Date: Nov 15, 2005 * Time: 4:23:29 PM * To change this template use File | Settings | File Templates. */ public class Y { }"""; String s17 = """ /** * Created by IntelliJ IDEA. * User: '_USER * Date: '_DATE * Time: '_TIME * To change this template use File | Settings | File Templates. */ class 'c { }"""; assertEquals("complete comment match", 1, findMatchesCount(s16, s17)); assertEquals("complete comment match case insensitive", 1, findMatchesCount(s16, s17.toLowerCase())); String s18 = """ public class A { private void f(int i) { int g=0; //sss } }"""; String s19 = """ class '_c { '_type '_f('_t '_p){ '_s; // sss } }"""; assertEquals("statement match with comment", 1, findMatchesCount(s18,s19)); String s20 = """ class X { /* H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ */ }"""; assertEquals("match comments ignoring accents and differences in whitespace", 1, findMatchesCount(s20, "/*he\ncomes*/")); }