-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add filtering by jvm version in TastyTest
- Loading branch information
1 parent
b0c8120
commit fa4c3df
Showing
12 changed files
with
175 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Scala (https://www.scala-lang.org) | ||
* | ||
* Copyright EPFL and Lightbend, Inc. | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package scala.tools.tastytest | ||
|
||
import scala.util.Using | ||
import scala.io.Source | ||
|
||
import SourceFile._ | ||
import scala.util.chaining._ | ||
|
||
final case class SourceFile(path: String) { | ||
lazy val options: Options = readOptions(path) | ||
} | ||
|
||
object SourceFile { | ||
|
||
private val directivePattern = raw"\s*//>\s+using\s+(\S+)(?:\s+(.*))?".r | ||
final case class Options(data: Map[String, Option[String]]) | ||
|
||
def readOptions(path: String): Options = | ||
Using.resource(Source.fromFile(path)) { source => | ||
source.getLines().takeWhile(_.trim.startsWith("//>")) | ||
.flatMap { | ||
case directivePattern(key, valueOrNull) => Some(key -> Option(valueOrNull)) | ||
case _ => None | ||
} | ||
.toMap | ||
.pipe(Options(_)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/tasty/run-pipelined/src-2/tastytest/TestRawTypes2.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//> using jvm 16+ | ||
package tastytest | ||
|
||
import lib.RawTypes2 | ||
|
||
/** Test definitions that only compile in Java 16+ */ | ||
object TestRawTypes2 extends scala.App { | ||
val rt: RawTypes2 = new RawTypes2() | ||
|
||
lazy val cd_is = new rt.C.DStatic[String]() // lazy because this fails at runtime even when reading from a classfile | ||
|
||
def foo1 = RawTypes2.mis_Raw_Raw(cd_is) // lazy because this fails at runtime even when reading from a classfile | ||
|
||
def foo2 = RawTypes2.mis_Raw_Gen(cd_is) // lazy because this fails at runtime even when reading from a classfile | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//> using jvm 16+ | ||
package lib; | ||
|
||
/** Contains C.DStatic, only allowed since JDK 16 */ | ||
public class RawTypes2 { | ||
|
||
public class C<T> { | ||
public static class DStatic<U> {} // illegal in Java < 16 | ||
} | ||
|
||
public static void mis_Raw_Raw(C.DStatic d) {} // illegal in Java < 16 | ||
public static void mis_Raw_Gen(C.DStatic<String> d) {} // illegal in Java < 16 | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package lib; | ||
|
||
public class SomeAnnotated { | ||
|
||
private static <T> T unimplemented() { | ||
return null; | ||
} | ||
|
||
@SomeAnnotation("hello") | ||
public static int method() { return 23; } | ||
|
||
@SomeAnnotation(value = "hello", year = 1996) | ||
public static int method2() { return 23; } | ||
|
||
@SomeAnnotation(value = "hello", year = 1996, classes = {long.class}) | ||
public static int method3() { return 23; } | ||
|
||
} |