-
Notifications
You must be signed in to change notification settings - Fork 87
range methods on SortedSet / SortedMap #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
126f8fc
Move files to correct directory
lrytz 7c76007
Update 2.13 scala version to 2.13.0-pre-b11db01
lrytz 3e979ac
Sorted range methods
lrytz 8db6fdc
Move impls to private object
lrytz 9ac619f
Don't test mutable.SortedMap, as it's not on 2.11
lrytz acf9f39
Move tests to 'test' package
lrytz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...2.12/collection/compat_impl/package.scala → .../scala/collection/compat/CompatImpl.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/test/scala/collection/FactoryTest.scala → .../scala/scala/collection/FactoryTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...scala/collection/ImmutableArrayTest.scala → ...scala/collection/ImmutableArrayTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package collection | ||
package scala.collection | ||
|
||
import org.junit.{Assert, Test} | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
src/test/scala/collection/StreamTest.scala → ...t/scala/scala/collection/StreamTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package collection | ||
package scala.collection | ||
|
||
import org.junit.Test | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package scala.collection.generic | ||
|
||
import org.junit.Test | ||
import org.junit.Assert._ | ||
|
||
import scala.collection.compat._ | ||
import scala.collection.{immutable => i, mutable => m} | ||
|
||
class SortedTest { | ||
@Test | ||
def immutableRangeOps(): Unit = { | ||
val st = i.SortedSet(-1, 2, 4, 3) | ||
for (x <- List(0, 1, 4, -1, -4)) { | ||
val s1 = st.rangeFrom(x) | ||
assertEquals(s1: i.SortedSet[Int], st.from(x)) | ||
val s2 = st.rangeTo(x) | ||
assertEquals(s2: i.SortedSet[Int], st.to(x)) | ||
val s3 = st.rangeUntil(x) | ||
assertEquals(s3: i.SortedSet[Int], st.until(x)) | ||
} | ||
val mp = i.SortedMap("" -> 0, "ds" -> -3, "-??" -> 13, "Df" -> 33, "d!" -> -32) | ||
for (x <- List("", "-", "@", "aa", "D", "d")) { | ||
val m1 = mp.rangeFrom(x) | ||
assertEquals(m1: i.SortedMap[String, Int], mp.from(x)) | ||
val m2 = mp.rangeTo(x) | ||
assertEquals(m2: i.SortedMap[String, Int], mp.to(x)) | ||
val m3 = mp.rangeUntil(x) | ||
assertEquals(m3: i.SortedMap[String, Int], mp.until(x)) | ||
} | ||
} | ||
|
||
@Test | ||
def mutableRangeOps(): Unit = { | ||
val st = m.SortedSet(-1, 2, 4, 3) | ||
for (x <- List(0, 1, 4, -1, -4)) { | ||
val s1 = st.rangeFrom(x) | ||
assertEquals(s1: m.SortedSet[Int], st.from(x)) | ||
val s2 = st.rangeTo(x) | ||
assertEquals(s2: m.SortedSet[Int], st.to(x)) | ||
val s3 = st.rangeUntil(x) | ||
assertEquals(s3: m.SortedSet[Int], st.until(x)) | ||
} | ||
/* 2.11 doesn't have a mutable.SortedMap | ||
val mp = m.SortedMap("" -> 0, "ds" -> -3, "-??" -> 13, "Df" -> 33, "d!" -> -32) | ||
for (x <- List("", "-", "@", "aa", "D", "d")) { | ||
val m1 = mp.rangeFrom(x) | ||
assertEquals(m1: m.SortedMap[String, Int], mp.from(x)) | ||
val m2 = mp.rangeTo(x) | ||
assertEquals(m2: m.SortedMap[String, Int], mp.to(x)) | ||
val m3 = mp.rangeUntil(x) | ||
assertEquals(m3: m.SortedMap[String, Int], mp.until(x)) | ||
} | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no |
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially the tests were in the “empty” package. I moved them to the
collection
package just to not be in the empty package. However I’d rather not use thescala.collection
package because it implicitly imports everything that is in that package, whereas user code doesn’t do that usually. I think we should put the tests in a dummy package just to reproduce the same context as in user code. (And that would solve the issue withBitSet
shadowing)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll move them. What do you think about
test.scala.collection....
? Having them in_root_.collection
looked like an oversight.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good now.