From caa6bf0e7a9c02b7519549c289f7a455bad281b1 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 7 Jun 2010 23:43:14 +0000 Subject: Most of the iterate implementations were callin... Most of the iterate implementations were calling the given function one too many times, leading to tragic failure if the function could not handle this (such as repeatedly applying tail.) Closes #3540, review by prokopec. --- test/files/run/bug3540.scala | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 test/files/run/bug3540.scala (limited to 'test/files/run') diff --git a/test/files/run/bug3540.scala b/test/files/run/bug3540.scala new file mode 100644 index 0000000000..5ffacb5dff --- /dev/null +++ b/test/files/run/bug3540.scala @@ -0,0 +1,7 @@ +object Test { + def main(args: Array[String]): Unit = { + assert(List.iterate(List(1,2,3), 4)(_.tail).last.isEmpty) + assert(Stream.iterate(Stream(1,2,3), 4)(_.tail).last.isEmpty) + assert(Array.iterate(Array(1,2,3), 4)(_.tail).last.isEmpty) + } +} -- cgit v1.2.3