summaryrefslogtreecommitdiff
path: root/test/junit
Commit message (Collapse)AuthorAgeFilesLines
* SI-8988 Escaping character in StringLike.split(c) prevents usage of ↵Denton Cockburn2015-01-091-0/+37
| | | | | | | | | | | | optimized String.split code path Escaping a char when calling split is slow. We end up compiling a Pattern to simply match a character literal. Instead, we just use an loop with indexOf to construct our resulting Array. Current speed up over old behaviour is about 12-1
* SI-9043 ArrayBuffer.insert and insertAll are very slowDenton Cockburn2014-12-141-0/+36
| | | | | | | | | | | | | | | | | | | | insert and insertAll were slower than their java equivalents by factors of 5 and 10 respectively. Benchmark code was provided here: https://gist.github.com/rklaehn/3e9290118fcf63d1feae We are using a toList to the source Traversable Then doing a length and a copy on that collection. By using an array, we can make use of faster methods. Managed to get the ratios down to 1.5 and 1.5 respectively. In addition to this, I think we should consider breaking insert into 2 separate methods, one for a single item and one for a collection. The varags version is very expensive when a single item is being inserted. @phaller @axel22
* Merge pull request #4176 from mpociecha/flat-classpath2Grzegorz Kossakowski2014-12-055-5/+538
|\ | | | | The alternative, flat representation of classpath elements
| * Add benchmarks to compare recursive and flat cp representationsmpociecha2014-12-051-0/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of these changes is to add possibility to: - compare an efficiency and a content of both cp implementations (ClassPathImplComparator) - examine the memory consumption by creating a lot of globals using a specified classpath (ClassPathMemoryConsumptionTester) - it can be considered as e.g. some approximation of ScalaPresentationCompilers in Scala IDE when working with many projects ClassPathMemoryConsumptionTester is placed in main (I mean not test) sources so thanks to that it has properly, out of the box configured boot classpath etc. and it's easy to use it, e.g.: scala scala.tools.nsc.ClassPathMemoryConsumptionTester -YclasspathImpl:<implementation_to_test> -cp <some_cp> -sourcepath <some_sp> -requiredInstances 50 SomeFileToCompile.scala At the end it waits for the "exit" command so there can be used some profiler like JProfiler to look how the given implementation behaves. Also flat classpath implementation is set as a default one to test it on Jenkins. This particular change must be reverted when all tests will pass because for now it's not desirable to make it permanently the default representation.
| * Cleanup and refactoring - semicolons, unused or commented out codempociecha2014-12-052-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit contains some minor changes made by the way when implementing flat classpath. Sample JUnit test that shows that all pieces of JUnit infrastructure work correctly now uses assert method form JUnit as it should do from the beginning. I removed commented out lines which were obvious to me. In the case of less obvious commented out lines I added TODOs as someone should look at such places some day and clean them up. I removed also some unnecessary semicolons and unused imports. Many string concatenations using + have been changed to string interpolation. There's removed unused, private walkIterator method from ZipArchive. It seems that it was unused since this commit: https://github.com/scala/scala/commit/9d4994b96c77d914687433586eb6d1f9e49c520f However, I had to add an exception for the compatibility checker because it was complaining about this change. I made some trivial corrections/optimisations like use 'findClassFile' method instead of 'findClass' in combination with 'binary' to find the class file.
| * Integrate flat classpath with the compilermpociecha2014-12-051-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit integrates with the compiler the whole flat classpath representation build next to the recursive one as an alternative. From now flat classpath really works and can be turned on. There's added flag -YclasspathImpl with two options: recursive (the default one) and flat. It was needed to make the dynamic dispatch to the particular classpath representation according to the chosen type of a classpath representation. There's added PathResolverFactory which is used instead of a concrete implementation of a path resolver. It turned out that only a small subset of path resolvers methods is used outside this class in Scala sources. Therefore, PathResolverFactory returns an instance of a base interface PathResolverResult providing only these used methods. PathResolverFactory in combination with matches in some other places ensures that in all places using classpath we create/get the proper representation. Also the classPath method in Global is modified to use the dynamic dispatch. This is very important change as a return type changed to the base ClassFileLookup providing subset of old ClassPath public methods. It can be problematic if someone was using in his project the explicit ClassPath type or public methods which are not provided via ClassFileLookup. I tested flat classpath with sbt and Scala IDE and there were no problems. Also was looking at sources of some other projects like e.g. Scala plugin for IntelliJ and there shouldn't be problems, I think, but it would be better to check these changes using the community build. Scalap's Main.scala is changed to be able to use both implementations and also to use flags related to the classpath implementation. The classpath invalidation is modified to work properly with the old (recursive) classpath representation after changes made in a Global. In the case of the attempt to use the invalidation for the flat cp it just throws exception with a message that the flat one currently doesn't support the invalidation. And also that's why the partest's test for the invalidation has been changed to use (always) the old implementation. There's added an adequate comment with TODO to this file. There's added partest test generating various dependencies (directories, zips and jars with sources and class files) and testing whether the compilation and further running an application works correctly, when there are these various types of entries specified as -classpath and -sourcepath. It should be a good approximation of real use cases.
| * Create dedicated path resolver for the flat classpath representationmpociecha2014-11-301-0/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds dedicated FlatClassPathResolver loading classpath entries as FlatClassPath. Most of the common logic from PathResolver for the old classpath has been moved to the base, separate class which isn't dependent on a particular classpath representation. Thanks to that it was possible to reuse it when creating an adequate path resolver for the flat classpath representation. This change doesn't modify the way the compiler works. It also doesn't change nothing from the perspective of someone who already uses PathResolver in some project or even extends it - at least as long as he/she doesn't need to use flat classpath. There are also added JUnit tests inter alia comparing entries created using the old and the new classpath representations (whether the flat one created using the new path resolver returns the same entries as the recursive one).
| * Add the flat classpath type aggregating flat classpath instancesmpociecha2014-11-301-0/+208
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's added AggregateFlatClassPath - an equivalent of MergedClassPath from the old implementation. It is supposed to group classpath instances handling different files being directories, zips or jars. Unlike in the case of the old (recursive) implementation, there won't be a deep, nested hierarchy of classpath instances - just one root (aggregate) and a flat structure of its children. AggregateFlatClassPath ensures the distinction of classpath entries and merges corresponding entries for class and source files into one entry. This is required as SymbolLoaders class makes use of this kind of ClassRepresentation. There are also added unit tests which check whether AggregateFlatClassPath obtains correct entries from classpath instances specified in a constructor and whether it preserves the ordering in the case of repeated entries. There's added a test type of flat classpath using VirtualFiles so it's easy to check the real behaviour.
* | Merge pull request #4141 from Ichoran/issue/8970Lukas Rytz2014-12-041-0/+6
|\ \ | | | | | | SI-8970 hashCode of BigDecimal and Double do not match
| * | SI-8970 hashCode of BigDecimal and Double do not matchRex Kerr2014-11-211-0/+6
| |/ | | | | | | | | | | Switched isValidDouble (binary equivalence) to isDecimalDouble (decimal expansion equivalence), as people generally do not care about the slew of extra decimal digits off the end of the binary approximation to a decimal fraction (decimal equivalence is the standard now). Added minimal unit test to verify behavior.
* | Merge pull request #4146 from Ichoran/issue/6519Lukas Rytz2014-12-041-3/+15
|\ \ | | | | | | SI-6519 PagedSeq is not lazy enough
| * | SI-6519 PagedSeq is not lazy enoughRex Kerr2014-11-211-3/+15
| |/ | | | | | | | | | | This was actually an issue with `length` of all things--it wasn't stopping scanning when it was past the end of what was requested. It'd just gratuitously read everything. Also fixed an overflow bug with isDefinedAt along the way (start + index > Int.MaxValue would always return true despite never working).
* / SI-8924 don't hold reference to list in iteratorMaxim Valyanskiy2014-11-271-0/+49
|/ | | | | | | | | | Current implementation of LinearSeqLike.iterator holds reference to complete sequence. This prevent garbage collecting of List elements while we keep reference to iterator somewhere. This commit removes reference from Iterator implementation. This allow garbage collection of List while we iterating over its elements (when there is no other references to List in our program).
* Merge pull request #4075 from som-snytt/issue/8835-junitGrzegorz Kossakowski2014-11-172-3/+150
|\ | | | | SI-8835 Iterator tests can be junit
| * SI-8835 Update iterator testsSom Snytt2014-11-131-50/+35
| | | | | | | | | | | | | | | | Addressing feedback from the collections test czar, updated a few of the primitive tests. Avoided testing addition and just asserted. Updated indexOf test to test Iterator.indexOf.
| * SI-8835 Iterator tests can be junitSom Snytt2014-11-112-3/+165
| | | | | | | | | | | | | | | | | | | | Without loss of generality or convenience, but helps reduce the number of files in test/files and may reduce compile times for test suite. This commit includes the fix from #3963 and an extra test of that fix that ensures the stack doesn't grow on chained drops.
* | SI-8932 Fix dropRight/takeRight implementationsRui Gonçalves2014-11-114-0/+73
|/ | | | | | | | I looked up at all the overrides of `IterableLike#takeRight` and `IterableLike#dropRight` and replaced usages of its argument `n` with `math.max(n, 0)` every time it was being used in an index subtraction. Fixes [SI-8932](https://issues.scala-lang.org/browse/SI-8932).
* Merge pull request #4088 from lrytz/opt/cleanupOptimizationsLukas Rytz2014-11-108-68/+554
|\ | | | | GenBCode: cleanup optimizations
| * Address review commentsLukas Rytz2014-11-071-1/+1
| |
| * GenBCode: Compact local variable slotsLukas Rytz2014-11-041-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After eliminating unreachable code, there may be unused local varaible slots. Such gaps increase the method's frame size unnecessarily. The optimization does not attempt to re-use the same local variable slot for non-overlapping locals (proper register allocation): def f(b: Boolean) = if (b) { val x = e; x } else { val y = e; y } x and y will not use the same slot, even though they could. This was originally implemented by Miguel in https://github.com/lrytz/scala/commit/09c40359338f8770e4f99d045999af062112973e
| * GenBCode: Tests for combined method-level optimizationsLukas Rytz2014-11-042-0/+88
| |
| * GenBCode: Command-line flags for enabling cleanup optimizationsLukas Rytz2014-11-046-85/+81
| | | | | | | | | | | | | | | | | | | | Add command-line flags `Yopt:...` for simplifying jumps, eliminating stale line number and label nodes. `LocalOpt.methodOptimizations` applies all enabled intra-method optimizations in the right order. Some cleanups for unreachable code elimination and its tests.
| * GenBCode: Eliminate redundant labels and line number nodesLukas Rytz2014-11-041-0/+101
| | | | | | | | | | | | | | | | | | Cleanup optimizations - remove line number nodes that describe no executable instructions - squash sequences of label nodes, remove unreferenced labels Command-line flags that allow enabling these transformations are added in a later comimt.
| * GenBCode: Simplify branching instructionsLukas Rytz2014-11-041-0/+221
| | | | | | | | | | | | | | | | | | | | This commit implements simplifications to branching instructions, for example `CondJump l; GOTO l` is replaced by `POP; GOTO l`. The individual optimizations are explained in doc comments. A later commit will add compiler flags to allow enabling the new optimizations.
* | Merge pull request #4083 from retronym/ticket/8947Jason Zaugg2014-11-071-0/+12
|\ \ | | | | | | SI-8947 Avoid cross talk between tag materializers and reify
| * | SI-8947 Avoid cross talk between tag materializers and reifyJason Zaugg2014-10-301-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a macro has been expanded, the expandee are expansion are bidirectionally linked with tree attachments. Reify uses the back reference to replace the expansion with the expandee in the reified tree. It also has some special cases to replace calls to macros defined in scala-compiler.jar with `Predef.implicitly[XxxTag[T]]`. This logic lives in `Reshape`. However, the expansion of a macro may be `EmptyTree`. This is the case when a tag materializer macro fails. User defined macros could do the also expand to `EmptyTree`. In the enclosed test case, the error message that the tag materializer issued ("cannot materialize class tag for unsplicable type") is not displayed as the typechecker finds another means of making the surrounding expression typecheck. However, the macro engine attaches a backreference to the materializer macro on `EmpytyTree`! Later, when `reify` reshapes a tree, every occurance of `EmptyTree` will be replaced by a call to `implicitly`. This commit expands the domain of `CannotHaveAttrs`, which is mixed in to `EmptyTree`. It silently ignores all attempts to mutate attachments. Unlike similar code that discards mutations of its type and position, I have refrained from issuing a developer warning in this case, as to silence this I would need to go and add a special case at any places adding attachments.
* | | Merge pull request #4017 from lrytz/t6541Lukas Rytz2014-11-051-0/+16
|\ \ \ | | | | | | | | SI-6541 valid wildcard existentials for case-module-unapply
| * | | Fix default value for ScalaVersionSettingLukas Rytz2014-11-041-0/+16
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default value was NoScalaVersion before, because tryToSet (where the default was supposed to be set) is not called at all if the option is not specified. The initial value of Xmigration is set to NoScalaVersion (which it was before, the AnyScalaVersion argument was ignored). AnyScalaVersion would be wrong, it would give a warning in `Map(1 -> "eis").values` if the option was not specified. See tests.
* | | Merge pull request #4046 from gourlaysama/wip/t8711-version-unparseLukas Rytz2014-11-041-0/+18
|\ \ \ | |_|/ |/| | SI-8711 ScalaVersion.unparse doesn't produce valid versions
| * | SI-8711 ScalaVersion.unparse doesn't produce valid versionsAntoine Gourlay2014-10-131-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no dot between `major.minor.rev` and `-build` in a scala version, yet that's what unparse returns for ``` // was "2.11.3.-SNAPSHOT" ScalaVersion("2.11.3-SNAPSHOT").unparse ```
* | | Merge pull request #4052 from Lymia/issue/8910Jason Zaugg2014-11-041-0/+22
|\ \ \ | | | | | | | | SI-8910 BitSet sometimes uses exponential memory.
| * | | SI-8910 BitSet sometimes uses exponential memory.Alissa Rao2014-10-151-0/+22
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because of an off-by-one error in scala.collection.mutable.BitSet, where a function (ensureCapacity) is passed a list length instead of an index, when ^=, &=, |=, or &~= are passed BitSets with the same internal capacity as the set the method is being invoked on, the size of the first BitSet is needlessly doubled. This patch simply changes the ensureCapacity calls to pass the last index of the list, instead of the raw length. In addition, add documentation to ensureCapacity to try and stop something similar from happening in the future.
* | | Merge pull request #4045 from gourlaysama/wip/t8875-show-codeJason Zaugg2014-11-041-0/+7
|\ \ \ | |_|/ |/| | SI-8875 showCode should print all class constructor modifiers.
| * | SI-8875 showCode should print all class constructor modifiers.Antoine Gourlay2014-10-241-0/+7
| |/ | | | | | | | | showCode used to print nothing when the only modifier was a change in visibility scope (i.e. no flags but privateWithin is set).
* | Merge pull request #4067 from lrytz/t8926Grzegorz Kossakowski2014-10-201-0/+41
|\ \ | | | | | | SI-8926 default visbility RUNTIME for java annotations
| * | SI-8926 default visbility RUNTIME for java annotationsLukas Rytz2014-10-201-0/+41
| |/ | | | | | | | | | | | | | | | | | | | | When parsed from source, java annotation class symbol are lacking the `@Retention` annotation. In mixed compilation, java annotations are therefore emitted with visibility CLASS. This patch conservatively uses the RUNTIME visibility in case there is no @Retention annotation. The real solution is to fix the Java parser, logged in SI-8928.
* / [nomerge] SI-8899 Revert "SI-8627 make Stream.filterNot non-eager"Lukas Rytz2014-10-121-18/+0
|/ | | | | | | | | This reverts commit 9276a1205f74fdec74206209712831913e93f359. The change is not binary compatible, See discussion on SI-8899. Making filterImpl non-private changes its call-sites (within TraversableLike) from INVOKESTATIC to INVOKEINTERFACE. Subclasses of TraversableLike compiled before this change don't have a mixin for filterImpl.
* Merge pull request #4030 from som-snytt/issue/8843Grzegorz Kossakowski2014-10-072-3/+141
|\ | | | | SI-8843 AbsFileCL acts like a CL
| * SI-8843 AbsFileCL acts like a CLSom Snytt2014-10-062-3/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let the AbstractFileClassLoader override just the usual suspects. Normal delegation behavior should ensue. That's instead of overriding `getResourceAsStream`, which was intended that "The repl classloader now works more like you'd expect a classloader to." (Workaround for "Don't know how to construct an URL for something which exists only in memory.") Also override `findResources` so that `getResources` does the obvious thing, namely, return one iff `getResource` does. The translating class loader for REPL only special-cases `foo.class`: as a fallback, take `foo` as `$line42.$read$something$foo` and try that class file. That's the use case for "works like you'd expect it to." There was a previous fix to ensure `getResource` doesn't take a class name. The convenience behavior, that `classBytes` takes either a class name or a resource path ending in ".class", has been promoted to `ScalaClassLoader`.
* | Merge pull request #4016 from lrytz/t8731Grzegorz Kossakowski2014-10-072-0/+42
|\ \ | |/ |/| SI-8731 warning if @switch is ignored
| * SI-8731 warning if @switch is ignoredLukas Rytz2014-10-062-0/+42
| | | | | | | | | | For matches with two or fewer cases, @switch is ignored. This should not happen silently.
* | Better ant / junit interactionAntoine Gourlay2014-09-2912-6/+3
|/ | | | | | | | | | | | | Currently junit test sources are always rebuilt, that's wasteful. The second dependency on the junit task is there so that the first can be skipped if sources haven't changed. Also normalize package names versus location in the `test/junit` folder: ant isn't very clever when it comes to selectively recompiling tests, so now editing a test will only cause that one to be recompiled (instead of ~13 files every time). This makes TDD with junit even faster.
* Get rid of Platform.doLoad method.Grzegorz Kossakowski2014-09-241-1/+0
| | | | Since .NET backend got removed this method is a no-op.
* Merge pull request #3941 from Ichoran/issue/8815Lukas Rytz2014-09-161-0/+15
|\ | | | | SI-8815 mutable.LongMap makes different choices for splitAt vs etc.
| * SI-8815 mutable.LongMap makes different choices for splitAt vs etc.Rex Kerr2014-09-111-0/+15
| | | | | | | | | | | | | | | | | | | | It turns out that take/drop/splitAt/takeWhile/dropWhile inherit a smattering of foreach vs. iterator-based implementations. These aren't consistent unless they iterate in the same order. This probably reflects an undesirable underlying weakness, but in this particular case it was easy to make LongMap's foreach order agree with iterator. Made traversal order of other foreach-like methods match also. Also fixed a bug where Long.MinValue wasn't iterated. Added unit test for iteration coverage of extreme values.
* | Remove stale local variables and exception handlers after DCELukas Rytz2014-09-105-7/+215
| | | | | | | | | | | | This is required for correctness of the generated bytecode. Exception handlers and local variable descriptors specify code offset ranges. These offsets have to exist, not be eliminated.
* | Clarify why we emit ATHROW after expressions of type NothingLukas Rytz2014-09-102-6/+50
| | | | | | | | Tests for emitting expressions of type Nothing.
* | Tools to run the compiler in JUnit testsLukas Rytz2014-09-102-0/+115
| |
* | JUnit tests for dead code elimination.Lukas Rytz2014-09-104-2/+199
|/ | | | JUnit tests may use tools from partest-extras (ASMConverters)
* Merge pull request #3946 from gourlaysama/wip/t5254Grzegorz Kossakowski2014-09-091-0/+23
|\ | | | | SI-5254 running an empty scala script should succeed