diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2011-01-24 19:17:32 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2011-01-24 19:17:32 +0000 |
commit | f253b67d4a50a066fb91ce03fa1eb12db9a9c1e0 (patch) | |
tree | 17921974620182355dab935e09f864a24cd5789d /test/files/presentation/find-trees/FindTrees.scala | |
parent | e07ca49a24d15ab1b279203ad208153a44732550 (diff) | |
download | scala-f253b67d4a50a066fb91ce03fa1eb12db9a9c1e0.tar.gz scala-f253b67d4a50a066fb91ce03fa1eb12db9a9c1e0.tar.bz2 scala-f253b67d4a50a066fb91ce03fa1eb12db9a9c1e0.zip |
Added presentation compiler tests.
Diffstat (limited to 'test/files/presentation/find-trees/FindTrees.scala')
-rw-r--r-- | test/files/presentation/find-trees/FindTrees.scala | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/files/presentation/find-trees/FindTrees.scala b/test/files/presentation/find-trees/FindTrees.scala new file mode 100644 index 0000000000..38ac2984c1 --- /dev/null +++ b/test/files/presentation/find-trees/FindTrees.scala @@ -0,0 +1,43 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest +import scala.tools.nsc.util.Position + + +/** Example interactive test that does everything by hand. It would be much simpler + * to just add the markers in the test file. This test shows how to drive + * the presentation compiler manually. + */ +object Test extends InteractiveTest { + + def askForPos(pos: Position) { + import compiler._ + val response = new Response[Tree] + + println("asking position at %d:%d".format(pos.line, pos.column)) + compiler.askTypeAt(pos, response) + response.get match { + case Left(EmptyTree) => + println("error retrieving tree at %d:%d".format(pos.line, pos.column)) + case Left(t) => + println("retrieved tree: " + t) + } + println(this.reporter.infos.mkString("\n")) + } + + override def runTest { + import compiler._ + val src = sourceFiles(0) // only one under src/ + val pos = rangePos(src, 426, 426, 433) + val pos1 = src.position(19, 15) + + // reload is issued already by the framework, but we can redo it here as an example + val reload = new Response[Unit] + compiler.askReload(List(src), reload) + reload.get // it's important to let reload finish before asking other things. + + askForPos(pos) + println("=" * 20) + askForPos(pos1) + + compiler.askShutdown() + } +} |