aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-04-05 16:55:34 +0200
committerMartin Odersky <odersky@gmail.com>2013-04-05 16:55:34 +0200
commit7736cfb8ff8f5fafee87eb094f15627f4f097165 (patch)
tree601135fdb0c0fac1ba1061f3f4fe8502e6805bad
parent4ce196d8152f75163edb362fcd21fb37631b7fde (diff)
downloaddotty-7736cfb8ff8f5fafee87eb094f15627f4f097165.tar.gz
dotty-7736cfb8ff8f5fafee87eb094f15627f4f097165.tar.bz2
dotty-7736cfb8ff8f5fafee87eb094f15627f4f097165.zip
More tests in worksheets.
-rw-r--r--src/dotty/tools/dotc/core/Printers.scala6
-rw-r--r--test/test/DottyTest.scala4
-rw-r--r--test/test/SignatureTests.scala5
-rw-r--r--test/test/baseTypetest.sc27
-rw-r--r--test/test/denotTest.sc55
-rw-r--r--test/test/showClass.scala3
-rw-r--r--test/test/sigtest.sc17
7 files changed, 99 insertions, 18 deletions
diff --git a/src/dotty/tools/dotc/core/Printers.scala b/src/dotty/tools/dotc/core/Printers.scala
index e789e7db1..6e63eec3a 100644
--- a/src/dotty/tools/dotc/core/Printers.scala
+++ b/src/dotty/tools/dotc/core/Printers.scala
@@ -96,9 +96,9 @@ object Printers {
try {
ctx.toTextRecursions += 1
op
- } catch {
- case ex: CyclicReference =>
- s"<cycle involving ${ex.denot}>"
+// } catch {
+// case ex: CyclicReference =>
+// s"<cycle involving ${ex.denot}>"
} finally {
ctx.toTextRecursions -= 1
}
diff --git a/test/test/DottyTest.scala b/test/test/DottyTest.scala
index b5793a7eb..8057c0ad0 100644
--- a/test/test/DottyTest.scala
+++ b/test/test/DottyTest.scala
@@ -16,8 +16,8 @@ class DottyTest {
import base.settings._
val ctx = base.initialCtx.fresh
.withSetting(verbose, true)
- .withSetting(debug, true)
- .withSetting(debugTrace, true)
+// .withSetting(debug, true)
+// .withSetting(debugTrace, true)
.withSetting(Ylogcp, true)
.withSetting(printtypes, true)
.withSetting(pageWidth, 90)
diff --git a/test/test/SignatureTests.scala b/test/test/SignatureTests.scala
deleted file mode 100644
index 78f44aa60..000000000
--- a/test/test/SignatureTests.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-package test
-
-class SignatureTests extends DottyTest {
-
-} \ No newline at end of file
diff --git a/test/test/baseTypetest.sc b/test/test/baseTypetest.sc
new file mode 100644
index 000000000..350e503aa
--- /dev/null
+++ b/test/test/baseTypetest.sc
@@ -0,0 +1,27 @@
+package test
+
+import dotty.tools.dotc._
+import core._
+import Decorators._
+import Types._, Symbols._
+
+object baseTypetest extends DottyTest {
+ println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet
+ val int = defn.IntType //> int : dotty.tools.dotc.core.Types.Type = TypeRef(ThisType(module class scal
+ //| a),Int)
+ int.baseClasses //> res0: List[dotty.tools.dotc.core.Symbols.ClassSymbol] = List(class Int, clas
+ //| s AnyVal, class NotNull, class Any)
+ defn.StringClass.typeConstructor.baseClasses //> res1: List[dotty.tools.dotc.core.Symbols.ClassSymbol] = List(class String, c
+ //| lass CharSequence, class Comparable, class Serializable, class Object, class
+ //| Any)
+ defn.StringClass.typeConstructor.baseType(defn.ObjectClass)
+ //> res2: dotty.tools.dotc.core.Types.Type = TypeRef(ThisType(module class lang)
+ //| ,Object)
+ defn.StringClass.typeConstructor.baseType(defn.AnyClass)
+ //> res3: dotty.tools.dotc.core.Types.Type = TypeRef(ThisType(module class scala
+ //| ),Any)
+ defn.StringClass isSubClass defn.NullClass //> res4: Boolean = false
+ defn.StringClass.typeConstructor.baseType(defn.NullClass)
+ //> res5: dotty.tools.dotc.core.Types.Type = NoType
+
+} \ No newline at end of file
diff --git a/test/test/denotTest.sc b/test/test/denotTest.sc
new file mode 100644
index 000000000..939c51c01
--- /dev/null
+++ b/test/test/denotTest.sc
@@ -0,0 +1,55 @@
+package test
+
+import dotty.tools.dotc._
+import core._
+import Decorators._
+import Types._, Symbols._
+
+object denotTest extends DottyTest {
+ println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet
+
+ val str = defn.StringClass.typeConstructor //> str : dotty.tools.dotc.core.Types.TypeRef = TypeRef(ThisType(module class l
+ //| ang),String)
+ val d= str.member("getBytes".toTermName) //> d : dotty.tools.dotc.core.Denotations.Denotation = val getBytes <and> val g
+ //| etBytes <and> val getBytes <and> val getBytes
+ d.alternatives //> res0: List[dotty.tools.dotc.core.Denotations.SingleDenotation] = List(val ge
+ //| tBytes, val getBytes, val getBytes, val getBytes)
+ d.alternatives.map(_.info) //> res1: List[dotty.tools.dotc.core.Types.Type] = List(JavaMethodType(List(), L
+ //| ist(), RefinedType(TypeRef(ThisType(module class scala),Array), scala$Array$
+ //| $T, TypeAlias(TypeRef(ThisType(module class scala),Byte)) | hash = 777673561
+ //| )), JavaMethodType(List(x$0), List(TypeRef(ThisType(module class charset),Ch
+ //| arset)), RefinedType(TypeRef(ThisType(module class scala),Array), scala$Arra
+ //| y$$T, TypeAlias(TypeRef(ThisType(module class scala),Byte)) | hash = 7776735
+ //| 61)), JavaMethodType(List(x$0), List(TypeRef(ThisType(module class lang),Str
+ //| ing)), RefinedType(TypeRef(ThisType(module class scala),Array), scala$Array$
+ //| $T, TypeAlias(TypeRef(ThisType(module class scala),Byte)) | hash = 777673561
+ //| )), JavaMethodType(List(x$0, x$1, x$2, x$3), List(TypeRef(ThisType(module cl
+ //| ass scala),Int), TypeRef(ThisType(module class scala),Int), RefinedType(Type
+ //| Ref(ThisType(module class scala),Array), scala$Array$$T, TypeAlias(TypeRef(T
+ //| hisType(module class scala),Byte)) | hash = 777673561), TypeRef(ThisType(mod
+ //| ule class scala),Int)), TypeRef(ThisType(module class scala),Unit)))
+ val sm = defn.StringClass.companionModule //> sm : dotty.tools.dotc.core.Symbols.Symbol = module String
+ val d2 = sm.info.member("valueOf".toTermName) //> d2 : dotty.tools.dotc.core.Denotations.Denotation = val valueOf <and> val v
+ //| alueOf <and> val valueOf <and> val valueOf <and> val valueOf <and> val value
+ //| Of <and> val valueOf <and> val valueOf <and> val valueOf
+ d2.alternatives.map(_.info) //> res2: List[dotty.tools.dotc.core.Types.Type] = List(JavaMethodType(List(x$0)
+ //| , List(TypeRef(ThisType(module class scala),Double)), TypeRef(ThisType(modul
+ //| e class lang),String)), JavaMethodType(List(x$0), List(TypeRef(ThisType(modu
+ //| le class scala),Float)), TypeRef(ThisType(module class lang),String)), JavaM
+ //| ethodType(List(x$0), List(TypeRef(ThisType(module class scala),Long)), TypeR
+ //| ef(ThisType(module class lang),String)), JavaMethodType(List(x$0), List(Type
+ //| Ref(ThisType(module class scala),Int)), TypeRef(ThisType(module class lang),
+ //| String)), JavaMethodType(List(x$0), List(TypeRef(ThisType(module class scala
+ //| ),Char)), TypeRef(ThisType(module class lang),String)), JavaMethodType(List(
+ //| x$0), List(TypeRef(ThisType(module class scala),Boolean)), TypeRef(ThisType(
+ //| module class lang),String)), JavaMethodType(List(x$0, x$1, x$2), List(Refine
+ //| dType(TypeRef(ThisType(module class scala),Array), scala$Array$$T, TypeAlias
+ //| (TypeRef(ThisType(module class scala),Char)) | hash = 2075434073), TypeRef(T
+ //| hisType(module class scala),Int), TypeRef(ThisType(module class scala),Int))
+ //| , TypeRef(ThisType(module class lang),String)), JavaMethodType(List(x$0), Li
+ //| st(RefinedType(TypeRef(ThisType(module class scala),Array), scala$Array$$T,
+ //| TypeAlias(TypeRef(ThisType(module class scala),Char)) | hash = 2075434073)),
+ //| TypeRef(ThisType(module class lang),String)), JavaMethodType(List(x$0), Lis
+ //| t(TypeRef(ThisType(module class scala),Any)), TypeRef(ThisType(module class
+ //| lang),String)))
+} \ No newline at end of file
diff --git a/test/test/showClass.scala b/test/test/showClass.scala
index 39ffd496c..31bb87c02 100644
--- a/test/test/showClass.scala
+++ b/test/test/showClass.scala
@@ -6,7 +6,8 @@ object showClass extends ShowClassTests {
def main(args: Array[String]) = {
for (arg <- args) showPackage(ctx.requiredPackage(arg))
- showClasses("scala.reflect.runtime.SynchronizedOps")
+ showClasses("scala.collection.Traversable")
+ showClasses("scala.collection.generic.package")
// showPackage("scala.reflect")
// showPackage("scala")
println("done")
diff --git a/test/test/sigtest.sc b/test/test/sigtest.sc
index 44fa4f110..ed3793f1c 100644
--- a/test/test/sigtest.sc
+++ b/test/test/sigtest.sc
@@ -13,19 +13,22 @@ object sigtest extends DottyTest {
//| (TypeRef(ThisType(module class scala),Int)), TypeRef(ThisType(module class s
//| cala),Unit))
intmeth.signature //> res1: dotty.tools.dotc.core.Denotations.Signature = List(Int)
- val arraymeth = methType("x")(defn.ArrayType.appliedTo(int.symbolicRef))()
- //> arraymeth : dotty.tools.dotc.core.Types.MethodType = MethodType(List(x), Li
+ val arr = defn.ArrayType.appliedTo(int.symbolicRef)
+ //> arr : dotty.tools.dotc.core.Types.Type = RefinedType(TypeRef(ThisType(modul
+ //| e class scala),Array), scala$Array$$T, TypeAlias(TypeRef(ThisType(module cla
+ //| ss scala),Int)) | hash = 1907214242)
+ val arraymeth = methType("x")(arr)() //> arraymeth : dotty.tools.dotc.core.Types.MethodType = MethodType(List(x), Li
//| st(RefinedType(TypeRef(ThisType(module class scala),Array), scala$Array$$T,
- //| TypeAlias(TypeRef(ThisType(module class scala),Int)) | hash = -634207123)),
+ //| TypeAlias(TypeRef(ThisType(module class scala),Int)) | hash = 1907214242)),
//| TypeRef(ThisType(module class scala),Unit))
- arraymeth.signature //> res2: dotty.tools.dotc.core.Denotations.Signature = List(Object[])
+ arraymeth.signature //> res2: dotty.tools.dotc.core.Denotations.Signature = List(Int[])
val curriedmeth = methType("x", "y")(defn.IntType, defn.BooleanType)(methType("z")(defn.ArrayType.appliedTo(defn.IntType))())
//> curriedmeth : dotty.tools.dotc.core.Types.MethodType = MethodType(List(x, y
//| ), List(TypeRef(ThisType(module class scala),Int), TypeRef(ThisType(module c
//| lass scala),Boolean)), MethodType(List(z), List(RefinedType(TypeRef(ThisType
//| (module class scala),Array), scala$Array$$T, TypeAlias(TypeRef(ThisType(modu
- //| le class scala),Int)) | hash = -250095115)), TypeRef(ThisType(module class s
+ //| le class scala),Int)) | hash = 1808140099)), TypeRef(ThisType(module class s
//| cala),Unit)))
- curriedmeth.signature //> res3: dotty.tools.dotc.core.Denotations.Signature = List(Int, Boolean, Objec
- //| t[])
+ curriedmeth.signature //> res3: dotty.tools.dotc.core.Denotations.Signature = List(Int, Boolean, Int[]
+ //| )
} \ No newline at end of file