blob: f703abf3e47cb20ad3f12c955b5b9654b5a06fa0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
package scala.collection
import org.junit.Assert._
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 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)
}
}
|