summaryrefslogtreecommitdiff
path: root/compiler/src/test/scala/scala/scalajs/compiler/test/PositionTest.scala
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/test/scala/scala/scalajs/compiler/test/PositionTest.scala')
-rw-r--r--compiler/src/test/scala/scala/scalajs/compiler/test/PositionTest.scala37
1 files changed, 37 insertions, 0 deletions
diff --git a/compiler/src/test/scala/scala/scalajs/compiler/test/PositionTest.scala b/compiler/src/test/scala/scala/scalajs/compiler/test/PositionTest.scala
new file mode 100644
index 0000000..e25399b
--- /dev/null
+++ b/compiler/src/test/scala/scala/scalajs/compiler/test/PositionTest.scala
@@ -0,0 +1,37 @@
+package scala.scalajs.compiler.test
+
+import util.JSASTTest
+
+import org.junit.Test
+import org.junit.Assert._
+
+import scala.reflect.internal.util.BatchSourceFile
+
+import scala.scalajs.ir.{Trees => js}
+
+class PositionTest extends JSASTTest {
+
+ @Test
+ def virtualFilePosition = {
+
+ val name = "<foo with illegal URI chars: %%>"
+ val source = new BatchSourceFile(name,
+ """class A { def x = 1 }""")
+
+ var found = false
+ sourceAST(source) traverse {
+ case lit: js.IntLiteral =>
+ found = true
+ assertEquals(
+ "Scheme of virtual file URI should be `virtualfile'",
+ "virtualfile", lit.pos.source.getScheme)
+ assertEquals(
+ "Scheme specific part of virtual file URI should be its path",
+ name, lit.pos.source.getSchemeSpecificPart)
+ }
+
+ assertTrue("Should have IntLiteral tree", found)
+
+ }
+
+}