You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MethodSigs.java 4.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import org.aspectj.testing.Tester;
  2. import java.util.*;
  3. public class MethodSigs {
  4. public static void main(String[] args) {
  5. new MethodSigs().realMain(args);
  6. }
  7. String want;
  8. void want(String want) { this.want = want; }
  9. void w(String s) { want(s); }
  10. void have(Object have, Object msg) { Tester.checkEqual(want, have, msg+""); }
  11. void have(Object have) { Tester.checkEqual(want, have); }
  12. public void realMain(String[] args) {
  13. lists();
  14. integers();
  15. }
  16. void lists() {
  17. Object o = new Object() { public String toString() { return "o"; } };
  18. Object o1 = new Object() { public String toString() { return "o"; } };
  19. Object o2 = new Object() { public String toString() { return "o"; } };
  20. List l = new Vector() { public String toString() { return "l:"+super.toString(); } };
  21. List l1 = new Vector() { public String toString() { return "l1:"+super.toString(); } };
  22. List l2 = new Vector() { public String toString() { return "l2:"+super.toString(); } };
  23. Collection c = new Vector() { public String toString() { return "c:"+super.toString(); } };
  24. Collection c1 = new Vector() { public String toString() { return "c1:"+super.toString(); } };
  25. Collection c2 = new Vector() { public String toString() { return "c2:"+super.toString(); } };
  26. Set s = new HashSet() { public String toString() { return "s:"+super.toString(); } };
  27. Set s1 = new HashSet() { public String toString() { return "s1:"+super.toString(); } };
  28. Set s2 = new HashSet() { public String toString() { return "s2:"+super.toString(); } };
  29. want("a:Object,Object"); a(o1,o2);
  30. want("a:List,Object"); a(l,o);
  31. want("a:Object,List"); a(o,l);
  32. want("a:Collection,Object"); a(c,o);
  33. want("a:Object,Collection"); a(o,c);
  34. want("a:List,Collection"); a(l,c);
  35. want("a:Collection,List"); a(c,l);
  36. want("a:Collection,Collection"); a(c1,c2);
  37. want("a:Set,Collection"); a(s,c);
  38. want("a:Collection,Set"); a(c,s);
  39. want("a:Set,Set"); a(s1,s2);
  40. want("a:List,Set"); a(l,s);
  41. want("a:Set,List"); a(s,l);
  42. }
  43. public void a(Object o1, Object o2) { have("a:Object,Object"); }
  44. public void a(List l, Object o) { have("a:List,Object"); }
  45. public void a(Object o, List l) { have("a:Object,List"); }
  46. public void a(Collection c, Object o) { have("a:Collection,Object"); }
  47. public void a(Object o, Collection c) { have("a:Object,Collection"); }
  48. public void a(List l, Collection c) { have("a:List,Collection"); }
  49. public void a(Collection c,List l) { have("a:Collection,List"); }
  50. public void a(Collection c1, Collection c2) { have("a:Collection,Collection"); }
  51. public void a(Set s, Collection c) { have("a:Set,Collection"); }
  52. public void a(Collection c,Set s) { have("a:Collection,Set"); }
  53. public void a(Set s1, Set s2) { have("a:Set,Set"); }
  54. public void a(List l, Set s) { have("a:List,Set"); }
  55. public void a(Set s,List l) { have("a:Set,List"); }
  56. void integers() {
  57. Integer i = new Integer(0);
  58. Integer i1 = new Integer(1);
  59. Integer i2 = new Integer(2);
  60. Object o = new Object() { public String toString() { return "o"; } };
  61. Object o1 = new Object() { public String toString() { return "o"; } };
  62. Object o2 = new Object() { public String toString() { return "o"; } };
  63. Object oi = new Integer(3);
  64. w("Object,Object"); f(o1,o2);
  65. w("Integer,Object"); f(i,o);
  66. w("Object,Integer"); f(o,i);
  67. w("Integer,Integer"); f(i1,i2);
  68. w("Object,Object"); f(oi,oi);
  69. w("Object,Object"); f(oi,o);
  70. w("Object,Object"); f(o,oi);
  71. }
  72. public void f(Object o1, Object o2) { have("Object,Object", o1+":"+o2); }
  73. public void f(Integer i, Object o) { have("Integer,Object", i+":"+o); }
  74. public void f(Object o, Integer i) { have("Object,Integer", o+":"+i); }
  75. public void f(Integer i1, Integer i2) { have("Integer,Integer", i1+":"+i2); }
  76. }