diff options
Diffstat (limited to 'test/files/run/t8918-unary-ids.scala')
-rw-r--r-- | test/files/run/t8918-unary-ids.scala | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/files/run/t8918-unary-ids.scala b/test/files/run/t8918-unary-ids.scala new file mode 100644 index 0000000000..3aa990f72c --- /dev/null +++ b/test/files/run/t8918-unary-ids.scala @@ -0,0 +1,49 @@ + + +import scala.tools.partest.SessionTest + +// Taking unary ids as plain +object Test extends SessionTest { + def session = +"""Type in expressions to have them evaluated. +Type :help for more information. + +scala> val - = 42 +-: Int = 42 + +scala> val i = - +i: Int = 42 + +scala> - { 42 } +res0: Int = -42 + +scala> - if (true) 1 else 2 +<console>:1: error: illegal start of simple expression +- if (true) 1 else 2 + ^ + +scala> - - 1 +<console>:1: error: ';' expected but integer literal found. +- - 1 + ^ + +scala> -.-(1) +res1: Int = 41 + +scala> - +res2: Int = 42 + +scala> - - +res3: Int = -42 + +scala> + - +res4: Int = 42 + +scala> object X { def -(i: Int) = 42 - i ; def f(g: Int => Int) = g(7) ; def j = f(-) } +defined object X + +scala> X.j +res5: Int = 35 + +scala> :quit""" +} |