diff options
author | Martin Odersky <odersky@gmail.com> | 2013-02-28 15:03:01 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-02-28 15:03:15 +0100 |
commit | e2d8e2acf76472a2c9b60048be8260e1d73435ac (patch) | |
tree | a6e6ca69e6ffe1e643289c2483c55f63b38d48e1 /src/dotty/tools | |
parent | b1adda5e885880d95dd675a127349c4bc8376bb9 (diff) | |
download | dotty-e2d8e2acf76472a2c9b60048be8260e1d73435ac.tar.gz dotty-e2d8e2acf76472a2c9b60048be8260e1d73435ac.tar.bz2 dotty-e2d8e2acf76472a2c9b60048be8260e1d73435ac.zip |
Some worksheets to start testing
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/core/flagtest.sc | 22 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/periods.sc | 19 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/periodtest.sc | 20 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/testnames.sc | 29 |
4 files changed, 71 insertions, 19 deletions
diff --git a/src/dotty/tools/dotc/core/flagtest.sc b/src/dotty/tools/dotc/core/flagtest.sc new file mode 100644 index 000000000..f9de76b9e --- /dev/null +++ b/src/dotty/tools/dotc/core/flagtest.sc @@ -0,0 +1,22 @@ +package dotty.tools.dotc.core + +object flagtest { + println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet + + import Flags._ + + val pri = Private //> pri : dotty.tools.dotc.core.Flags.FlagSet = private + val pro = Protected //> pro : dotty.tools.dotc.core.Flags.FlagSet = protected + val pripro = pri | pro //> pripro : dotty.tools.dotc.core.Flags.FlagSet = private protected + pripro is pri //> res0: Boolean = true + pripro is pro //> res1: Boolean = true + pripro is Local //> res2: Boolean = false + val pp = allOf(pri, pro) //> pp : dotty.tools.dotc.core.Flags.FlagConjunction = private protected + pripro is pp //> res3: Boolean = true + pri is pp //> res4: Boolean = false + pri is pripro //> res5: Boolean = true + Method //> res6: dotty.tools.dotc.core.Flags.FlagSet = <method> + Abstract //> res7: dotty.tools.dotc.core.Flags.FlagSet = abstract + Method == Abstract //> res8: Boolean = false + Method.toCommonFlags //> res9: dotty.tools.dotc.core.Flags.FlagSet = <method> abstract +}
\ No newline at end of file diff --git a/src/dotty/tools/dotc/core/periods.sc b/src/dotty/tools/dotc/core/periods.sc deleted file mode 100644 index 395c7a2fe..000000000 --- a/src/dotty/tools/dotc/core/periods.sc +++ /dev/null @@ -1,19 +0,0 @@ -package dotty.tools.dotc.core - -import Periods._ - -object periods { - val rid = 223 - val p = periodOf(rid, 2) - val ivl = intervalOf(rid, 2, 4) - containsPeriod(ivl, p) - containsPeriod(ivl, periodOf(rid, 1)) - containsPeriod(ivl, periodOf(rid, 5)) - containsPeriod(ivl, periodOf(rid, 4)) - containsPeriod(ivl, periodOf(rid+1, 2)) - containsPeriod(ivl, periodOf(rid-1, 2)) - phaseIdOf(p) - phaseIdOf(ivl) - runIdOf(p) - containsPeriod(intervalOf(rid, 2, 2), p) -}
\ No newline at end of file diff --git a/src/dotty/tools/dotc/core/periodtest.sc b/src/dotty/tools/dotc/core/periodtest.sc new file mode 100644 index 000000000..38dccdfc3 --- /dev/null +++ b/src/dotty/tools/dotc/core/periodtest.sc @@ -0,0 +1,20 @@ +package dotty.tools.dotc.core + +object periodtest { + println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet + + import Periods._ + + val p1 = Period(1, 2, 7) //> p1 : dotty.tools.dotc.core.Periods.Period = dotty.tools.dotc.core.Periods$P + //| eriod@4e5 + val p2 = Period(1, 3, 7) //> p2 : dotty.tools.dotc.core.Periods.Period = dotty.tools.dotc.core.Periods$P + //| eriod@4e4 + p1 contains p2 //> res0: Boolean = true + p1 contains p1 //> res1: Boolean = true + p2 contains p1 //> res2: Boolean = false + p1 contains Period(0, 3, 3) //> res3: Boolean = false + p1 contains Period(2, 3, 3) //> res4: Boolean = false + p1 contains Nowhere //> res5: Boolean = false + p1 overlaps p1 //> res6: Boolean = true + Period(1, 2, 7) overlaps Period(1, 6, 9) //> res7: Boolean = true +}
\ No newline at end of file diff --git a/src/dotty/tools/dotc/core/testnames.sc b/src/dotty/tools/dotc/core/testnames.sc new file mode 100644 index 000000000..aa0493e9d --- /dev/null +++ b/src/dotty/tools/dotc/core/testnames.sc @@ -0,0 +1,29 @@ +package dotty.tools.dotc.core + +object testnames { + println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet + + import Names._ + + val n = termName("hello") //> n : dotty.tools.dotc.core.Names.TermName = hello + val tn = n.toTypeName //> tn : dotty.tools.dotc.core.Names.TypeName = hello + val ln = n.toLocalName //> ln : dotty.tools.dotc.core.Names.LocalName = hello + assert(tn.toTermName eq n) + assert(tn.toLocalName eq ln) + assert(n.toLocalName eq ln) + + n == tn //> res0: Boolean = false + n == ln //> res1: Boolean = false + n eq tn //> res2: Boolean = false + n.hashCode //> res3: Int = 0 + tn.hashCode //> res4: Int = 0 + val foo = encodedTermName("++") //> foo : dotty.tools.dotc.core.Names.TermName = $plus$plus + foo.hashCode //> res5: Int = 5 + foo.toTypeName.hashCode //> res6: Int = -5 + + val nfoo = n ++ foo //> nfoo : dotty.tools.dotc.core.testnames.n.ThisName = hello$plus$plus + nfoo contains '$' //> res7: Boolean = true + nfoo.replace('$', '.') //> res8: dotty.tools.dotc.core.testnames.nfoo.ThisName = hello.plus.plus + n == EmptyTermName //> res9: Boolean = false + EmptyTermName.start //> res10: Int = -1 +}
\ No newline at end of file |