### Question:
Comparator implements BiPredicate<List<String>, List<String>> { @Override public boolean test(List<String> strings1, List<String> strings2) { if (strings1.equals(strings2)) return false; final Lexer lexer; if (checkComments) { lexer = new Lexer().commentSensitive(); } else { lexer = new Lexer(); } LexicalElement[] elements1 = lexer.apply(strings1); LexicalElement[] elements2 = lexer.apply(strings2); if (elements1.length != elements2.length) { return true; } for (int i = 0; i < elements1.length; i++) { if (!elements1[i].equals(elements2[i])) { return true; } } return false; }  Comparator commentSensitive(); @Override boolean test(List<String> strings1, List<String> strings2);  }### Answer:
@Test @DisplayName("Two empty source code equals") void testEmpty(){ final var s1 = ""; final var s2 = ""; Assertions.assertFalse( new Comparator().test(sourceList(s1), sourceList(s2))); }
@Test @DisplayName("Changed code does not equals") void testSimple(){ final var s1 = "int i"; final var s2 = "float i"; Assertions.assertTrue( new Comparator().test(sourceList(s1), sourceList(s2))); }
@Test @DisplayName("Reformatted code equals") void testReformatted(){ final var s1 = " void test(){\n" + " final var s1 = \"\";\n" + " final var s2 = \"\";\n" + " Assertions.assertTrue( new Comparator().test(Arrays.asList(s1.split(\"\\n\",-1)),Arrays.asList(s2.split(\"\\n\",-1))));\n" + " }"; final var s2 = " void test(){\n" + " final var s1 = \"\";\n" + " final var \n" + " s2 = \"\";\n" + " Assertions.assertTrue( new Comparator().test(Arrays.asList(s1.split(\"\\n\",-1)),Arrays.asList(s2.split(\"\\n\",-1))));\n" + " }"; Assertions.assertFalse( new Comparator().test(sourceList(s1), sourceList(s2))); }
@Test @DisplayName("Code comparison does not care the radix of numbers") void testNumberDifference(){ final var s1 = " @Test\n" + " void method(){\n" + " var x = 13;\n" + " }"; final var s2 = " @Test\n" + " void method(){\n" + " var x = 0xd;\n" + " }"; Assertions.assertFalse( new Comparator().test(sourceList(s1), sourceList(s2))); }
@Test @DisplayName("Code comparison does not care about comments by default.") void testCommentDifference(){ final var s1 = " @Test\n" + " void method(){\n" + " }"; final var s2 = " @Test\n" + ""+ " void method(){\n" + " }"; Assertions.assertFalse( new Comparator().test(sourceList(s1), sourceList(s2))); }