summaryrefslogtreecommitdiff
path: root/test/files/run/bugs.scala
blob: b84d9827fbec5944288ab0c7ada9af1523d63f61 (plain) (blame)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//############################################################################
// Bugs
//############################################################################
// $Id$

//############################################################################
// Bug 135

object Bug135Test {

  import scala.collection.immutable.TreeMap;
  import scala.collection.immutable.Order;

  def main(args: Array[String]): Unit = {
    val intOrder =
	new Order((x:int,y:int) => x < y, (x:int,y:int) => x == y);
    val myMap:TreeMap[int,String] = new TreeMap(intOrder);
    val map1 = myMap + 42 -> "The answer";
    Console.println(map1.get(42));
  }

}

//############################################################################
// Bug 142

abstract class Bug142Foo1 { class Inner; def foo: Inner; foo; }
abstract class Bug142Foo2 { class Inner; def foo: Inner = {System.out.println("ok"); null};}
abstract class Bug142Foo3 { type  Inner; def foo: Inner; foo; }
abstract class Bug142Foo4 { type  Inner; def foo: Inner = {System.out.println("ok"); null.asInstanceOf[Inner]}; }

abstract class Bug142Bar1 { type  Inner; def foo: Inner = {System.out.println("ok"); null.asInstanceOf[Inner]}; }
abstract class Bug142Bar2 { type  Inner; def foo: Inner; foo; }
abstract class Bug142Bar3 { class Inner; def foo: Inner = {System.out.println("ok"); null}; }
abstract class Bug142Bar4 { class Inner; def foo: Inner; foo; }

object Bug142Test1 extends Bug142Foo1 with Bug142Bar1 {def main(args:Array[String]):Unit=();}
object Bug142Test2 extends Bug142Foo2 with Bug142Bar2 {def main(args:Array[String]):Unit=();}
object Bug142Test3 extends Bug142Foo3 with Bug142Bar3 {def main(args:Array[String]):Unit=();}
object Bug142Test4 extends Bug142Foo4 with Bug142Bar4 {def main(args:Array[String]):Unit=();}
object Bug142Test5 with    Bug142Foo1 with Bug142Bar1 {def main(args:Array[String]):Unit=();}
object Bug142Test6 with    Bug142Foo2 with Bug142Bar2 {def main(args:Array[String]):Unit=();}
object Bug142Test7 with    Bug142Foo3 with Bug142Bar3 {def main(args:Array[String]):Unit=();}
object Bug142Test8 with    Bug142Foo4 with Bug142Bar4 {def main(args:Array[String]):Unit=();}

object Bug142Test {
  def main(args:Array[String]): Unit = {
    Bug142Test1;
    Bug142Test2;
    Bug142Test3;
    Bug142Test4;
    Bug142Test5;
    Bug142Test6;
    Bug142Test7;
    Bug142Test8;
    ()
  }
}

//############################################################################
// Bug 166

object Bug166Test {
  import scala.collection.mutable.HashMap ;
  def main(args:Array[String]) = {
    val m:HashMap[String,String] = new HashMap[String,String];
    m.update("foo","bar");
  }
}

//############################################################################
// Bug 167

class Bug167Node(bar:Int) {
  val foo = {
    val bar = 1;
    bar
  }
}

object Bug167Test {
  def main(args: Array[String]): Unit = {
    if (new Bug167Node(0).foo != 1) System.out.println("bug 167");
  }
}

//############################################################################
// Bug 168

class Bug168Foo {
  class Bar;
  def foo = new Bar;
}

object Bug168Test {
  def main(args: Array[String]): Unit = {
    (new Bug168Foo).foo;
    ()
  }
}

//############################################################################
// Bug 174

class Bug174Foo[X] {

  class Tree;
  class Node extends Tree;


  val inner:Inner = new SubInner;

  trait Inner {
    def test: Bug174Foo[X]#Tree ;
  }

  class SubInner extends Inner {
    def test = new Node;
  }

}

object Bug174Test {
  def main(args: Array[String]): Unit = {
    (new Bug174Foo[Int]).inner.test;
    ()
  }
}


//############################################################################
// Bug 176

trait Bug176A {
  type T;
  def foo(x: T): Int;
  def bar: T;
  def test = foo(bar);
}
trait Bug176B {
  type S <: Object;
  type T = S;
  def foo(x: S): Int;
  def bar: S;
}
class Bug176C with Bug176A with Bug176B {
  class S;
  def foo(x: S) = 1;
  def bar = new S;
}
object Bug176Test {
  def main(args: Array[String]): Unit = {
    val x: Bug176A = new Bug176C;
    System.out.println(x.test);
  }
}

//############################################################################
// Main

object Test  {
  var errors: Int = 0;
  def test(bug: Int, def test: Unit): Unit = {
    System.out.println("<<< bug " + bug);
    try {
      test;
    } catch {
      case exception => {
        val name: String = Thread.currentThread().getName();
        System.out.print("Exception in thread \"" + name + "\" ");
        exception.printStackTrace();
        System.out.println();
        errors = errors + 1;
      }
    }
    System.out.println(">>> bug " + bug);
    System.out.println();
  }

  def main(args: Array[String]): Unit = {

    test(135, Bug135Test.main(args));
    test(142, Bug142Test.main(args));
    test(166, Bug166Test.main(args));
    test(167, Bug167Test.main(args));
    test(168, Bug168Test.main(args));
    test(174, Bug174Test.main(args));
    test(176, Bug176Test.main(args));

    if (errors > 0) {
      System.out.println();
      System.out.println(errors + " error" + (if (errors > 1) "s" else ""));
    }
  }
}

//############################################################################