diff options
author | Vinicius Miana <vinicius@miana.com.br> | 2013-01-29 14:14:02 -0200 |
---|---|---|
committer | Vinicius Miana <vinicius@miana.com.br> | 2013-02-08 14:43:37 -0200 |
commit | 7b425bf7f02c15d6c3577f21318c6bdfc92d6b35 (patch) | |
tree | 929d9a8929bd7b1472dbf3e424fb35d7e312fb74 /test/files/run | |
parent | 1a63cf8b9b48c98fa754a1eb6dcfe35220016c74 (diff) | |
download | scala-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')
-rw-r--r-- | test/files/run/t6370.scala | 12 |
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") + } + + } +} |