1 package fit;
2
3 import java.lang.reflect.Method;
4
5 public abstract class ArgumentFixture extends Fixture
6 {
7
8 @SuppressWarnings("unchecked")
9 protected static Class args[] = {Argument.class, Argument.class};
10
11 private boolean stop = false;
12
13 public boolean isStop()
14 {
15 return stop;
16 }
17
18 public void setStop(boolean stop)
19 {
20
21 }
22
23 public void doCells(Parse cells)
24 {
25 if (isStop())
26 {
27 ignore(cells);
28 }
29 else
30 {
31 doTest(cells);
32 }
33 }
34
35 private void doTest(Parse cells)
36 {
37 try
38 {
39 Method action = getClass().getMethod(cells.text(), args);
40 Argument argument;
41 Argument selektor = new Argument(cells.more);
42 if (cells.more != null)
43 {
44 argument = new Argument(cells.more.more);
45 }
46 else
47 {
48 argument = null;
49 }
50 action.invoke(this, new Object[] {selektor, argument});
51 }
52 catch (Exception e)
53 {
54 exception(cells, e);
55 }
56 }
57
58 protected void exception(Argument arg, Exception e)
59 {
60 arg.setException(true);
61 exception(arg.getCell(), e);
62 }
63
64 protected void wrong(Argument arg)
65 {
66 arg.setWrong(true);
67 wrong(arg.getCell());
68 }
69
70 protected void wrong(Argument arg, String actual)
71 {
72 arg.setWrong(true);
73 if (actual == null)
74 {
75 wrong(arg.getCell(), "null");
76 }
77 else
78 {
79 wrong(arg.getCell(), actual);
80 }
81 }
82
83
84
85
86
87
88 protected void wrong(Argument arg, Object actual)
89 {
90 arg.setWrong(true);
91 if (actual == null)
92 {
93 wrong(arg.getCell(), "null");
94 }
95 else
96 {
97 wrong(arg.getCell(), actual.toString());
98 }
99
100 }
101
102 protected void right(Argument arg)
103 {
104 arg.setRight(true);
105 right(arg.getCell());
106 }
107
108 }