From 5ffe50c3dfc793eb983f341f4e9e816de3636a4f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 6 Feb 2008 18:43:12 +0000 Subject: fixed problems with ranges --- test/files/neg/t0345.check | 4 ++++ test/files/neg/t0345.scala | 15 +++++++++++++++ test/files/neg/t0351.check | 4 ++++ test/files/neg/t0351.scala | 3 +++ test/files/run/iterators.scala | 16 ++++++++++------ 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 test/files/neg/t0345.check create mode 100755 test/files/neg/t0345.scala create mode 100644 test/files/neg/t0351.check create mode 100755 test/files/neg/t0351.scala (limited to 'test/files') diff --git a/test/files/neg/t0345.check b/test/files/neg/t0345.check new file mode 100644 index 0000000000..f4a5275336 --- /dev/null +++ b/test/files/neg/t0345.check @@ -0,0 +1,4 @@ +t0345.scala:2: error: object creation impossible, since method cons in trait Lizt of type (Nothing)Unit is not defined + val empty = new Lizt[Nothing] { + ^ +one error found diff --git a/test/files/neg/t0345.scala b/test/files/neg/t0345.scala new file mode 100755 index 0000000000..f3652c183b --- /dev/null +++ b/test/files/neg/t0345.scala @@ -0,0 +1,15 @@ +object Lizt { + val empty = new Lizt[Nothing] { + def cons[A](a : A) {} + } +} + +trait Lizt[A] { + def cons(a : A) : Unit +} +class Test { + abstract class C[A] {} + val c = new C[Int] { + def f[A](x: A) {} + } + } diff --git a/test/files/neg/t0351.check b/test/files/neg/t0351.check new file mode 100644 index 0000000000..d374c905ed --- /dev/null +++ b/test/files/neg/t0351.check @@ -0,0 +1,4 @@ +t0351.scala:2: error: no by-name parameter type allowed here + def identity[T](x : => T) : (=> T) + ^ +one error found diff --git a/test/files/neg/t0351.scala b/test/files/neg/t0351.scala new file mode 100755 index 0000000000..665bd89da4 --- /dev/null +++ b/test/files/neg/t0351.scala @@ -0,0 +1,3 @@ +abstract class Foo { + def identity[T](x : => T) : (=> T) +} diff --git a/test/files/run/iterators.scala b/test/files/run/iterators.scala index 714861ef68..7972418059 100644 --- a/test/files/run/iterators.scala +++ b/test/files/run/iterators.scala @@ -22,10 +22,13 @@ object Test { } def check_range2: Int = { - val r1 = Iterator.range(0, 10) - val r2 = Iterator.range(r1.start, r1.end, r1.step + 1) - val r3 = Iterator.range(r1.end, r1.start, -r1.step) - val r4 = Iterator.range(0, 10, 11) + val r1start = 0 + val r1end = 10 + val r1step = 1 + val r1 = Iterator.range(r1start, r1end, r1step) toList; + val r2 = Iterator.range(r1start, r1end, r1step + 1) toList; + val r3 = Iterator.range(r1end, r1start, -r1step) toList; + val r4 = Iterator.range(0, 10, 11) toList; // 10 + 5 + 10 + 1 r1.length + r2.length + r3.length + r4.length } @@ -34,8 +37,9 @@ object Test { def trues(xs: List[Boolean]) = xs.foldLeft(0)((a, b) => if (b) a+1 else a) val r1 = Iterator.range(0, 10) val xs1 = List(r1 contains 5, r1 contains 6) - val r2 = Iterator.range(0, 10, 2) - val xs2 = List(r2 contains 5, r2 contains 6) + val r2a = Iterator.range(0, 10, 2) + val r2b = Iterator.range(0, 10, 2) + val xs2 = List(r2a contains 5, r2b contains 6) val r3 = Iterator.range(0, 10, 11) val xs3 = List(r3 contains 5, r3 contains 6) // 2 + 1 + 0 -- cgit v1.2.3