1.1 --- a/tests/AbstractClassTest.java Sun Jan 23 01:01:34 2005 +0100 1.2 +++ b/tests/AbstractClassTest.java Sun Jan 23 01:01:40 2005 +0100 1.3 @@ -1,5 +1,13 @@ 1.4 public abstract class AbstractClassTest { 1.5 public static ConcreteClassTest member = new ConcreteClassTest(); 1.6 + 1.7 + public static void main(String[] args) { 1.8 + if (AbstractClassTest.member != null) { 1.9 + System.out.println("AbstractClassTest.member correct: " + AbstractClassTest.member); 1.10 + } else { 1.11 + System.err.println("AbstractClassTest.member failed!"); 1.12 + } 1.13 + } 1.14 } 1.15 1.16 // vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/tests/DispatchTest.java Sun Jan 23 01:01:34 2005 +0100 2.2 +++ b/tests/DispatchTest.java Sun Jan 23 01:01:40 2005 +0100 2.3 @@ -45,6 +45,52 @@ 2.4 public int testTest(DispatchInterface obj) { 2.5 return test(obj); 2.6 } 2.7 + 2.8 + public static void main(String[] args) { 2.9 + DispatchTest test = new DispatchTest(); 2.10 + DispatchClass1 dc1 = new DispatchClass1(); 2.11 + DispatchClass2 dc2 = new DispatchClass2(); 2.12 + 2.13 + if (test.a == 1 && test.b == 2) { 2.14 + System.out.println("test.a, test.b correct: " + test.a + ", " + test.b); 2.15 + } else { 2.16 + System.err.println("test.a, test.b failed!"); 2.17 + } 2.18 + test.set(5); 2.19 + if (test.a == 5 && test.b == 2) { 2.20 + System.out.println("test.a, test.b correct: " + test.a + ", " + test.b); 2.21 + } else { 2.22 + System.err.println("test.a, test.b failed!"); 2.23 + } 2.24 + test.set(7.0f); 2.25 + if (test.a == 5 && test.b == 7.0f) { 2.26 + System.out.println("test.a, test.b correct: " + test.a + ", " + test.b); 2.27 + } else { 2.28 + System.err.println("test.a, test.b failed!"); 2.29 + } 2.30 + if (test.test(dc1) == 11) { 2.31 + System.out.println("test.test(dc1) correct: " + test.test(dc1)); 2.32 + } else { 2.33 + System.err.println("test.test(dc1) failed!"); 2.34 + } 2.35 + if (test.test(dc2) == 2) { 2.36 + System.out.println("test.test(dc2) correct: " + test.test(dc2)); 2.37 + } else { 2.38 + System.err.println("test.test(dc2) failed!"); 2.39 + } 2.40 + // Yes, one might think this could be 11, but the parameter becomes 2.41 + // "more vague" when passed to testTest. 2.42 + if (test.testTest(dc1) == 1) { 2.43 + System.out.println("test.testTest(dc1) correct: " + test.testTest(dc1)); 2.44 + } else { 2.45 + System.err.println("test.testTest(dc1) failed!"); 2.46 + } 2.47 + if (test.testTest(dc2) == 2) { 2.48 + System.out.println("test.testTest(dc2) correct: " + test.testTest(dc2)); 2.49 + } else { 2.50 + System.err.println("test.testTest(dc2) failed!"); 2.51 + } 2.52 + } 2.53 } 2.54 2.55 interface DispatchInterface { 2.56 @@ -62,3 +108,5 @@ 2.57 return 2; 2.58 } 2.59 } 2.60 + 2.61 +// vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/tests/StaticTest.java Sun Jan 23 01:01:34 2005 +0100 3.2 +++ b/tests/StaticTest.java Sun Jan 23 01:01:40 2005 +0100 3.3 @@ -3,6 +3,24 @@ 3.4 public static StaticTestClass staticMember = StaticTestClass.newInstance(); 3.5 public static StaticTestClass staticMember2 = StaticTestClass.newInstance(123); 3.6 public static int staticMember3 = StaticTestClass.getNumber(); 3.7 + 3.8 + public static void main(String[] args) { 3.9 + if (StaticTest.staticMember != null && StaticTest.staticMember.x == 321) { 3.10 + System.out.println("StaticTest.staticMember.x correct: " + StaticTest.staticMember.x); 3.11 + } else { 3.12 + System.out.println("StaticTest.staticMember.x failed!"); 3.13 + } 3.14 + if (StaticTest.staticMember2 != null && StaticTest.staticMember2.x == 123) { 3.15 + System.out.println("StaticTest.staticMember2.x correct: " + StaticTest.staticMember2.x); 3.16 + } else { 3.17 + System.out.println("StaticTest.staticMember2.x failed!"); 3.18 + } 3.19 + if (StaticTest.staticMember3 == 456) { 3.20 + System.out.println("StaticTest.staticMember3 correct: " + StaticTest.staticMember3); 3.21 + } else { 3.22 + System.out.println("StaticTest.staticMember3 failed!"); 3.23 + } 3.24 + } 3.25 } 3.26 3.27 class StaticTestClass { 3.28 @@ -28,3 +46,5 @@ 3.29 return 456; 3.30 } 3.31 } 3.32 + 3.33 +// vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/tests/StringBufferTest.java Sun Jan 23 01:01:34 2005 +0100 4.2 +++ b/tests/StringBufferTest.java Sun Jan 23 01:01:40 2005 +0100 4.3 @@ -2,9 +2,31 @@ 4.4 StringBuffer sb1; 4.5 StringBuffer sb2; 4.6 String s; 4.7 + 4.8 public StringBufferTest(String a, String b) { 4.9 sb1 = new StringBuffer(a); 4.10 sb2 = new StringBuffer(b); 4.11 s = a + b; 4.12 } 4.13 + 4.14 + public static void main(String[] args) { 4.15 + StringBufferTest test = new StringBufferTest("Hello ", "world"); 4.16 + if (test.sb1.toString().equals("Hello ")) { 4.17 + System.out.println("test.sb1.toString() correct: " + test.sb1.toString()); 4.18 + } else { 4.19 + System.err.println("test.sb1.toString() failed!"); 4.20 + } 4.21 + if (test.sb2.toString().equals("world")) { 4.22 + System.out.println("test.sb2.toString() correct: " + test.sb2.toString()); 4.23 + } else { 4.24 + System.err.println("test.sb2.toString() failed!"); 4.25 + } 4.26 + if (test.s.equals("Hello world")) { 4.27 + System.out.println("test.s correct: " + test.s); 4.28 + } else { 4.29 + System.err.println("test.s failed!"); 4.30 + } 4.31 + } 4.32 } 4.33 + 4.34 +// vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/tests/StringTest.java Sun Jan 23 01:01:34 2005 +0100 5.2 +++ b/tests/StringTest.java Sun Jan 23 01:01:40 2005 +0100 5.3 @@ -2,7 +2,7 @@ 5.4 private String s; 5.5 private String s2 = new String("abc"); 5.6 private static String s3; 5.7 - private static String s4 = new String("xyz"); 5.8 + public static String s4 = new String("xyz"); 5.9 5.10 public StringTest() { 5.11 s = s2; 5.12 @@ -15,4 +15,32 @@ 5.13 public StringTest(String firstString, String secondString) { 5.14 s = firstString + secondString; 5.15 } 5.16 + 5.17 + public static void main(String[] args) { 5.18 + if (StringTest.s4.equals("xyz")) { 5.19 + System.out.println("StringTest.s4 correct: " + StringTest.s4); 5.20 + } else { 5.21 + System.err.println("StringTest.s4 failed!"); 5.22 + } 5.23 + StringTest test0 = new StringTest(); 5.24 + if (test0.s.equals("abc")) { 5.25 + System.out.println("test0.s correct: " + test0.s); 5.26 + } else { 5.27 + System.err.println("test0.s failed!"); 5.28 + } 5.29 + StringTest test1 = new StringTest("Test"); 5.30 + if (test1.s.equals("Test")) { 5.31 + System.out.println("test1.s correct: " + test1.s); 5.32 + } else { 5.33 + System.err.println("test1.s failed!"); 5.34 + } 5.35 + StringTest test2 = new StringTest("Hello ", "world"); 5.36 + if (test2.s.equals("Hello world")) { 5.37 + System.out.println("test2.s correct: " + test2.s); 5.38 + } else { 5.39 + System.err.println("test2.s failed!"); 5.40 + } 5.41 + } 5.42 } 5.43 + 5.44 +// vim: tabstop=4 expandtab shiftwidth=4
6.1 --- a/tests/SwitchTest.java Sun Jan 23 01:01:34 2005 +0100 6.2 +++ b/tests/SwitchTest.java Sun Jan 23 01:01:40 2005 +0100 6.3 @@ -18,4 +18,30 @@ 6.4 6.5 return x; 6.6 } 6.7 + 6.8 + public static void main(String[] args) { 6.9 + SwitchTest test = new SwitchTest(); 6.10 + if (test.test(0) == 10) { 6.11 + System.out.println("test.test(0) correct: " + test.test(0)); 6.12 + } else { 6.13 + System.err.println("test.test(0) failed!"); 6.14 + } 6.15 + if (test.test(1) == 11) { 6.16 + System.out.println("test.test(1) correct: " + test.test(1)); 6.17 + } else { 6.18 + System.err.println("test.test(1) failed!"); 6.19 + } 6.20 + if (test.test(2) == 22) { 6.21 + System.out.println("test.test(2) correct: " + test.test(2)); 6.22 + } else { 6.23 + System.err.println("test.test(2) failed!"); 6.24 + } 6.25 + if (test.test(3) == 3) { 6.26 + System.out.println("test.test(3) correct: " + test.test(3)); 6.27 + } else { 6.28 + System.err.println("test.test(3) failed!"); 6.29 + } 6.30 + } 6.31 } 6.32 + 6.33 +// vim: tabstop=4 expandtab shiftwidth=4
7.1 --- a/tests/ValueSubclass.java Sun Jan 23 01:01:34 2005 +0100 7.2 +++ b/tests/ValueSubclass.java Sun Jan 23 01:01:40 2005 +0100 7.3 @@ -29,9 +29,50 @@ 7.4 public void setValueObject(Value v) { 7.5 this.value = v.getValue(); 7.6 } 7.7 + 7.8 + /** 7.9 + * Test program. 7.10 + */ 7.11 + public static void main(String[] args) { 7.12 + SubclassValue sv = new SubclassValue(686); 7.13 + if (sv.getValue() == 686) { 7.14 + System.out.println("sv.getValue() correct: " + sv.getValue()); 7.15 + } else { 7.16 + System.err.println("sv.getValue() failed!"); 7.17 + } 7.18 + 7.19 + ValueSubclass vs = new ValueSubclass(109); 7.20 + if (vs.tmp.getValue() == 42) { 7.21 + System.out.println("vs.tmp.getValue() correct: " + vs.tmp.getValue()); 7.22 + } else { 7.23 + System.err.println("vs.tmp.getValue() failed!"); 7.24 + } 7.25 + if (vs.getValue() == 109) { 7.26 + System.out.println("vs.getValue() correct: " + vs.getValue()); 7.27 + } else { 7.28 + System.err.println("vs.getValue() failed!"); 7.29 + } 7.30 + vs.setValue(404); 7.31 + if (vs.getValue() == -404) { 7.32 + System.out.println("vs.getValue() correct: " + vs.getValue()); 7.33 + } else { 7.34 + System.err.println("vs.getValue() failed!"); 7.35 + } 7.36 + if (vs.add(404) == -808) { 7.37 + System.out.println("vs.add(404) correct: " + vs.add(404)); 7.38 + } else { 7.39 + System.err.println("vs.add(404) failed!"); 7.40 + } 7.41 + vs.setValueObject(sv); 7.42 + if (vs.getValue() == 686) { 7.43 + System.out.println("vs.getValue() correct: " + vs.getValue()); 7.44 + } else { 7.45 + System.err.println("vs.getValue() failed!"); 7.46 + } 7.47 + } 7.48 } 7.49 7.50 -// This should confuse the importer since it should be read before Value in 7.51 +// This would confuse a simple importer since it should be read before Value in 7.52 // alphabetical order. 7.53 7.54 class SubclassValue extends Value { 7.55 @@ -39,3 +80,5 @@ 7.56 super(x); 7.57 } 7.58 } 7.59 + 7.60 +// vim: tabstop=4 expandtab shiftwidth=4