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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
import scala.tools.nsc.doc.model._
import scala.tools.nsc.doc.model.diagram._
import scala.tools.partest.ScaladocModelTest
object Test extends ScaladocModelTest {
override def code = """
package scala.test.scaladoc.SI5235 {
trait Builder[From, To]
/**
* @define Coll `GenericColl`
*/
class GenericColl {
/**
* @usecase def reverse(): $Coll
* Returns the reversed $Coll.
*/
def reverse[T](implicit something: Builder[GenericColl, T]): T
def foo1: GenericColl = ???
}
/** Nooo, don't point to this */
trait MyCollection
package specific {
/**
* @define Coll `BullSh`
*/
trait SpecificColl extends GenericColl {
def foo2: SpecificColl = ???
}
}
package mycoll {
/**
* @define Coll `mycoll.MyCollection`
*/
class MyCollection extends specific.SpecificColl {
def foo3: MyCollection = ???
}
}
}
"""
// diagrams must be started. In case there's an error with dot, it should not report anything
def scaladocSettings = ""
def testModel(rootPackage: Package) = {
// get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
import access._
val base = rootPackage._package("scala")._package("test")._package("scaladoc")._package("SI5235")
val GenericColl = base._class("GenericColl")
val SpecificColl = base._package("specific")._trait("SpecificColl")
val MyCollection = base._package("mycoll")._class("MyCollection")
// check comment text
val gcComment = extractCommentText(GenericColl._method("reverse").comment.get)
val scComment = extractCommentText(SpecificColl._method("reverse").comment.get)
val mcComment = extractCommentText(MyCollection._method("reverse").comment.get)
assert(gcComment.contains("Returns the reversed GenericColl."),
gcComment + ".contains(\"Returns the reversed GenericColl.\")")
assert(scComment.contains("Returns the reversed BullSh."),
scComment + ".contains(\"Returns the reversed BullSh.\")")
assert(mcComment.contains("Returns the reversed mycoll.MyCollection."),
mcComment + ".contains(\"Returns the reversed mycoll.MyCollection.\")")
// check signatures
val gcReverse = GenericColl._method("reverse")
val scReverse = SpecificColl._method("reverse")
val mcReverse = MyCollection._method("reverse")
val gcReverseType = gcReverse.resultType
val scReverseType = scReverse.resultType
val mcReverseType = mcReverse.resultType
assert(gcReverseType.name == "GenericColl", gcReverseType.name + " == GenericColl")
assert(scReverseType.name == "BullSh", scReverseType.name + " == BullSh")
assert(mcReverseType.name == "MyCollection",mcReverseType.name + " == MyCollection")
assert(gcReverseType.refEntity(0)._1 == GenericColl,
gcReverse.qualifiedName + "'s return type has a link to " + GenericColl.qualifiedName)
assert(scReverseType.refEntity.isEmpty,
scReverse.qualifiedName + "'s return type does not have links")
assert(mcReverseType.refEntity(0)._1 == MyCollection,
mcReverse.qualifiedName + "'s return type has a link to " + MyCollection.qualifiedName)
}
}
|