diff options
author | Lex Spoon <lex@lexspoon.org> | 2007-04-19 02:50:36 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2007-04-19 02:50:36 +0000 |
commit | e43c7bef06d64b98f00752bd06510768ba37910a (patch) | |
tree | 5173077228071a7105a18048411cde80a738d7d2 /test/files/run | |
parent | 81cc9a834ceacb02fa7ec933708f6513248becd7 (diff) | |
download | scala-e43c7bef06d64b98f00752bd06510768ba37910a.tar.gz scala-e43c7bef06d64b98f00752bd06510768ba37910a.tar.bz2 scala-e43c7bef06d64b98f00752bd06510768ba37910a.zip |
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/interpreter.check | 135 | ||||
-rw-r--r-- | test/files/run/interpreter.scala | 86 |
2 files changed, 221 insertions, 0 deletions
diff --git a/test/files/run/interpreter.check b/test/files/run/interpreter.check new file mode 100644 index 0000000000..2440be2cad --- /dev/null +++ b/test/files/run/interpreter.check @@ -0,0 +1,135 @@ +This is an interpreter for Scala. +Type in expressions to have them evaluated. +Type :help for more information. + +scala> +scala> +scala> unnamed0: scala.Int = 7 + +scala> | | | | gcd: (int,int)int + +scala> five: int = 5 + +scala> x: scala.Int = 1 + +scala> x: scala.Int = 2 + +scala> three: scala.Int = 3 + +scala> defined type alias anotherint + +scala> four: anotherint = 4 + +scala> <console>:5: error: type mismatch; + found : java.lang.String("hello") + required: $iw.$iw.anotherint +val bogus: anotherint = "hello" + ^ + +scala> defined trait PointlessTrait + +scala> +scala> +scala> defined class Foo + +scala> defined class Bar + +scala> foo2bar: (Foo)Bar + +scala> bar: Bar = Bar(3) + +scala> +scala> +scala> import bar._ + +scala> m: int = 3 + +scala> +scala> +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> one: scala.Int = 1 + +scala> +scala> +scala> x1: scala.Int = 1 + +scala> x2: scala.Int = 1 + +scala> x3: scala.Int = 1 + +scala> x4: scala.Int = 1 + +scala> x5: scala.Int = 1 + +scala> x6: scala.Int = 1 + +scala> x7: scala.Int = 1 + +scala> x8: scala.Int = 1 + +scala> x9: scala.Int = 1 + +scala> x10: scala.Int = 1 + +scala> x11: scala.Int = 1 + +scala> x12: scala.Int = 1 + +scala> x13: scala.Int = 1 + +scala> x14: scala.Int = 1 + +scala> x15: scala.Int = 1 + +scala> x16: scala.Int = 1 + +scala> x17: scala.Int = 1 + +scala> x18: scala.Int = 1 + +scala> x19: scala.Int = 1 + +scala> x20: scala.Int = 1 + +scala> +scala> two: scala.Int = 2 + +scala> +scala>
\ No newline at end of file diff --git a/test/files/run/interpreter.scala b/test/files/run/interpreter.scala new file mode 100644 index 0000000000..8c06d4c70d --- /dev/null +++ b/test/files/run/interpreter.scala @@ -0,0 +1,86 @@ +import scala.tools.nsc._ +import java.io.{BufferedReader, StringReader, PrintWriter} + +object Test { + val testCodeString = <code> +// basics +3+4 +def gcd(x: int, y: int): int = {{ + if (x == 0) y + else if (y == 0) x + else gcd(y%x, x) +}} +val five = gcd(15,35) +var x = 1 +x = 2 +val three = x+1 +type anotherint = Int +val four: anotherint = 4 +val bogus: anotherint = "hello" +trait PointlessTrait + +// implicit conversions +case class Foo(n: int) +case class Bar(n: int) +implicit def foo2bar(foo: Foo) = Bar(foo.n) +val bar: Bar = Foo(3) + +// importing from a previous result +import bar._ +val m = n + +// stressing the imports mechanism +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 + + +val x1 = 1 +val x2 = 1 +val x3 = 1 +val x4 = 1 +val x5 = 1 +val x6 = 1 +val x7 = 1 +val x8 = 1 +val x9 = 1 +val x10 = 1 +val x11 = 1 +val x12 = 1 +val x13 = 1 +val x14 = 1 +val x15 = 1 +val x16 = 1 +val x17 = 1 +val x18 = 1 +val x19 = 1 +val x20 = 1 + +val two = one + x5 + +</code>.text + + + def main(args: Array[String]) { + val input = new BufferedReader(new StringReader(testCodeString)) + val repl = new InterpreterLoop(input, new PrintWriter(Console.out)) + repl.main(new Settings) + } +} |