summaryrefslogtreecommitdiff
path: root/test/files/run/transpose.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-19 19:59:40 +0000
committerPaul Phillips <paulp@improving.org>2011-02-19 19:59:40 +0000
commit68d13416b50acb1779a3befe817fb2a7eabe9f14 (patch)
tree7c4ba0d3b702b6bc05edebd91a43a681a13d2110 /test/files/run/transpose.scala
parente91c0e25f1095e77b8dcc8342893462d072a35e9 (diff)
downloadscala-68d13416b50acb1779a3befe817fb2a7eabe9f14.tar.gz
scala-68d13416b50acb1779a3befe817fb2a7eabe9f14.tar.bz2
scala-68d13416b50acb1779a3befe817fb2a7eabe9f14.zip
Rediscovering that transpose sometimes throws a...
Rediscovering that transpose sometimes throws an exception on irregular lists and sometimes returns an irregular result (depending on whether the first collection is the longest or not) indicated that this needs a better resolution than the status quo. Determination: as long as we're throwing an exception on any invalid input, we should throw an exception on all invalid input, so that's what it does now. I postpone any attempt to offer a variation accepting a "hole value". Closes #3597, review by community.
Diffstat (limited to 'test/files/run/transpose.scala')
-rw-r--r--test/files/run/transpose.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/files/run/transpose.scala b/test/files/run/transpose.scala
new file mode 100644
index 0000000000..2761a24ff5
--- /dev/null
+++ b/test/files/run/transpose.scala
@@ -0,0 +1,12 @@
+object Test {
+ def wrap[T >: Null](body: => T) =
+ try body
+ catch { case _: IllegalArgumentException => null }
+
+ def main(args: Array[String]): Unit = {
+ assert(wrap(Nil.transpose) == Nil)
+ assert(wrap(List(List(1, 2), List(1)).transpose) == null)
+ assert(wrap(List(List(1), List(1, 2)).transpose) == null)
+ assert(wrap(List(List(1, 2), List(1, 2)).transpose) == List(List(1, 1), List(2, 2)))
+ }
+}