Skip to content

Commit f2c7448

Browse files
authored
Merge pull request #3612 from dotty-staging/neg-tests
Fix #3581: Reorganise neg tests
2 parents eb2472d + 55c62c3 commit f2c7448

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+42
-40
lines changed

compiler/test/dotc/tests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class tests extends CompilerTest {
186186

187187
@Test def negVarargsT1625 = compileFiles(negDir + "varargsInMethodsT1625/")
188188

189-
val negCustomArgs = negDir + "customArgs/"
189+
val negCustomArgs = testsDir + "neg-custom-args/"
190190

191191
@Test def neg_typers() = compileFile(negCustomArgs, "typers")(allowDoubleBindings)
192192
@Test def neg_overrideClass = compileFile(negCustomArgs, "overrideClass", scala2mode)
@@ -198,7 +198,7 @@ class tests extends CompilerTest {
198198
@Test def neg_valueclasses_pavlov = compileFile(negCustomArgs, "valueclasses-pavlov")(allowDoubleBindings)
199199
@Test def neg_trailingUnderscore = compileFile(negCustomArgs, "trailingUnderscore", args = "-strict" :: Nil)
200200

201-
val negTailcallDir = negDir + "tailcall/"
201+
val negTailcallDir = testsDir + "neg-tailcall/"
202202
@Test def neg_tailcall_t1672b = compileFile(negTailcallDir, "t1672b")
203203
@Test def neg_tailcall_t3275 = compileFile(negTailcallDir, "t3275")
204204
@Test def neg_tailcall_t6574 = compileFile(negTailcallDir, "t6574")

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CompilationTests extends ParallelTesting {
9999
compileDir("../tests/pos/i1137-1", defaultOptions and "-Yemit-tasty") +
100100
compileFile(
101101
// succeeds despite -Xfatal-warnings because of -nowarn
102-
"../tests/neg/customArgs/xfatalWarnings.scala",
102+
"../tests/neg-custom-args/xfatalWarnings.scala",
103103
defaultOptions.and("-nowarn", "-Xfatal-warnings")
104104
)
105105
}.checkCompile()
@@ -165,30 +165,25 @@ class CompilationTests extends ParallelTesting {
165165

166166
@Test def compileNeg: Unit = {
167167
implicit val testGroup: TestGroup = TestGroup("compileNeg")
168-
compileShallowFilesInDir("../tests/neg", defaultOptions) +
169-
compileShallowFilesInDir("../tests/neg/no-optimise", defaultOptions) +
170-
compileFile("../tests/neg/customArgs/typers.scala", allowDoubleBindings) +
171-
compileFile("../tests/neg/customArgs/overrideClass.scala", scala2Mode) +
172-
compileFile("../tests/neg/customArgs/autoTuplingTest.scala", defaultOptions.and("-language:noAutoTupling")) +
173-
compileFile("../tests/neg/customArgs/i1050.scala", defaultOptions.and("-strict")) +
174-
compileFile("../tests/neg/customArgs/i1240.scala", allowDoubleBindings) +
175-
compileFile("../tests/neg/customArgs/i2002.scala", allowDoubleBindings) +
176-
compileFile("../tests/neg/customArgs/nopredef.scala", defaultOptions.and("-Yno-predef")) +
177-
compileFile("../tests/neg/customArgs/noimports.scala", defaultOptions.and("-Yno-imports")) +
178-
compileFile("../tests/neg/customArgs/noimports2.scala", defaultOptions.and("-Yno-imports")) +
179-
compileFile("../tests/neg/customArgs/overloadsOnAbstractTypes.scala", allowDoubleBindings) +
180-
compileFile("../tests/neg/customArgs/xfatalWarnings.scala", defaultOptions.and("-Xfatal-warnings")) +
181-
compileFile("../tests/neg/customArgs/pureStatement.scala", defaultOptions.and("-Xfatal-warnings")) +
182-
compileFile("../tests/neg/customArgs/phantom-overload.scala", allowDoubleBindings) +
183-
compileFile("../tests/neg/customArgs/phantom-overload-2.scala", allowDoubleBindings) +
184-
compileFile("../tests/neg/tailcall/t1672b.scala", defaultOptions) +
185-
compileFile("../tests/neg/tailcall/t3275.scala", defaultOptions) +
186-
compileFile("../tests/neg/tailcall/t6574.scala", defaultOptions) +
187-
compileFile("../tests/neg/tailcall/tailrec.scala", defaultOptions) +
188-
compileFile("../tests/neg/tailcall/tailrec-2.scala", defaultOptions) +
189-
compileFile("../tests/neg/tailcall/tailrec-3.scala", defaultOptions) +
190-
compileFile("../tests/neg/i3246.scala", scala2Mode) +
191-
compileDir("../tests/neg/typedIdents", defaultOptions)
168+
compileFilesInDir("../tests/neg", defaultOptions) +
169+
compileFilesInDir("../tests/neg-tailcall", defaultOptions) +
170+
compileFilesInDir("../tests/neg-no-optimise", defaultOptions) +
171+
compileFile("../tests/neg-custom-args/i3246.scala", scala2Mode) +
172+
compileFile("../tests/neg-custom-args/typers.scala", allowDoubleBindings) +
173+
compileFile("../tests/neg-custom-args/overrideClass.scala", scala2Mode) +
174+
compileFile("../tests/neg-custom-args/autoTuplingTest.scala", defaultOptions.and("-language:noAutoTupling")) +
175+
compileFile("../tests/neg-custom-args/i1050.scala", defaultOptions.and("-strict")) +
176+
compileFile("../tests/neg-custom-args/i1240.scala", allowDoubleBindings) +
177+
compileFile("../tests/neg-custom-args/i2002.scala", allowDoubleBindings) +
178+
compileFile("../tests/neg-custom-args/nopredef.scala", defaultOptions.and("-Yno-predef")) +
179+
compileFile("../tests/neg-custom-args/noimports.scala", defaultOptions.and("-Yno-imports")) +
180+
compileFile("../tests/neg-custom-args/noimports2.scala", defaultOptions.and("-Yno-imports")) +
181+
compileFile("../tests/neg-custom-args/overloadsOnAbstractTypes.scala", allowDoubleBindings) +
182+
compileFile("../tests/neg-custom-args/xfatalWarnings.scala", defaultOptions.and("-Xfatal-warnings")) +
183+
compileFile("../tests/neg-custom-args/pureStatement.scala", defaultOptions.and("-Xfatal-warnings")) +
184+
compileFile("../tests/neg-custom-args/phantom-overload.scala", allowDoubleBindings) +
185+
compileFile("../tests/neg-custom-args/phantom-overload-2.scala", allowDoubleBindings) +
186+
compileFile("../tests/neg-custom-args/structural.scala", defaultOptions.and("-Xfatal-warnings"))
192187
}.checkExpectedErrors()
193188

194189
// Run tests -----------------------------------------------------------------
@@ -311,7 +306,7 @@ class CompilationTests extends ParallelTesting {
311306
implicit val testGroup: TestGroup = TestGroup("optimised/testOptimised")
312307
compileFilesInDir("../tests/pos", defaultOptimised).checkCompile()
313308
compileFilesInDir("../tests/run", defaultOptimised).checkRuns()
314-
compileShallowFilesInDir("../tests/neg", defaultOptimised).checkExpectedErrors()
309+
compileFilesInDir("../tests/neg", defaultOptimised).checkExpectedErrors()
315310
}
316311

317312
private val (compilerSources, backendSources, backendJvmSources) = {
@@ -340,10 +335,14 @@ object CompilationTests {
340335
implicit val summaryReport: SummaryReporting = new SummaryReport
341336
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
342337

343-
def sources(paths: JStream[Path], excludedFiles: List[String] = Nil): List[String] =
344-
paths.iterator().asScala
338+
def sources(paths: JStream[Path], excludedFiles: List[String] = Nil): List[String] = {
339+
val sources = paths.iterator().asScala
345340
.filter(path =>
346341
(path.toString.endsWith(".scala") || path.toString.endsWith(".java"))
347342
&& !excludedFiles.contains(path.getFileName.toString))
348343
.map(_.toString).toList
344+
345+
paths.close()
346+
sources
347+
}
349348
}

compiler/test/dotty/tools/dotc/CompilerTest.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ abstract class CompilerTest {
149149

150150
private def expectedErrors(filePath: String): List[ErrorsInFile] = expectedErrors(List(filePath))
151151

152-
private def isNegTest(testPath: String) = testPath.contains("/neg/")
152+
private def isNegTest(testPath: String) =
153+
testPath.contains("/neg/") || testPath.contains("/neg-custom-args/") || testPath.contains("/neg-tailcall/")
153154

154155
private def compileArgs(args: Array[String], expectedErrorsPerFile: List[ErrorsInFile])
155156
(implicit defaultOptions: List[String]): Unit = {

compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class MissingCoreLibTests {
1111

1212
@Test def missingDottyLib: Unit = {
1313
val classPath = mkClassPath(Jars.dottyCompiler :: Jars.dottyInterfaces :: Jars.dottyExtras) // missing Jars.dottyLib
14-
val source = "../tests/neg/nolib/Foo.scala"
14+
val source = "../tests/pos/Foo.scala"
1515
val options = Array("-classpath", classPath, source)
1616
val reporter = Main.process(options)
1717
assertEquals(1, reporter.errorCount)

compiler/test/dotty/tools/dotc/SettingsTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SettingsTests {
1919

2020
@Test def jarOutput: Unit = {
2121
val classPath = mkClassPath(Jars.dottyTestDeps)
22-
val source = "../tests/neg/nolib/Foo.scala"
22+
val source = "../tests/pos/Foo.scala"
2323
val out = Paths.get("../out/jaredFoo.jar").normalize
2424
if (Files.exists(out)) Files.delete(out)
2525
val options = Array("-classpath", classPath, "-d", out.toString, source)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/neg/compExceptions/structural.scala renamed to tests/neg-custom-args/structural.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import scala.reflect.Selectable.reflectiveSelectable
2+
13
package p1 {
24

35
object test123 {
@@ -36,20 +38,21 @@ object RClose {
3638
}
3739

3840
package p3 {
41+
3942
object Test {
40-
def idMap[C[_],T](m: { def map[U](f: T => U): C[U] }): C[T] = m.map(t => t)
43+
def idMap[C[_],T](m: { def map[U](f: T => U): C[U] }): C[T] = m.map(t => t) // error: polymorphic refinement method map without matching type in parent Object is no longer allowed
4144

4245
def main(args: Array[String]): Unit = {
43-
idMap(Some(5))
44-
idMap(Responder.constant(5))
46+
idMap(Some(5)) // error: type mismatch: found Some[Int], required Object{map: [U](f: Any => U): Any}
47+
idMap(Responder.constant(5)) // error: type mismatch: found Responder[Int], required Object{map: [U](f: Any => U): Any}
4548
}
4649
}
4750
}
4851
package p4 {
4952

5053
trait A { self: Any { def p: Any } =>
5154
def f(b: => Unit): Unit = {}
52-
f { p } // error: cannot access member 'p' from structural type
55+
f { p } // OK
5356
}
5457
}
5558

@@ -64,7 +67,7 @@ object Test {
6467
package p6 {
6568

6669
class Refinements {
67-
val y: C { val x: T; type T } // was adeprecated warning: illegal forward reference in refinement; now illegal
70+
val y: { val x: T; type T } // error: deprecated warning: illegal forward reference in refinement; now illegal
6871
}
6972

7073
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/neg/nolib/Foo.scala

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/pos/Foo.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class Foo

0 commit comments

Comments
 (0)