File: null.testsuite

package info (click to toggle)
nice 0.9.12-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,220 kB
  • ctags: 6,894
  • sloc: java: 42,767; xml: 3,508; lisp: 1,079; sh: 736; makefile: 673; cpp: 21; awk: 3
file content (88 lines) | stat: -rw-r--r-- 1,512 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
83
84
85
86
87
88
/// COMMENT Test typing related to nullness markers.
/// PASS
  /// toplevel
<T> void nonnull(!T);

nonnull(String x) {}
nonnull(x) {}

/// PASS
  ?int i = f();
  /// Toplevel

<T> ?T f(?T s = null, !T?->!T i = null) = s;

/// PASS
  /// Toplevel
void foo()
{
  javax.swing.JFrame f = new javax.swing.JFrame().init();
}

<java.awt.Component T> T init
  (T this,
   ?String propertyName = null,
   java.awt.event.ComponentEvent ?-> void componentHidden = null)
{                            
  return this;
}

/// PASS
  f(null, null);
  /// Toplevel
void f(?String, int ?-> int) {}

/// FAIL
  /* /// FAIL HERE */ f(null);
  /// Toplevel
void f(?String) {}
void f(?java.io.File) {}

/// PASS
  // Checks that ! is the minimum amond nullness markers.
  /// Toplevel
interface Method <R,A> {
   R call(A a);
}

abstract class OOMemoize<R,A> implements Method<R,A> {
   HashMap<A,R> table = new HashMap();

   R protomethod(A a);
}

<R,A> call(OOMemoize this, a){
   if (this.table.containsKey(a))
     return notNull(this.table.get(a));
   else {
      let R m = this.protomethod(a);
      this.table.put(a,m);
      return m;
   }
}

/// PASS
  /// package a
  /// Toplevel
<T> !T foo(T x)
{
  assert x != null;
  return x;
}
  /// package b import a
  String s = foo("");

/// PASS
  /// Toplevel
<W> !W foo(W x, !W y) = y;

/// PASS
  /// Toplevel
<W> !W foo(!W x, W y) = x;

/// PASS
  /// package a
  /// Toplevel
<T> !T foo(T x, !T y) = x != null ? x : y;
  /// package b import a
  String s = foo(null, "");