File: instanceof.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 (52 lines) | stat: -rw-r--r-- 918 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
/// PASS
  boolean b = "A" instanceof java.lang.String;

/// PASS
  boolean b = "A" instanceof String;

/// PASS
  boolean b = "A" instanceof Local;
  /// Toplevel
  class Local {}

/// PASS
  /// Toplevel
  boolean f() = "A" instanceof Local;
  class Local {}

/// FAIL
  boolean b = "A" instanceof /* /// FAIL HERE */ not.Existing;

/// PASS
  if ("A" instanceof String)
    {}
  else
    throw new Error();

/// PASS
  if (0 instanceof String)
    throw new Error();

/// FAIL
  boolean b = /* /// FAIL HERE */ 1 instanceof int;

/// PASS
  if (true instanceof boolean)
    {}
  else
    throw new Error();

/// PASS
  assert [] instanceof Object[];

  int[] i = [0];
  assert i instanceof int[];

  Object l = [""];
  assert l instanceof String[];

/// PASS
  assert   "".isa(java.lang.String);
  assert ! "".isa(java.io.File);
  /// Toplevel
<T,U> boolean isa(T value, Class<U> type) = `instanceof`(value, type);