s = Commandline.translateCommandline("\"\""); assertEquals("Doublequoted null arg", 1, s.length); assertEquals("Doublequoted null arg", "", s[0]); s = Commandline.translateCommandline("\'\' a"); assertEquals("Singlequoted null arg prepend", 2, s.length); assertEquals("Singlequoted null arg prepend", "", s[0]);
s = Commandline.translateCommandline("1 \'2\"3\' 4"); assertEquals("Case with single quotes around double quote", 3, s.length); assertEquals("Single quotes stripped, double quote included", "2\"3", s[1]); // \ doesn't have a special meaning anymore - this is different from // what the Unix sh does but causes a lot of problems on DOS // based platforms otherwise s = Commandline.translateCommandline("1 2\\ 3 4"); assertEquals("case with quoted whitespace", 4, s.length); assertEquals("backslash included", "2\\", s[1]);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
Method name: void testTokenizer() Method name: void testTokenizer()
Number of AST nodes: 6 Number of AST nodes: 6
1
s = Commandline.translateCommandline("\"\"");
1
s = Commandline.translateCommandline("1 \'2\"3\' 4");
2
        assertEquals("Doublequoted null arg", 1, s.length);
2
        assertEquals("Case with single quotes around double quote", 3, s.length);
3
        assertEquals("Doublequoted null arg", "",
3
        assertEquals("Single quotes stripped, double quote included", "2\"3",
4
 s[0]);
4
                     s[1]);
5
        // \ doesn't have a special meaning anymore - this is different from
6
        // what the Unix sh does but causes a lot of problems on DOS
7
        // based platforms otherwise
5
        s = Commandline.translateCommandline("\'\' a");
8
        s = Commandline.translateCommandline("1 2\\ 3 4");
6
        assertEquals("Singlequoted null arg prepend", 2, s.length);
9
        assertEquals("case with quoted whitespace", 4, s.length);
7
        assertEquals("Singlequoted null arg prepend", "", s[0]);
10
        assertEquals("backslash included", "2\\", s[1]);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are in the same method
Number of node comparisons36
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    38
    s = Commandline.translateCommandline("\"\"");
    38
    s = Commandline.translateCommandline("\"\"");
    24
    s = Commandline.translateCommandline("1 \'2\"3\' 4");
    Differences
    Expression1Expression2Difference
    "\"\"""1 \'2\"3\' 4"LITERAL_VALUE_MISMATCH
    24
    s = Commandline.translateCommandline("1 \'2\"3\' 4");
    39
    assertEquals("Doublequoted null arg", 1, s.length);
    39
    assertEquals("Doublequoted null arg", 1, s.length);
    25
    assertEquals("Case with single quotes around double quote", 3, s.length);
    Differences
    Expression1Expression2Difference
    "Doublequoted null arg""Case with single quotes around double quote"LITERAL_VALUE_MISMATCH
    13LITERAL_VALUE_MISMATCH
    25
    assertEquals("Case with single quotes around double quote", 3, s.length);
    40
    assertEquals("Doublequoted null arg", "", s[0]);
    40
    assertEquals("Doublequoted null arg", "", s[0]);
    26
    assertEquals("Single quotes stripped, double quote included", "2\"3", s[1]);
    Differences
    Expression1Expression2Difference
    "Doublequoted null arg""Single quotes stripped, double quote included"LITERAL_VALUE_MISMATCH
    """2\"3"LITERAL_VALUE_MISMATCH
    01LITERAL_VALUE_MISMATCH
    26
    assertEquals("Single quotes stripped, double quote included", "2\"3", s[1]);
    41
    s = Commandline.translateCommandline("\'\' a");
    41
    s = Commandline.translateCommandline("\'\' a");
    27
    s = Commandline.translateCommandline("1 2\\ 3 4");
    Differences
    Expression1Expression2Difference
    "\'\' a""1 2\\ 3 4"LITERAL_VALUE_MISMATCH
    27
    s = Commandline.translateCommandline("1 2\\ 3 4");
    42
    assertEquals("Singlequoted null arg prepend", 2, s.length);
    42
    assertEquals("Singlequoted null arg prepend", 2, s.length);
    28
    assertEquals("case with quoted whitespace", 4, s.length);
    Differences
    Expression1Expression2Difference
    "Singlequoted null arg prepend""case with quoted whitespace"LITERAL_VALUE_MISMATCH
    24LITERAL_VALUE_MISMATCH
    28
    assertEquals("case with quoted whitespace", 4, s.length);
    43
    assertEquals("Singlequoted null arg prepend", "", s[0]);
    43
    assertEquals("Singlequoted null arg prepend", "", s[0]);
    29
    assertEquals("backslash included", "2\\", s[1]);
    Differences
    Expression1Expression2Difference
    "Singlequoted null arg prepend""backslash included"LITERAL_VALUE_MISMATCH
    """2\\"LITERAL_VALUE_MISMATCH
    01LITERAL_VALUE_MISMATCH
    29
    assertEquals("backslash included", "2\\", s[1]);
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables s , while Clone fragment #2 returns variables