File: Watches.java

package info (click to toggle)
jswat2 2.37-1
  • links: PTS
  • area: contrib
  • in suites: etch, etch-m68k
  • size: 7,092 kB
  • ctags: 5,592
  • sloc: java: 43,576; xml: 1,086; sh: 66; makefile: 57
file content (48 lines) | stat: -rw-r--r-- 1,160 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// JSwat test class for watchpoints.
// $Id: Watches.java 1157 2004-02-25 09:28:54Z nfiedler $

package pkg;

import java.util.ArrayList;

public class Watches {

    public void runtest() {
        // Populate the test list.
        ArrayList list = new ArrayList();
        for (int ii = 0; ii < 20; ii++) {
            MutableInteger mi = new MutableInteger(ii);
            list.add(mi); // unit tests stop here
        }

        // Modify the values to cause modification events.
        for (int ii = 0; ii < list.size(); ii++) {
            MutableInteger mi = (MutableInteger) list.get(ii);
            mi.setValue(mi.getValue() * 2);
        }
    }

    public static void main(String[] args) {
        Watches me = new Watches();
        me.runtest();
    }

}

// This is defined outside of Watches, and is non-public, of course,
// for the sake of testing the PathManager's find source function.
class MutableInteger {
    private int value;

    public MutableInteger(int i) {
        value = i;
    }

    public int getValue() {
        return value; // unit tests stop here
    }

    public void setValue(int i) {
        value = i;
    }
}