summaryrefslogtreecommitdiff
path: root/test/junit/scala/collection
diff options
context:
space:
mode:
authorSeth Tisue <seth@tisue.net>2016-10-20 21:22:44 -0700
committerGitHub <noreply@github.com>2016-10-20 21:22:44 -0700
commitaef9786669bb7bae4d46fd6edefb54e8fb0e6def (patch)
tree22edcbdec2f910566daa1ea49e8674c8a2b92ee1 /test/junit/scala/collection
parentaed4d942cbf19898ee6b7852358115305bd0a976 (diff)
parent44971d104f4364a0ddaa4f05afc4cc61ee39cdf7 (diff)
downloadscala-aef9786669bb7bae4d46fd6edefb54e8fb0e6def.tar.gz
scala-aef9786669bb7bae4d46fd6edefb54e8fb0e6def.tar.bz2
scala-aef9786669bb7bae4d46fd6edefb54e8fb0e6def.zip
Merge pull request #5400 from sjrd/rewrite-traversablelike-stringprefix
Rewrite TraversableLike.stringPrefix not to blow up code size in Scala.js.
Diffstat (limited to 'test/junit/scala/collection')
-rw-r--r--test/junit/scala/collection/TraversableLikeTest.scala46
1 files changed, 41 insertions, 5 deletions
diff --git a/test/junit/scala/collection/TraversableLikeTest.scala b/test/junit/scala/collection/TraversableLikeTest.scala
index 8588956016..f703abf3e4 100644
--- a/test/junit/scala/collection/TraversableLikeTest.scala
+++ b/test/junit/scala/collection/TraversableLikeTest.scala
@@ -5,29 +5,65 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+object TraversableLikeTest {
+ abstract class FakeIndexedSeq[A] extends IndexedSeq[A] {
+ def apply(i: Int): A = ???
+ def length: Int = 0
+ }
+}
+
@RunWith(classOf[JUnit4])
class TraversableLikeTest {
+ import TraversableLikeTest._
+
// For test_SI9019; out here because as of test writing, putting this in a method would crash compiler
class Baz[@specialized(Int) A]() extends IndexedSeq[A] {
def apply(i: Int) = ???
def length: Int = 0
}
-
+
@Test
def test_SI9019 {
object Foo {
def mkBar = () => {
- class Bar extends IndexedSeq[Int] {
- def apply(i: Int) = ???
- def length: Int = 0
- }
+ class Bar extends FakeIndexedSeq[Int]
new Bar
}
+
+ def mkFalsePositiveToSyntheticTest = () => {
+ /* A class whose name tarts with an ASCII lowercase letter.
+ * It will be a false positive to the synthetic-part test.
+ */
+ class falsePositive extends FakeIndexedSeq[Int]
+ new falsePositive
+ }
+
+ def mkFrench = () => {
+ // For non-French speakers, this means "strange class name"
+ class ÉtrangeNomDeClasse extends FakeIndexedSeq[Int]
+ new ÉtrangeNomDeClasse
+ }
+
+ def mkFrenchLowercase = () => {
+ class étrangeNomDeClasseMinuscules extends FakeIndexedSeq[Int]
+ new étrangeNomDeClasseMinuscules
+ }
}
+
val bar = Foo.mkBar()
assertEquals("Bar", bar.stringPrefix) // Previously would have been outermost class, TraversableLikeTest
val baz = new Baz[Int]()
assertEquals("TraversableLikeTest.Baz", baz.stringPrefix) // Make sure we don't see specialization $mcI$sp stuff
+
+ // The false positive unfortunately produces an empty stringPrefix
+ val falsePositive = Foo.mkFalsePositiveToSyntheticTest()
+ assertEquals("", falsePositive.stringPrefix)
+
+ val french = Foo.mkFrench()
+ assertEquals("ÉtrangeNomDeClasse", french.stringPrefix)
+
+ val frenchLowercase = Foo.mkFrenchLowercase()
+ assertEquals("étrangeNomDeClasseMinuscules", frenchLowercase.stringPrefix)
}
}