summaryrefslogtreecommitdiff
path: root/test/files/run/t6370.scala
diff options
context:
space:
mode:
authorVinicius Miana <vinicius@miana.com.br>2013-01-29 14:14:02 -0200
committerVinicius Miana <vinicius@miana.com.br>2013-02-08 14:43:37 -0200
commit7b425bf7f02c15d6c3577f21318c6bdfc92d6b35 (patch)
tree929d9a8929bd7b1472dbf3e424fb35d7e312fb74 /test/files/run/t6370.scala
parent1a63cf8b9b48c98fa754a1eb6dcfe35220016c74 (diff)
downloadscala-7b425bf7f02c15d6c3577f21318c6bdfc92d6b35.tar.gz
scala-7b425bf7f02c15d6c3577f21318c6bdfc92d6b35.tar.bz2
scala-7b425bf7f02c15d6c3577f21318c6bdfc92d6b35.zip
SI-6370 changed ListMap apply0 method to produce correct error message when a key is not found
Current implementation of apply0 relies on tail method to iterate over all keys. When the list gets to its end, tail produces an 'empty map' message in its exception, which is thrown by ListMap. This change checks if the collection is empty before calling tail and provides a more appropriate key not found message. Signed-off-by: Vinicius Miana <vinicius@miana.com.br>
Diffstat (limited to 'test/files/run/t6370.scala')
-rw-r--r--test/files/run/t6370.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/files/run/t6370.scala b/test/files/run/t6370.scala
new file mode 100644
index 0000000000..c86b87dc8a
--- /dev/null
+++ b/test/files/run/t6370.scala
@@ -0,0 +1,12 @@
+object Test {
+
+ def main(args: Array[String]): Unit = {
+ val m = collection.immutable.ListMap( "x" -> 1 )
+ try {
+ m("y")
+ } catch {
+ case e : NoSuchElementException => assert(e.getMessage() == "key not found: y")
+ }
+
+ }
+}