summaryrefslogtreecommitdiff
path: root/test/files/run/t7398.scala
blob: e4090f7db3c112b279791d0ac62dff82647cf17e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import scala.tools.partest._

object Test extends CompilerTest {
  import global._

  def javaVersion = scala.util.Properties.javaVersion
  def isJavaEight = javaVersion startsWith "1.8"
  // This way we auto-pass on non-java8 since there's nothing to check
  override lazy val units = {
    val res: List[CompilationUnit]  = if (isJavaEight) javaCompilationUnits(global)(defaultMethodSource) else Nil
    val word = if (isJavaEight) "Attempting" else "Skipping"
    log(s"$word java8-specific test under java version $javaVersion")
    res
  }

  private def defaultMethodSource = """
public interface Iterator<E> {
    boolean hasNext();
    E next();
    default void remove() {
        throw new UnsupportedOperationException("remove");
    }
    default void forEachRemaining(Consumer<? super E> action) {
        throw new UnsupportedOperationException("forEachRemaining");
    }
}
  """

  // We're only checking we can parse it.
  def check(source: String, unit: global.CompilationUnit): Unit = ()
}