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
|
package scala.tools.nsc
package symtab
import org.junit.Assert._
import scala.tools.testing.AssertUtil._
import org.junit.{Ignore, Test}
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@RunWith(classOf[JUnit4])
class StdNamesTest {
object symbolTable extends SymbolTableForUnitTesting
import symbolTable._
import nme.{SPECIALIZED_SUFFIX, unspecializedName, splitSpecializedName}
@Test
def testNewTermNameInvalid(): Unit = {
assertThrows[IllegalArgumentException](newTermName("foo".toCharArray, -1, 1))
}
@Test
def testNewTermNameNegativeLenght(): Unit = {
assertEquals(nme.EMPTY, newTermName("foo".toCharArray, 0, -1))
assertEquals(nme.EMPTY, newTermName("foo".toCharArray, 0, 0))
}
@Test
def testUnspecializedName(): Unit = {
def test(expected: Name, nme: Name) {
assertEquals(expected, unspecializedName(nme))
}
test(TermName("Tuple2"), TermName("Tuple2$mcII" + SPECIALIZED_SUFFIX))
test(TermName("foo"), TermName("foo$mIcD" + SPECIALIZED_SUFFIX))
test(TermName("foo"), TermName("foo$mIc" + SPECIALIZED_SUFFIX))
test(nme.EMPTY, TermName(s"T1$SPECIALIZED_SUFFIX"))
test(nme.EMPTY, SPECIALIZED_SUFFIX)
}
@Test
def testSplitSpecializedName(): Unit = {
def test(expected: (Name, String, String), nme: Name) {
assertEquals(expected, splitSpecializedName(nme))
}
test((TermName("Tuple2"), "II", ""), TermName("Tuple2$mcII" + SPECIALIZED_SUFFIX))
test((TermName("foo"), "D", "I"), TermName("foo$mIcD" + SPECIALIZED_SUFFIX))
test((TermName("foo"), "", "I"), TermName("foo$mIc" + SPECIALIZED_SUFFIX))
test((nme.EMPTY, "T1", ""), TermName(s"T1$SPECIALIZED_SUFFIX"))
test((nme.EMPTY, "", ""), SPECIALIZED_SUFFIX)
}
}
|