summaryrefslogtreecommitdiff
path: root/test/scaladoc/run
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@gmail.com>2012-07-11 23:56:32 +0200
committerVlad Ureche <vlad.ureche@gmail.com>2012-07-16 23:41:44 +0200
commit0f2a0b7441153f3bdac49ca8878ffd9215458918 (patch)
tree7d8abd2e70c253c1d2d39fb811177e7859dbf31a /test/scaladoc/run
parentb651269275a4cfd72761586e088bff5a130949b5 (diff)
downloadscala-0f2a0b7441153f3bdac49ca8878ffd9215458918.tar.gz
scala-0f2a0b7441153f3bdac49ca8878ffd9215458918.tar.bz2
scala-0f2a0b7441153f3bdac49ca8878ffd9215458918.zip
Scaladoc: updated type class descriptions
The known type class descriptions give you a humanly-understandable explanation for [T: TypeClass] in the implicit conversions. For example [T: Integral] will tell you that T must be an integral type such as Integer and co. Now that the reflection dust settled, I can actually add the test to make sure the well-known type classes are intercepted and explanations are given instead of the usual "the type T is context-bounded by TypeClass"
Diffstat (limited to 'test/scaladoc/run')
-rw-r--r--test/scaladoc/run/implicits-known-type-classes.check1
-rw-r--r--test/scaladoc/run/implicits-known-type-classes.scala33
2 files changed, 34 insertions, 0 deletions
diff --git a/test/scaladoc/run/implicits-known-type-classes.check b/test/scaladoc/run/implicits-known-type-classes.check
new file mode 100644
index 0000000000..619c56180b
--- /dev/null
+++ b/test/scaladoc/run/implicits-known-type-classes.check
@@ -0,0 +1 @@
+Done.
diff --git a/test/scaladoc/run/implicits-known-type-classes.scala b/test/scaladoc/run/implicits-known-type-classes.scala
new file mode 100644
index 0000000000..9f4ca372b0
--- /dev/null
+++ b/test/scaladoc/run/implicits-known-type-classes.scala
@@ -0,0 +1,33 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+import language._
+
+object Test extends ScaladocModelTest {
+
+ // test a file instead of a piece of code
+ override def resourceFile = "implicits-known-type-classes-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._
+
+ /** Tests the "known type classes" feature of scaladoc implicits
+ * if the test fails, please update the correct qualified name of
+ * the type class in src/compiler/scala/tools/nsc/doc/Settings.scala
+ * in the knownTypeClasses map. Thank you! */
+
+ val base = root._package("scala")._package("test")._package("scaladoc")._package("implicits")._package("typeclasses")
+ var conv: ImplicitConversion = null
+
+ val A = base._class("A")
+
+ for (conversion <- A.conversions if !conversion.isCommonConversion) {
+ assert(conversion.constraints.length == 1, conversion.constraints.length + " == 1 (in " + conversion + ")")
+ assert(conversion.constraints.head.isInstanceOf[KnownTypeClassConstraint],
+ conversion.constraints.head + " is not a known type class constraint!")
+ }
+ }
+}