184-1-2

MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime());
MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime());

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/axis/junit/DateAxisTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/axis/junit/DateAxisTests.java
Method name: `void testPreviousStandardDateMillisecondA()` |  | Method name: `void testPreviousStandardDateMillisecondB()`
Number of AST nodes: 25 |  | Number of AST nodes: 25

1

    MyDateAxis axis = new MyDateAxis("Millisecond");↵

1

    MyDateAxis axis = new MyDateAxis("Millisecond");↵

2

            Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007);↵

2

            Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007);↵

3

            Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007);↵

3

            Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007);↵

4

            Date d0 = new Date(m0.getFirstMillisecond());↵

4

            Date d0 = new Date(m0.getFirstMillisecond());↵

5

            Date end = new Date(m1.getLastMillisecond());↵

5

            Date end = new Date(m1.getLastMillisecond());↵

6

            ↵

6

            ↵

7

            DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1);↵

7

            DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10);↵

8

            axis.setTickUnit(unit);↵

8

            axis.setTickUnit(unit);↵

9

            // START: check d0↵

9

            // START: check d0↵

10

            axis.setTickMarkPosition(DateTickMarkPosition.START);↵

10

            axis.setTickMarkPosition(DateTickMarkPosition.START);↵

11

            axis.setRange(d0, end);↵

11

            axis.setRange(d0, end);↵

12

            Date psd = axis.previousStandardDate(d0, unit);↵

12

            Date psd = axis.previousStandardDate(d0, unit);↵

13

            Date nsd = unit.addToDate(psd);↵

13

            Date nsd = unit.addToDate(psd);↵

14

            assertTrue(psd.getTime() < d0.getTime());↵

14

            assertTrue(psd.getTime() < d0.getTime());↵

15

            assertTrue(nsd.getTime() >= d0.getTime());↵

15

            assertTrue(nsd.getTime() >= d0.getTime());↵

16

            // MIDDLE: check d0↵

16

            // MIDDLE: check d0↵

17

            axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);↵

17

            axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);↵

18

            ↵

18

            ↵

19

            axis.setRange(d0, end);↵

19

            axis.setRange(d0, end);↵

20

            psd = axis.previousStandardDate(d0, unit);↵

20

            psd = axis.previousStandardDate(d0, unit);↵

21

            nsd = unit.addToDate(psd);↵

21

            nsd = unit.addToDate(psd);↵

22

            assertTrue(psd.getTime() < d0.getTime());↵

22

            assertTrue(psd.getTime() < d0.getTime());↵

23

            assertTrue(nsd.getTime() >= d0.getTime());↵

23

            assertTrue(nsd.getTime() >= d0.getTime());↵

24

            ↵

24

            ↵

25

            // END: check d0↵

25

            // END: check d0↵

26

            axis.setTickMarkPosition(DateTickMarkPosition.END);↵

26

            axis.setTickMarkPosition(DateTickMarkPosition.END);↵

27

            ↵

27

            ↵

28

            axis.setRange(d0, end);↵

28

            axis.setRange(d0, end);↵

29

            psd = axis.previousStandardDate(d0, unit);↵

29

            psd = axis.previousStandardDate(d0, unit);↵

30

            nsd = unit.addToDate(psd);↵

30

            nsd = unit.addToDate(psd);↵

31

            assertTrue(psd.getTime() < d0.getTime());↵

31

            assertTrue(psd.getTime() < d0.getTime());↵

32

            assertTrue(nsd.getTime() >= d0.getTime());

32

            assertTrue(nsd.getTime() >= d0.getTime());

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0
Clones location | Clones are declared in the same class
Number of node comparisons | 353

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 25
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 0.0
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       MyDateAxis axis = new MyDateAxis("Millisecond");

   1

       MyDateAxis axis = new MyDateAxis("Millisecond");

   2

       Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007);

   2

       Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007);

   3

       Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007);

   3

       Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007);

   4

       Date d0 = new Date(m0.getFirstMillisecond());

   4

       Date d0 = new Date(m0.getFirstMillisecond());

   5

       Date end = new Date(m1.getLastMillisecond());

   5

       Date end = new Date(m1.getLastMillisecond());

   6

       DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1);

   6 | DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1);
   6 | DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   1 | 10 | LITERAL_VALUE_MISMATCH

   6

       DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10);

   7

       axis.setTickUnit(unit);

   7

       axis.setTickUnit(unit);

   8

       axis.setTickMarkPosition(DateTickMarkPosition.START);

   8

       axis.setTickMarkPosition(DateTickMarkPosition.START);

   9

       axis.setRange(d0, end);

   9

       axis.setRange(d0, end);

   10

       Date psd = axis.previousStandardDate(d0, unit);

   10

       Date psd = axis.previousStandardDate(d0, unit);

   11

       Date nsd = unit.addToDate(psd);

   11

       Date nsd = unit.addToDate(psd);

   12

       assertTrue(psd.getTime() < d0.getTime());

   12

       assertTrue(psd.getTime() < d0.getTime());

   13

       assertTrue(nsd.getTime() >= d0.getTime());

   13

       assertTrue(nsd.getTime() >= d0.getTime());

   14

       axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

   14

       axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

   15

       axis.setRange(d0, end);

   15

       axis.setRange(d0, end);

   16

       psd = axis.previousStandardDate(d0, unit);

   16

       psd = axis.previousStandardDate(d0, unit);

   17

       nsd = unit.addToDate(psd);

   17

       nsd = unit.addToDate(psd);

   18

       assertTrue(psd.getTime() < d0.getTime());

   18

       assertTrue(psd.getTime() < d0.getTime());

   19

       assertTrue(nsd.getTime() >= d0.getTime());

   19

       assertTrue(nsd.getTime() >= d0.getTime());

   20

       axis.setTickMarkPosition(DateTickMarkPosition.END);

   20

       axis.setTickMarkPosition(DateTickMarkPosition.END);

   21

       axis.setRange(d0, end);

   21

       axis.setRange(d0, end);

   22

       psd = axis.previousStandardDate(d0, unit);

   22

       psd = axis.previousStandardDate(d0, unit);

   23

       nsd = unit.addToDate(psd);

   23

       nsd = unit.addToDate(psd);

   24

       assertTrue(psd.getTime() < d0.getTime());

   24

       assertTrue(psd.getTime() < d0.getTime());

   25

       assertTrue(nsd.getTime() >= d0.getTime());

   25

       assertTrue(nsd.getTime() >= d0.getTime());

   Precondition Violations (0)
   Row | Violation
   --- | ---