diff options
Diffstat (limited to 'test/files/run/json.scala')
-rw-r--r-- | test/files/run/json.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/files/run/json.scala b/test/files/run/json.scala index 7b2b80718c..8ee8c347fd 100644 --- a/test/files/run/json.scala +++ b/test/files/run/json.scala @@ -7,8 +7,8 @@ object Test extends App { * toString comparison. */ def jsonToString(in : Any) : String = in match { case l : List[_] => "[" + l.map(jsonToString).mkString(", ") + "]" - case m : Map[String,_] => "{" + m.elements.toList - .sort({ (x,y) => x._1 < y._1 }) + case m : Map[String,_] => "{" + m.iterator.toList + .sortWith({ (x,y) => x._1 < y._1 }) .map({ case (k,v) => "\"" + k + "\": " + jsonToString(v) }) .mkString(", ") + "}" case s : String => "\"" + s + "\"" @@ -20,7 +20,7 @@ object Test extends App { */ def sortJSON(in : Any) : Any = in match { case l : List[_] => l.map(sortJSON) - case m : Map[String,_] => TreeMap(m.mapElements(sortJSON).elements.toSeq : _*) + case m : Map[String,_] => TreeMap(m.mapValues(sortJSON).iterator.toSeq : _*) // For the object versions, sort their contents, ugly casts and all... case JSONObject(data) => JSONObject(sortJSON(data).asInstanceOf[Map[String,Any]]) case JSONArray(data) => JSONArray(sortJSON(data).asInstanceOf[List[Any]]) @@ -62,7 +62,7 @@ object Test extends App { def stringDiff (expected : String, actual : String) { if (expected != actual) { // Figure out where the Strings differ and generate a marker - val mismatchPosition = expected.toList.zip(actual.toList).findIndexOf({case (x,y) => x != y}) match { + val mismatchPosition = expected.toList.zip(actual.toList).indexWhere({case (x,y) => x != y}) match { case -1 => Math.min(expected.length, actual.length) case x => x } |