summaryrefslogtreecommitdiff
path: root/test/junit/scala/collection
Commit message (Collapse)AuthorAgeFilesLines
* SI-10187 Support mutation of mutable.HashMap in getOrElseUpdateJason Zaugg2017-03-031-0/+38
| | | | | | | | | | | | Scala 2.12.1 included optimizations to `HashMape.getOrElseUpdate` to avoid recomputing the index in the hash table when adding an the element. However, this index could be stale if the callback added elements to the map and triggered a resize. This commit checks that the table is unchanged before reusing the index, restoring the 2.12.0 behaviour.
* Merge branch '2.12.x' into merge-2.11.x-to-2.12.x-20170214Seth Tisue2017-02-172-3/+63
|\
| * Merge pull request #5697 from som-snytt/issue/10164Seth Tisue2017-02-171-3/+9
| |\ | | | | | | SI-10164 BitSet.tail zigs where it zagged
| | * SI-10164 BitSet.tail zigs where it zaggedSom Snytt2017-02-141-3/+9
| | | | | | | | | | | | | | | A cut/paste issue, an increment was held over from head, which scans forward, to tail, which scans backward.
| * | Merge pull request #5687 from retronym/ticket/10177Adriaan Moors2017-02-161-0/+54
| |\ \ | | |/ | |/| SI-10177 Override lazy operations to preserve TrieMap's semantics
| | * SI-10177 Override lazy operations to preserve TrieMap's semanticsJason Zaugg2017-02-101-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling .iterator on a TrieMap gives a read-only snapshot. This then extends to most inherited implementations written in terms of .iterator. However, some inherited methods, such as .values, either defer the call to .iterator or call it more than once. This results in subsequent mutations to the original map being visible I reviewed the inherited implementations from MapLike and found we needed overrides of `values`, `keySet`, `filterKeys`, and `mapValues`. Like `iterator`, these now create a read-only snapshot.
* | | Merge commit '0965028809' into merge-2.11.x-to-2.12.x-20170214Seth Tisue2017-02-161-0/+578
|\ \ \ | |/ / |/| |
| * | fix IndexedSeqTest to work in both Ant and sbtSeth Tisue2017-02-131-3/+14
| | | | | | | | | | | | | | | follows up on https://github.com/scala/scala/pull/5664; fixes https://github.com/scala/scala-dev/issues/301
| * | Test IndexedSeq, including ArrayOps, WrappedArray.Mike Skells2017-01-281-0/+567
| | | | | | | | | | | | Specifically, the `slice` and `take` methods.
| * | [Backport] Modify ArrayBuilder and WrappedArrayBuilder to be reusableMasaru Nomura2016-12-282-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As they're reusable in 2.12.x with this change[1], it'd be useful to make them reusable in 2.11.x. [1] https://github.com/scala/scala/commit/6eaae1b969b68ed3dc65a40613a8168b09246256 With this change, not only are they reusable but also we can avoid mutation of previously created arrays. Behaviour(Problem): Actual behaviour before this modification is as follows; <ArrayBuilder> ``` scala> import scala.collection.mutable.ArrayBuilder import scala.collection.mutable.ArrayBuilder scala> val builder = new ArrayBuilder.ofInt builder: scala.collection.mutable.ArrayBuilder.ofInt = ArrayBuilder.ofInt scala> builder ++= Vector.range(1, 17) res0: builder.type = ArrayBuilder.ofInt scala> val arr = builder.result() arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) scala> builder.clear() scala> builder += 100 res2: builder.type = ArrayBuilder.ofInt scala> val arr2 = builder.result() arr2: Array[Int] = Array(100) scala> arr res3: Array[Int] = Array(100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) // arr should be Array(1, .., 16) but was unexpectedly mutated by `+=` operation ``` `arr` was mutated as follows; 1. `result` & `clear` - `arr = elems` - `size = 0` 2. `+=(100)` - `ensureSize(0 + 1)` => `capacity < size || capacity == 0` is `false` as `capacity == 16` and `size == 1` - `elems(0) = 100` this is where `arr(0) = 100` was done because we did not reallocate a new array for `elems` when calling `ensureSize`, which should have happened. - `size = 1` 3. `result` - `mkArray(1)` gives us `arr2 = Array(100)` <WrappedArrayBuilder> We can observe almost the same mutation behaviour of ArrayBuilder. ``` scala> import scala.collection.mutable.WrappedArray import scala.collection.mutable.WrappedArray scala> import scala.collection.mutable.WrappedArrayBuilder import scala.collection.mutable.WrappedArrayBuilder scala> import scala.reflect.ClassTag import scala.reflect.ClassTag scala> val builder = new WrappedArrayBuilder(ClassTag.Int) builder: scala.collection.mutable.WrappedArrayBuilder[Int] = scala.collection.mutable.WrappedArrayBuilder@56cbfb61 scala> builder ++= Vector.range(1, 17) res0: builder.type = scala.collection.mutable.WrappedArrayBuilder@56cbfb61 scala> builder.result() res1: scala.collection.mutable.WrappedArray[Int] = WrappedArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) scala> builder.clear() scala> builder += 100 res3: builder.type = scala.collection.mutable.WrappedArrayBuilder@56cbfb61 scala> res1 res4: scala.collection.mutable.WrappedArray[Int] = WrappedArray(100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) scala> builder.result() res5: scala.collection.mutable.WrappedArray[Int] = WrappedArray(100) ``` Solution: We should reset `capacity` to `0` when calling `result` so that `ensureSize(1)` calls `resize(16)`, which satisfies the property of Builder reusability. Besides mutation of previously created arrays does not happen.
* | | SI-9507 Make Stream #:: and #::: allow type wideningRui Gonçalves2017-02-021-0/+6
| |/ |/|
* | SI-10113 mutable.TreeMap.range does not workEvgeny Slutsky2017-01-092-0/+54
| | | | | | | | added missing overrides for TreeMapView
* | SI-9936 LinearSeqOptimized.indexWhereSom Snytt2016-12-301-0/+19
| | | | | | | | | | | | Also suffered from the negative `from` bug. Prefer `math.max` to avoid `RichInt`.
* | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2016-12-201-0/+39
|\| | | | | | | | | | | | | | | | | | | merge/2.11.x-to-2.12.x-20161220 Conflicts: bincompat-backward.whitelist.conf build.xml src/compiler/scala/tools/nsc/typechecker/Typers.scala src/library/scala/collection/immutable/NumericRange.scala
| * SI-10086 NumericRange.min|max with custom Integral (#5575)Tobias Schlatter2016-12-121-0/+39
| | | | | | SI-10086 NumericRange.min|max with custom Integral
* | fixup! SI-10060 Fixes NumericRange.max bug on empty rangesTamer Mohammed Abdul-Radi2016-11-161-2/+14
| |
* | SI-10060 Fixes NumericRange.max bug on empty rangesTamer AbdulRadi2016-11-161-0/+30
| |
* | Merge pull request #5335 from rumoku/SI-9888Jason Zaugg2016-11-111-0/+15
|\ \ | | | | | | SI-9888. Prevent OOM on ParRange. Improve toString.
| * | SI-9888. Prevent OOM on ParRange. Improve toString.Vladimir Glushak2016-10-021-0/+15
| | |
* | | Merge commit 'b9a16c4' into 2.12.xJason Zaugg2016-11-081-0/+6
|\ \ \ | | |/ | |/|
| * | SI-9913 Lead span iterator finishes at state -1Som Snytt2016-09-051-0/+6
| | | | | | | | | | | | | | | Even if no elements fail the predicate (so that the trailing iterator is empty).
| * | Merge pull request #5167 from martijnhoekstra/SI-9766Lukas Rytz2016-05-231-0/+18
| |\ \ | | | | | | | | SI 9766 - allow ++ on empty ConcatIterator
| | * | SI-9766 - allow ++ on empty ConcatIteratorMartijn Hoekstra2016-05-211-0/+18
| | | |
* | | | Merge pull request #5400 from sjrd/rewrite-traversablelike-stringprefixSeth Tisue2016-10-201-5/+41
|\ \ \ \ | | | | | | | | | | Rewrite TraversableLike.stringPrefix not to blow up code size in Scala.js.
| * | | | Rewrite TraversableLike.stringPrefix not to blow up code size in Scala.js.Sébastien Doeraene2016-09-151-5/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit 30876fe2dd8cbe657a6cad6b11bbc34f10c29b36 changed `TraversableLike.stringPrefix` to report nicer results for inner classes and method-local classes. The changes included calls to `String.split()`, `Character.isDigit()` and `Character.isUpperCase()`. This was particularly bad for Scala.js, because those methods bring with them huge parts of the JDK (the `java.util.regex.*` implementation on the one hand, and the Unicode database on the other hand), which increased generated code size by 6 KB after minimification and gzip for an application that does not otherwise use those methods. This sudden increase is tracked in the Scala.js bug tracker at https://github.com/scala-js/scala-js/issues/2591. This commit rewrites `TraversableLike.stringPrefix` in a very imperative way, without resorting to those methods. The behavior is (mostly) preserved. There can be different results when `getClass().getName()` contains non-ASCII lowercase letters and/or digits. Those will now be recognized as user-defined instead of likely compiler-synthesized (which is a progression). There still are false positives for ASCII lowercase letters, which cause the `stringPrefix` to be empty (as before). Since the new implementation is imperative anyway, at least I made it not allocate anything but the result `String` in the common case where the result does not contain any `.`.
* | | | | Merge remote-tracking branch 'origin/2.12.0' into merge/2.12.0-to-2.12.xJason Zaugg2016-10-142-6/+3
|\ \ \ \ \
| * | | | | re-enable two tests (starr is up to date now)Lukas Rytz2016-09-302-6/+3
| |/ / / /
* / / / / SI-9936 SeqLike.indexWhere starts at zeroSom Snytt2016-09-261-0/+19
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This follows the Scaladoc, and makes ``` "abcdef".indexOf('c', -1) ``` work like ``` "abcdef".toVector.indexOf('c', -1) ```
* | | | Disable stack hungry test of deprecated PagedSeqJason Zaugg2016-09-011-1/+2
| | | |
* | | | SD-192 Change scheme for trait super accessorsJason Zaugg2016-08-151-1/+1
| |_|/ |/| | | | | | | | | | | | | | Rather than putting the code of a trait method body into a static method, leave it in the default method. The static method (needed as the target of the super calls) now uses `invokespecial` to exactly call that method.
* | | Merge pull request #5312 from szeiger/issue/8434-2Stefan Zeiger2016-08-121-0/+184
|\ \ \ | | | | | | | | SI-8434 Make generic Set operations build the same kind of Set
| * | | SI-8434 Make generic Set operations build the same kind of SetStefan Zeiger2016-08-121-0/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building from a `Set` implementation that was statically seen as a `collection.GenSet` or `collection.Set`, we used to build a default `Set` implementation determined by `GenSetFactory.setCanBuildFrom`. This change modifies `setCanBuildFrom` to determine the correct implementation at runtime by asking the source `Set`’s companion object for the `Builder`. Tests are in `NewBuilderTest.mapPreservesCollectionType`, including lots of disabled tests for which I believe there is no solution under the current collection library design. `Map` suffers from the same problem as `Set`. This *can* be fixed in the same way as for `Set` with some non-trivial changes (see the note in `NewBuilderTest`), so it is probably best left for Scala 2.13.
* | | | Merge pull request #5258 from szeiger/issue/9019Stefan Zeiger2016-08-121-0/+33
|\ \ \ \ | | | | | | | | | | SI-9019 TraversableLike stringPrefix broken for inner classes
| * | | | SI-9019 TraversableLike stringPrefix broken for inner classesRex Kerr2016-08-121-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This version preserves outer class and object names but discards any part of the name after a `$` that does not start with an upper-case letter. When an integer literal occurs after a `$`, the prefix up to that point is dropped so that classes defined within methods appear as top-level.
* | | | | Merge pull request #5259 from szeiger/issue/6881Stefan Zeiger2016-08-121-0/+10
|\ \ \ \ \ | |_|/ / / |/| | | | SI-6881 Detect reference equality when comparing streams
| * | | | SI-6881 Detect reference equality when comparing streamsStefan Zeiger2016-07-071-0/+10
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `==` already covers this case. We override `equals` in `Stream` to do the same when `equals` is called directly. This takes care of identical streams. To support short-circuiting equality checks on elements prepended to identical streams we also override `sameElements` in `Cons` to treat the case where both sides are `Cons` separately. Tests in StreamTest.test_reference_equality.
* / / / SI-9691 BufferedIterator should expose a headOptionChristopher Davenport2016-07-151-0/+28
|/ / / | | | | | | | | | This exposes a new API to the BufferedIterator trait. It will return the next element of an iterator as an Option. The return will be Some(value) if there is a next value, and None if there is not a next element.
* | | Merge commit '4196569' into merge-2.11-to-2.12-june-1Lukas Rytz2016-06-011-0/+48
|\| |
| * | SI-9688 Make merge in immutable HashMap1 work with null kv.Łukasz Gieroń2016-05-231-0/+48
| |/ | | | | | | | | | | | | | | The kv field of scala.collection.immutable.HashMap.HashMap1 can be null. This commit corrects the behavior of updated0 (which is on call path for merged) to work in such cases, instead of throwing NPE. Commit contains regression test.
* | SI-9767 document and test behaviour of String->integer/float conversionsMike Pheasant2016-06-011-0/+31
| | | | | | | | | | | | | | We delegate `String`'s extension methods `toInt`, `toFloat`, etc to corresponding methods in the Java standard library. These differ in the way they handle whitespace in the original string. This commit documents and tests the current behaviour.
* | Merge pull request #5191 from som-snytt/issue/9382Lukas Rytz2016-05-301-16/+0
|\ \ | | | | | | SI-9382 Privatize enhanced x in Tuple2Zipped.Ops
| * | SI-9382 Zippy clean-up in aisle 2 & 3Som Snytt2016-05-261-16/+0
| | | | | | | | | | | | | | | Consolated JUnit tests and heeded comment about private def and code beauty.
* | | SI-9522 release key reference when deleting from OpenHashMapPerformant Data LLC2016-05-241-1/+57
|/ / | | | | | | | | | | | | | | | | This sets the key field in the hash table entry to its default value when an entry is deleted, so as not to unexpectedly retain an object reference, leading to a memory leak. Also includes incidental changes to the slot location algorithm that reduce the number of deleted entries.
* | Adapt naming convention for collection.convert null safety testLukas Rytz2016-05-203-279/+286
| | | | | | | | | | | | | | Test classes not ending in "Test" are not executed in sbt. IntelliJ runs them. After this patch: 803 tests executed both in sbt and junit.
* | Merge pull request #5103 from ruippeixotog/improve-list-map-set-perfLukas Rytz2016-05-172-0/+101
|\ \ | | | | | | Improve performance and behavior of ListMap and ListSet
| * | Improve performance and behavior of ListMap and ListSetRui Gonçalves2016-05-172-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | Makes the immutable `ListMap` and `ListSet` collections more alike one another, both in their semantics and in their performance. In terms of semantics, makes the `ListSet` iterator return the elements in their insertion order, as `ListMap` already does. While, as mentioned in SI-8985, `ListMap` and `ListSet` doesn't seem to make any guarantees in terms of iteration order, I believe users expect `ListSet` and `ListMap` to behave in the same way, particularly when they are implemented in the exact same way. In terms of performance, `ListSet` has a custom builder that avoids creation in O(N^2) time. However, this significantly reduces its performance in the creation of small sets, as its requires the instantiation and usage of an auxilliary HashSet. As `ListMap` and `ListSet` are only suitable for small sizes do to their performance characteristics, the builder is removed, the default `SetBuilder` being used instead.
* | | test PriorityQueue.reverseArno den Hartog2016-05-021-0/+7
|/ /
* | SI-9684 Deprecate JavaConversionsSom Snytt2016-04-221-1/+1
| | | | | | | | | | | | | | | | | | Implicit conversions are now in package convert as ImplicitConversions, ImplicitConversionsToScala and ImplicitConversionsToJava. Deprecated WrapAsJava, WrapAsScala and the values in package object. Improve documentation.
* | Merge branch '2.11.x' into topic/merge-2.11.x-to-2.12.x-20160210Jason Zaugg2016-02-101-0/+28
|\| | | | | | | | | | | | | | | | | Conflicts: src/library/scala/collection/Iterator.scala | `-- trivial conflicts only. Parens were added to the next() calls in 2.12.x, while in the meantime `{Concat,Join}Iterator` were optimized in 2.11.x
| * SI-9623 Avoid unnecessary hasNext calls in JoinIterator & ConcatIteratorStefan Zeiger2016-02-011-0/+28
| | | | | | | | | | | | | | | | | | | | | | These iterator implementations are used to concatenate two (JoinIterator) or more (ConcatIterator) other iterators with `++`. They used to perform many unnecessary calls to the child iterators’ `hasNext` methods. This improved state machine-based implementation reduces that number to the bare minimum, i.e. iterating over concatenated iterators with `foreach` calls the children's `hasNext` methods a total of (number of children) + (number of elements) times, the same as when iterating over all children separately.