summaryrefslogtreecommitdiff
path: root/test/files/run/coder2/Coder2.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/coder2/Coder2.scala')
-rw-r--r--test/files/run/coder2/Coder2.scala58
1 files changed, 29 insertions, 29 deletions
diff --git a/test/files/run/coder2/Coder2.scala b/test/files/run/coder2/Coder2.scala
index 7ecc5e67d1..abe284a398 100644
--- a/test/files/run/coder2/Coder2.scala
+++ b/test/files/run/coder2/Coder2.scala
@@ -77,7 +77,7 @@ class ParCoder(words: List[String]) {
* them e.g. `5282` -> List(`Java`, `Kata`, `Lava`, ...)
*/
val wordsForNum: Map[String, ParSeq[String]] =
- (words groupBy wordCode).map(t => (t._1, t._2.toParSeq)) withDefaultValue ParSeq()
+ (words groupBy wordCode).map(t => (t._1, t._2.toSeq.par)) withDefaultValue ParSeq()
val comparison = new SeqCoder(words)
@@ -85,7 +85,7 @@ class ParCoder(words: List[String]) {
def encode(number: String): ParSet[ParSeq[String]] =
if (number.isEmpty) ParSet(ParSeq())
else {
- val splits = (1 to number.length).toParSet
+ val splits = (1 to number.length).toSet.par
// for {
// split <- splits
// word <- wordsForNum(number take split)
@@ -118,7 +118,7 @@ class ParCoder(words: List[String]) {
def assertWfn(num: String, split: String, dropped: String, r: ParSeq[ParSeq[String]]) {
val m = comparison.wfnmemo((num, split))
- val rs = r.toParSet
+ val rs = r.toSet.par
val words: ParSeq[String] = wordsForNum(split)
if (rs != m) {
println("flatmap for number with split: " + num + ", " + split)
@@ -168,32 +168,32 @@ object Test {
/* */
def main(args : Array[String]) {
- // for (i <- 0 until 10) {
- // val seqcoder = new SeqCoder(Dictionary.wordlist)
- // val st = seqcoder.translate(code)
- // //println("Translation check: " + st.size)
-
- // val parcoder = new ParCoder(Dictionary.wordlist)
- // val pt = parcoder.translate(code)
- // //println("Translation check: " + pt.size)
-
- // // val st = sts.toList.sorted
- // // val pt = pts.toList.sorted
- // if (st.size != pt.size) {
- // // val zipped = st.zip(pt)
- // // val ind = zipped.indexWhere { case (a, b) => a != b }
- // // val sliced = zipped.slice(ind - 10, ind + 10)
- // // println(sliced.map(t => t._1 + "\n" + t._2 + "\n--------").mkString("\n"))
- // println(i + ") seq vs par: " + st.size + " vs " + pt.size)
- // }
- // if (st != pt) {
- // val zipped = (st.toList.sorted zip pt.toList.sorted);
- // val diffp = zipped indexWhere { case (x, y) => x != y }
- // println(zipped/*.slice(diffp - 10, diffp + 10)*/ mkString ("\n"))
- // println((st.toList.sorted zip pt.toList.sorted) map { case (x, y) => (x == y) } reduceLeft(_ && _))
- // }
- // assert(st == pt)
- // }
+ for (i <- 0 until 10) {
+ val seqcoder = new SeqCoder(Dictionary.wordlist)
+ val sts = seqcoder.translate(code)
+ //println("Translation check: " + st.size)
+
+ val parcoder = new ParCoder(Dictionary.wordlist)
+ val pts = parcoder.translate(code)
+ //println("Translation check: " + pt.size)
+
+ val st = sts.toList.sorted
+ val pt = pts.toList.sorted
+ if (st.size != pt.size) {
+ val zipped = st.zip(pt)
+ val ind = zipped.indexWhere { case (a, b) => a != b }
+ val sliced = zipped.slice(ind - 10, ind + 10)
+ //println(sliced.map(t => t._1 + "\n" + t._2 + "\n--------").mkString("\n"))
+ //println(i + ") seq vs par: " + st.size + " vs " + pt.size)
+ }
+ if (st != pt) {
+ val zipped = (st.toList.sorted zip pt.toList.sorted);
+ val diffp = zipped indexWhere { case (x, y) => x != y }
+ //println(zipped/*.slice(diffp - 10, diffp + 10)*/ mkString ("\n"))
+ //println((st.toList.sorted zip pt.toList.sorted) map { case (x, y) => (x == y) } reduceLeft(_ && _))
+ }
+ assert(st == pt)
+ }
}
}