Skip to content

Commit 95e270b

Browse files
author
Konrad Najder
committed
Added a test for invalid literal breaking the compiler
Whenever a non-compilable expression is the first thing evaluated after the Scala Compiler is created, all further expressions fail with a `scala.reflect.internal.FatalError: package scala does not have a member Nil`
1 parent 0543994 commit 95e270b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.avsystem.scex.compiler
2+
3+
import com.avsystem.scex.compiler.ScexCompiler.CompilationFailedException
4+
import com.avsystem.scex.japi.{DefaultJavaScexCompiler, JavaScexCompiler}
5+
import org.scalatest.funsuite.AnyFunSuite
6+
7+
class InvalidLiteralTest extends AnyFunSuite with CompilationTest {
8+
override protected def createCompiler: JavaScexCompiler = {
9+
val settings = new ScexSettings
10+
settings.classfileDirectory.value = "testClassfileCache"
11+
//evaluating getter adapters fixes the problem (since the invalid expression isn't the first thing compiled)
12+
settings.noGetterAdapters.value = true
13+
new DefaultJavaScexCompiler(settings)
14+
}
15+
16+
test("Invalid literal should not break the scex compiler") {
17+
intercept[CompilationFailedException] {
18+
evaluate[String]("11compilation_fail11")
19+
}
20+
assert("ok" == evaluate[String]("\"ok\""))
21+
}
22+
}

0 commit comments

Comments
 (0)