mirror of
https://github.com/enso-org/enso.git
synced 2024-11-23 16:18:23 +03:00
Minor cleanups in tests (#3697)
* Minor cleanups in tests Removing some leftovers from big PRs. * More tweaks * Print failed status to stderr
This commit is contained in:
parent
d8f274158a
commit
65b27447e6
@ -255,10 +255,6 @@ class RuntimeVisualizationsTest
|
||||
val idIncRes = metadata.addItem(129, 8)
|
||||
val idIncMethod = metadata.addItem(102, 43)
|
||||
|
||||
println(s"idIncY=$idIncY")
|
||||
println(s"idIncRes=$idIncRes")
|
||||
println(s"idIncMethod=$idIncMethod")
|
||||
|
||||
val code =
|
||||
metadata.appendToCode(
|
||||
"""import Standard.Base.IO
|
||||
|
@ -728,7 +728,9 @@ class Compiler(
|
||||
diagnostics.map(_._2.collect { case e: IR.Error => e }.length).sum
|
||||
val warnCount =
|
||||
diagnostics.map(_._2.collect { case e: IR.Warning => e }.length).sum
|
||||
println(s"Aborting due to ${count} errors and ${warnCount} warnings.")
|
||||
context.getErr.println(
|
||||
s"Aborting due to ${count} errors and ${warnCount} warnings."
|
||||
)
|
||||
throw new CompilationAbortedException
|
||||
}
|
||||
}
|
||||
@ -803,15 +805,14 @@ class Compiler(
|
||||
private def reportDiagnostics(
|
||||
diagnostics: List[(Module, List[IR.Diagnostic])]
|
||||
): Boolean = {
|
||||
val results = diagnostics.map { case (mod, diags) =>
|
||||
diagnostics.find { case (mod, diags) =>
|
||||
if (diags.nonEmpty) {
|
||||
context.getOut.println(s"In module ${mod.getName}:")
|
||||
reportDiagnostics(diags, mod.getSource)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
results.exists(r => r)
|
||||
}.nonEmpty
|
||||
}
|
||||
|
||||
/** Reports compilation diagnostics to the standard output and throws an
|
||||
|
@ -208,19 +208,6 @@ trait CompilerRunner {
|
||||
None
|
||||
)
|
||||
}
|
||||
|
||||
// /** Creates a module containing both an atom and a method that use the
|
||||
// * provided expression.
|
||||
// *
|
||||
// * The expression is used in the default for an atom argument, as in
|
||||
// * [[asAtomDefaultArg()]], and in the body of a method, as in
|
||||
// * [[asMethod()]].
|
||||
// *
|
||||
// * @return a module containing an atom def and method def using `expr`
|
||||
// */
|
||||
// def asModuleDefs: IR.Module = {
|
||||
// IR.Module(List(), List(), List(ir.asAtomDefaultArg, ir.asMethod), None)
|
||||
// }
|
||||
}
|
||||
|
||||
/** Builds a module context with a mocked module for testing purposes.
|
||||
|
@ -85,7 +85,6 @@ class ComplexTypeTest extends CompilerTest {
|
||||
}
|
||||
|
||||
"have their methods desugared to binding methods" in {
|
||||
// println(ir.pretty)
|
||||
ir.bindings(3) shouldBe an[Definition.Method.Binding]
|
||||
val isJust = ir.bindings(3).asInstanceOf[Definition.Method.Binding]
|
||||
isJust.methodName.name shouldEqual "is_just"
|
||||
|
@ -318,7 +318,6 @@ class DocumentationCommentsTest extends CompilerTest with Inside {
|
||||
implicit val moduleContext: ModuleContext =
|
||||
buildModuleContext(freshNameSupply = Some(new FreshNameSupply))
|
||||
|
||||
println("TUTEJ")
|
||||
val ir =
|
||||
"""## Module Docs
|
||||
|
|
||||
@ -343,7 +342,6 @@ class DocumentationCommentsTest extends CompilerTest with Inside {
|
||||
|""".stripMargin.preprocessModule
|
||||
|
||||
val t1 = ir.bindings.head
|
||||
println("IN TEST " + ir.bindings.head.getClass.getSimpleName)
|
||||
getDoc(t1) shouldEqual " the type Foo"
|
||||
inside(ir.bindings(1)) {
|
||||
case method: IR.Module.Scope.Definition.Method.Explicit =>
|
||||
|
@ -44,17 +44,10 @@ trait TypeMatchers {
|
||||
sig: Sig,
|
||||
expr: IR.Expression
|
||||
): Option[(Sig, IR.Expression, String)] = (sig, expr) match {
|
||||
case (Name(n), t: IR.Name.Literal) if n == t.name =>
|
||||
if (n == t.name) {
|
||||
None
|
||||
} else {
|
||||
Some((sig, expr, "names do not match"))
|
||||
}
|
||||
case (Name(n), t: IR.Name.Literal) =>
|
||||
Option.when(n != t.name)((sig, expr, "names do not match"))
|
||||
case (AnyQualName(n), _) =>
|
||||
val meta = expr.getMetadata(TypeNames)
|
||||
if (meta.isEmpty) {
|
||||
return Some((sig, expr, "the expression does not have a resolution"))
|
||||
}
|
||||
meta match {
|
||||
case None =>
|
||||
Some((sig, expr, "the expression does not have a resolution"))
|
||||
@ -73,18 +66,20 @@ trait TypeMatchers {
|
||||
}
|
||||
case (Fn(args, res), t: IR.Type.Function) =>
|
||||
if (args.length != t.args.length) {
|
||||
return Some((sig, expr, "arity does not match"))
|
||||
Some((sig, expr, "arity does not match"))
|
||||
} else {
|
||||
args
|
||||
.lazyZip(t.args)
|
||||
.flatMap(findInequalityWitness)
|
||||
.headOption
|
||||
.orElse(findInequalityWitness(res, t.result))
|
||||
}
|
||||
args
|
||||
.lazyZip(t.args)
|
||||
.flatMap(findInequalityWitness)
|
||||
.headOption
|
||||
.orElse(findInequalityWitness(res, t.result))
|
||||
case (Union(items), t: IR.Type.Set.Union) =>
|
||||
if (items.length != t.operands.length) {
|
||||
return Some((sig, expr, "number of items does not match"))
|
||||
Some((sig, expr, "number of items does not match"))
|
||||
} else {
|
||||
items.lazyZip(t.operands).flatMap(findInequalityWitness).headOption
|
||||
}
|
||||
items.lazyZip(t.operands).flatMap(findInequalityWitness).headOption
|
||||
case _ => Some((sig, expr, "constructors are incompatible"))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user