aboutsummaryrefslogtreecommitdiffstats
path: root/tests/debugger/ArgumentTester.java
blob: ade62baa71995b6457e2a899d85a902f4f2c6024 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//package debugger;

import com.sun.jdi.*;
import com.sun.jdi.event.*;
import com.sun.jdi.request.*;
import java.io.*;
import java.util.*;
import org.aspectj.tools.debugger.*;

public class ArgumentTester extends Tester {

    public static void main(String[] args) {
        new Main(new ArgumentTester(false), args);
    }
    
    public ArgumentTester(boolean b) {
        super(b);
    }

    public String getClassName() {
        return "Arguments";
    }

    public boolean test() {
        db();
        try {
            setRunArgs("0 1 2");
            stopon(19);
            stop(3);
            startTest();
            setRunArgs("0 1 2 3 4 5 6");
            stopon(19);
            stop(7);
            startTest();            
            quit();
            return true;
        } catch (DebuggerException de) {
            de.printStackTrace();
        }
        return false;
    }

    protected void stop(final int max) {
        d.addStopListener(new StopAdapter() {
                int times = -1;
                public void breakpointEvent(BreakpointEvent e) {
                    try {
                        String value = print("s") + "";
                        String str = "\"" + times + "\"";
                        if ((times++) != -1) {
                            check(value.equals(str), value + "!=" + str);
                        }
                        if (times < max) {
                            cont();
                        } else {
                            clear(19);
                            d.removeStopListener(this);
                        }
                    } catch (DebuggerException de) {
                        de(de);
                    }
                }
            });
    }
}