diff options
author | Vlad Ureche <vlad.ureche@gmail.com> | 2012-06-13 16:35:58 +0200 |
---|---|---|
committer | Vlad Ureche <vlad.ureche@gmail.com> | 2012-06-14 10:43:44 +0200 |
commit | 831f09bb6d00c152bd8aef3ce8bf9e200080fe36 (patch) | |
tree | 9959919ab28c10cbcaebd0f10932152e56abea16 /test/scaladoc/run/implicits-ambiguating.scala | |
parent | 1c2d466804b22f388ab4d66a034327539ac2e50f (diff) | |
download | scala-831f09bb6d00c152bd8aef3ce8bf9e200080fe36.tar.gz scala-831f09bb6d00c152bd8aef3ce8bf9e200080fe36.tar.bz2 scala-831f09bb6d00c152bd8aef3ce8bf9e200080fe36.zip |
Scaladoc class diagrams part 1
This commit contains model changes required for adding class diagrams
to scaladoc. It also contains an improved implicit shadowing
computation, which hides the shadowed implicitly inherited members
from the main view and gives instructions on how to access them.
This is joint work with Damien Obrist (@damienobrist) on supporting
diagram generation in scaladoc, as part of Damien's semester project
in the LAMP laborarory at EPFL.
The full history is located at:
https://github.com/damienobrist/scala/tree/feature/diagrams-dev
Commit summary:
- diagrams model
- diagram settings (Settings.scala, ScalaDoc.scala)
- diagram model object (Entity.scala, Diagram.scala)
- model: tracking direct superclasses and subclasses,
implicit conversions from and to (ModelFactory.scala)
- diagram object computation (DiagramFactory.scala, DocFactory.scala)
- capacity to filter diagrams (CommentFactory.scala,
DiagramDirectiveParser.scala)
- diagram statistics object (DiagramStats.scala)
- delayed link evaluation (Body.scala, Comment.scala)
- tests
- improved implicits shadowing information
- model shadowing computation (ModelFactoryImplicitSupport.scala,
Entity.scala)
- html generation for shadowing information (Template.scala)
- tests
Also fixes an issue reported by @dragos, where single-line comment
expansion would lead to the comment disappearing.
Review by @kzys, @pedrofurla.
Diffstat (limited to 'test/scaladoc/run/implicits-ambiguating.scala')
-rw-r--r-- | test/scaladoc/run/implicits-ambiguating.scala | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/test/scaladoc/run/implicits-ambiguating.scala b/test/scaladoc/run/implicits-ambiguating.scala new file mode 100644 index 0000000000..19e0f72b7b --- /dev/null +++ b/test/scaladoc/run/implicits-ambiguating.scala @@ -0,0 +1,111 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + // test a file instead of a piece of code + override def resourceFile = "implicits-ambiguating-res.scala" + + // start implicits + def scaladocSettings = "-implicits" + + def testModel(root: Package) = { + // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s)) + import access._ + + // SEE THE test/resources/implicits-chaining-res.scala FOR THE EXPLANATION OF WHAT'S CHECKED HERE: + val base = root._package("scala")._package("test")._package("scaladoc")._package("implicits")._object("ambiguating") + var conv1: ImplicitConversion = null + var conv2: ImplicitConversion = null + +//// class A /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + val A = base._class("A") + + conv1 = A._conversion(base._object("A").qualifiedName + ".AtoX") + conv2 = A._conversion(base._object("A").qualifiedName + ".AtoZ") + assert(conv1.members.length == 11) + assert(conv2.members.length == 11) + assert(conv1.constraints.length == 0) + assert(conv2.constraints.length == 0) + + /** - conv1-5 should be ambiguous + * - conv6-7 should not be ambiguous + * - conv8 should be ambiguous + * - conv9 should be ambiguous + * - conv10 and conv11 should not be ambiguous */ + def check1to9(cls: String): Unit = { + for (conv <- (1 to 5).map("conv" + _)) { + assert(conv1._member(conv).byConversion.get.isAmbiguous, cls + " - AtoX." + conv + " is ambiguous") + assert(conv2._member(conv).byConversion.get.isAmbiguous, cls + " - AtoZ." + conv + " is ambiguous") + } + for (conv <- (6 to 7).map("conv" + _)) { + assert(!conv1._member(conv).byConversion.get.isAmbiguous, cls + " - AtoX." + conv + " is not ambiguous") + assert(!conv2._member(conv).byConversion.get.isAmbiguous, cls + " - AtoZ." + conv + " is not ambiguous") + } + assert(conv1._member("conv8").byConversion.get.isAmbiguous, cls + " - AtoX.conv8 is ambiguous") + assert(conv2._member("conv8").byConversion.get.isAmbiguous, cls + " - AtoZ.conv8 is ambiguous") + assert(conv1._member("conv9").byConversion.get.isAmbiguous, cls + " - AtoX.conv9 is ambiguous") + assert(conv2._member("conv9").byConversion.get.isAmbiguous, cls + " - AtoZ.conv9 is ambiguous") + } + check1to9("A") + assert(!conv1._member("conv10").byConversion.get.isAmbiguous, "A - AtoX.conv10 is not ambiguous") + assert(!conv2._member("conv10").byConversion.get.isAmbiguous, "A - AtoZ.conv10 is not ambiguous") + assert(!conv1._member("conv11").byConversion.get.isAmbiguous, "A - AtoX.conv11 is not ambiguous") + assert(!conv2._member("conv11").byConversion.get.isAmbiguous, "A - AtoZ.conv11 is not ambiguous") + +//// class B /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + val B = base._class("B") + + conv1 = B._conversion(base._object("A").qualifiedName + ".AtoX") + conv2 = B._conversion(base._object("A").qualifiedName + ".AtoZ") + assert(conv1.members.length == 11) + assert(conv2.members.length == 11) + assert(conv1.constraints.length == 0) + assert(conv2.constraints.length == 0) + + /** conv1-9 should be the same, conv10 should be ambiguous, conv11 should be okay */ + check1to9("B") + assert(conv1._member("conv10").byConversion.get.isAmbiguous, "B - AtoX.conv10 is ambiguous") + assert(conv2._member("conv10").byConversion.get.isAmbiguous, "B - AtoZ.conv10 is ambiguous") + assert(!conv1._member("conv11").byConversion.get.isAmbiguous, "B - AtoX.conv11 is not ambiguous") + assert(!conv2._member("conv11").byConversion.get.isAmbiguous, "B - AtoZ.conv11 is not ambiguous") + +//// class C /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + val C = base._class("C") + + conv1 = C._conversion(base._object("A").qualifiedName + ".AtoX") + conv2 = C._conversion(base._object("A").qualifiedName + ".AtoZ") + assert(conv1.members.length == 11) + assert(conv2.members.length == 11) + assert(conv1.constraints.length == 0) + assert(conv2.constraints.length == 0) + + /** conv1-9 should be the same, conv10 and conv11 should not be ambiguous */ + check1to9("C") + assert(!conv1._member("conv10").byConversion.get.isAmbiguous, "C - AtoX.conv10 is not ambiguous") + assert(!conv2._member("conv10").byConversion.get.isAmbiguous, "C - AtoZ.conv10 is not ambiguous") + assert(!conv1._member("conv11").byConversion.get.isAmbiguous, "C - AtoX.conv11 is not ambiguous") + assert(!conv2._member("conv11").byConversion.get.isAmbiguous, "C - AtoZ.conv11 is not ambiguous") + +//// class D /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + val D = base._class("D") + + conv1 = D._conversion(base._object("A").qualifiedName + ".AtoX") + conv2 = D._conversion(base._object("A").qualifiedName + ".AtoZ") + assert(conv1.members.length == 11) + assert(conv2.members.length == 11) + assert(conv1.constraints.length == 0) + assert(conv2.constraints.length == 0) + + /** conv1-9 should be the same, conv10 should not be ambiguous while conv11 should be ambiguous */ + check1to9("D") + assert(!conv1._member("conv10").byConversion.get.isAmbiguous, "D - AtoX.conv10 is not ambiguous") + assert(!conv2._member("conv10").byConversion.get.isAmbiguous, "D - AtoZ.conv10 is not ambiguous") + assert(conv1._member("conv11").byConversion.get.isAmbiguous, "D - AtoX.conv11 is ambiguous") + assert(conv2._member("conv11").byConversion.get.isAmbiguous, "D - AtoZ.conv11 is ambiguous") + } +}
\ No newline at end of file |