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/dotc/core/testnames.sc | |
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/dotc/core/testnames.sc')
-rw-r--r-- | src/dotty/tools/dotc/core/testnames.sc | 29 |
1 files changed, 29 insertions, 0 deletions
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 |