diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2012-04-25 17:28:07 +0200 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2012-04-25 17:28:07 +0200 |
commit | 07ed42f07380aec06e5d0f65d69ce6826df39e2a (patch) | |
tree | 8140af3a4b0d56c57a202ca224fe99159dd427e4 /test/files | |
parent | 1d0372f84f9a7325a47beb55169cc454895ef74b (diff) | |
download | scala-07ed42f07380aec06e5d0f65d69ce6826df39e2a.tar.gz scala-07ed42f07380aec06e5d0f65d69ce6826df39e2a.tar.bz2 scala-07ed42f07380aec06e5d0f65d69ce6826df39e2a.zip |
Added a Presentation Compiler test for hyperlinking.
This test ensures hyperlinking works inside and around pattern matching. The new virtual pattern matcher
synthesizes trees that are not properly nested, and whose positions make it impossible to retrieve the correct
tree/symbol for a given position. Therefore, the current test is using the old pattern matcher. However,
once the virtual pattern matcher is fixed, remove the corresponding line from patmat.flags to re-enable virtpatmat.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/presentation/patmat.check | 36 | ||||
-rw-r--r-- | test/files/presentation/patmat.flags | 3 | ||||
-rw-r--r-- | test/files/presentation/patmat/Runner.scala | 11 | ||||
-rw-r--r-- | test/files/presentation/patmat/src/PatMatTests.scala | 28 |
4 files changed, 78 insertions, 0 deletions
diff --git a/test/files/presentation/patmat.check b/test/files/presentation/patmat.check new file mode 100644 index 0000000000..29fd8b8e68 --- /dev/null +++ b/test/files/presentation/patmat.check @@ -0,0 +1,36 @@ +reload: PatMatTests.scala + +askHyperlinkPos for `CaseOne` at (12,18) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `CaseOne` at (5,12) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `first` at (14,21) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `first` at (12,29) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `tmp` at (15,19) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `tmp` at (13,13) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `CaseTwo` at (17,18) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `CaseTwo` at (6,12) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `mystring` at (18,24) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `mystring` at (17,25) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `x` at (25,13) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `x` at (23,10) PatMatTests.scala +================================================================================ + +askHyperlinkPos for `y` at (25,21) PatMatTests.scala +================================================================================ +[response] found askHyperlinkPos for `y` at (23,13) PatMatTests.scala +================================================================================ diff --git a/test/files/presentation/patmat.flags b/test/files/presentation/patmat.flags new file mode 100644 index 0000000000..468b48c9e3 --- /dev/null +++ b/test/files/presentation/patmat.flags @@ -0,0 +1,3 @@ +# This test will fail in the new pattern matcher because +# it generates trees whose positions are not transparent +-Xoldpatmat diff --git a/test/files/presentation/patmat/Runner.scala b/test/files/presentation/patmat/Runner.scala new file mode 100644 index 0000000000..3d19f2d948 --- /dev/null +++ b/test/files/presentation/patmat/Runner.scala @@ -0,0 +1,11 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + override def runTests() { + // make sure typer is done.. the virtual pattern matcher might translate + // some trees and mess up positions. But we'll catch it red handed! + sourceFiles foreach (src => askLoadedTyped(src).get) + super.runTests() + } + +}
\ No newline at end of file diff --git a/test/files/presentation/patmat/src/PatMatTests.scala b/test/files/presentation/patmat/src/PatMatTests.scala new file mode 100644 index 0000000000..bbd0f2e7ed --- /dev/null +++ b/test/files/presentation/patmat/src/PatMatTests.scala @@ -0,0 +1,28 @@ +package patmat + +abstract class BaseType + +case class CaseOne(x: Int, y: List[Int]) extends BaseType +case class CaseTwo(str: String) extends BaseType + +class PatMatTests { + + def foo(x: BaseType) { + x match { + case CaseOne/*#*/(10, first :: second :: Nil) => + val tmp = 23 + println(first/*#*/) + println(tmp/*#*/) + + case CaseTwo/*#*/(mystring) => + println(mystring/*#*/) + } + } + + def multipleAssign() { + val (x, y) = ("abc", "def") + + println(x/*#*/, y/*#*/) + } + +}
\ No newline at end of file |