File: collections.testsuite

package info (click to toggle)
nice 0.9.13-3.2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 7,292 kB
  • ctags: 6,893
  • sloc: java: 42,767; xml: 3,508; lisp: 1,084; sh: 742; makefile: 670; cpp: 21; awk: 3
file content (82 lines) | stat: -rw-r--r-- 1,830 bytes parent folder | download | duplicates (3)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/// PASS
  let dummy = new Flowlet();
  /// Toplevel
  class Flowlet {
    java.util.Set<String> connectors = new java.util.HashSet();
  }

/// PASS
  List<String> l = new LinkedList();
  l.add("AA");
  assert (l.contains("AA"));

/// PASS
  int nSize = 10;
  ArrayList<int> L1 = new ArrayList(nSize);
  for (int j = 1; j <= nSize; j++) L1.add(j);

  Collections.reverse(L1);
  assert L1[0] == nSize;

/// PASS
  ArrayList<int> alist = new ArrayList();
  alist.add(10);
  alist.remove(10);

/// PASS
  int[] a = [ 1, 10, 3 ];
  a.sort((int i, int j) => j - i);
  assert a[0] == 10;

  String[] s = [ "a", "aa", "aaa" ];
  s.sort((String s1, String s2) => s2.length - s1.length);
  assert s[0] == "aaa";

  List<String> list = [ "C", "BA", "BB", "A" ];
  sort(list, (String s1, String s2) => s1.compareTo(s2));
  assert list[0] == "A";
  assert list[1] == "BA";

/// PASS   
  List<B> list = new ArrayList();   
  B b = new B();   
  list.add(b);   
  A obj = b;   
  assert(list.contains(obj));   
  /// Toplevel   
  class A{}   
  class B extends A{}   

/// FAIL   
  List<B> list = new ArrayList();   
  A obj = new A();   
  list. /*/// FAIL HERE */ contains(obj);   
  /// Toplevel   
  class A{}   
  class B{} 

/// PASS
  /// Toplevel
  <T,U,V | U <: T, V <: T> Set<T> myintersection(Set<U>, Set<V>);
  
  <T,U,V> myintersection(Set s1, Set s2) {
     Set<T> res = new HashSet();
     if (s1.size() < s2.size()) {
         for(U elem : s1) 
             if (s2.contains(elem)) res.add(elem);
     } else {
         for(V elem : s2) 
             if (s1.contains(elem)) res.add(elem);
     }
     return res;
  }

/// PASS
  List<A> listA = new ArrayList();
  List<B> listB = new ArrayList();
  listB.add(new B());
  listA.addAll(listB);
  assert listA.containsAll(listB);
  /// Toplevel
  class A{}
  class B extends A{}