Skip to content

Commit 650f115

Browse files
Fix outstanding test failure.
1 parent bcc2b6e commit 650f115

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/main/scala/scala/collection/decorators/MapDecorator.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ class MapDecorator[C, M <: IsMap[C]](coll: C)(implicit val map: M) {
5959
*/
6060
def mergeByKeyWith[W, X, That](other: Map[map.K, W])(f: PartialFunction[(Option[map.V], Option[W]), X])(implicit bf: BuildFrom[C, (map.K, X), That]): That = {
6161
val b = bf.newBuilder(coll)
62-
val traversed = mutable.Set.empty[W]
62+
val traversed = mutable.Set.empty[map.K]
6363
val pf = f.lift
6464
for {
6565
(k, v) <- map(coll)
66-
x <- pf(other.get(k).fold[(Option[map.V], Option[W])]((Some(v), None)){ w => traversed += w; (Some(v), Some(w)) })
66+
x <- pf(other.get(k).fold[(Option[map.V], Option[W])]((Some(v), None)){ w => traversed += k; (Some(v), Some(w)) })
6767
} {
6868
b += k -> x
6969
}
7070
for {
71-
(k, w) <- other if !traversed(w)
71+
(k, w) <- other if !traversed(k)
7272
x <- pf((None, Some(w)))
7373
} {
7474
b += k -> x

src/test/scala/scala/collection/decorators/MapDecoratorTest.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class MapDecoratorTest {
130130
.sorted
131131
.sameElements(theirChanges.mergeByKey(ourChanges).values.toList.sorted))
132132

133-
Assert.assertEquals(ourChanges.mergeByKey(theirChanges).keySet, theirChanges
133+
Assert.assertEquals("Expect reflexivity on an outer join in terms of the keys.", ourChanges.mergeByKey(theirChanges).keySet, theirChanges
134134
.mergeByKey(ourChanges)
135135
.keys)
136136
}
@@ -153,22 +153,22 @@ class MapDecoratorTest {
153153

154154
ourChanges.mergeByKey(theirChangesRedux)
155155

156-
Assert.assertEquals("Expect all the keys to appear in an outer join, but they don't.", ourChanges.mergeByKey(theirChangesRedux).keys, allKeys)
156+
Assert.assertEquals("Expect all the keys to appear in an outer join.", ourChanges.mergeByKey(theirChangesRedux).keys, allKeys)
157157

158158
theirChangesRedux.mergeByKey(ourChanges)
159159

160-
Assert.assertEquals("Expect all the keys to appear in an outer join, and they do, good.", theirChangesRedux.mergeByKey(ourChanges).keys, allKeys)
160+
Assert.assertEquals("Expect all the keys to appear in an outer join.", theirChangesRedux.mergeByKey(ourChanges).keys, allKeys)
161161

162162
Assert.assertTrue("Expect the same associated values to appear in the join taken either way around, albeit swapped around and not necessarily in the same key order.",
163163
ourChanges
164-
.mergeByKey(theirChangesRedux)
165-
.values
166-
.map(_.swap)
167-
.toList
168-
.sorted
169-
.sameElements(theirChangesRedux.mergeByKey(ourChanges).values.toList.sorted))
170-
171-
Assert.assertEquals("Expect these to be equal, but they aren't.", ourChanges.mergeByKey(theirChangesRedux).keySet, theirChangesRedux
164+
.mergeByKey(theirChangesRedux)
165+
.values
166+
.map(_.swap)
167+
.toList
168+
.sorted
169+
.sameElements(theirChangesRedux.mergeByKey(ourChanges).values.toList.sorted))
170+
171+
Assert.assertEquals("Expect reflexivity on an outer join in terms of the keys.", ourChanges.mergeByKey(theirChangesRedux).keySet, theirChangesRedux
172172
.mergeByKey(ourChanges)
173173
.keys)
174174
}

0 commit comments

Comments
 (0)