From 487620f5bf04b384744f13ede1dacc7876296f9f Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sat, 1 Apr 2023 11:35:47 +0200 Subject: [PATCH] Missing body yields an error --- .../org/enso/compiler/AnnotationsCompilerTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/engine/runtime/src/test/java/org/enso/compiler/AnnotationsCompilerTest.java b/engine/runtime/src/test/java/org/enso/compiler/AnnotationsCompilerTest.java index d5e526fa0b9c..9ee12724e01c 100644 --- a/engine/runtime/src/test/java/org/enso/compiler/AnnotationsCompilerTest.java +++ b/engine/runtime/src/test/java/org/enso/compiler/AnnotationsCompilerTest.java @@ -1,5 +1,7 @@ package org.enso.compiler; +import org.enso.compiler.core.IR$Error$Syntax; +import org.enso.compiler.core.IR$Error$Syntax$UnexpectedDeclarationInType$; import org.enso.compiler.core.IR$Function$Binding; import org.enso.compiler.core.IR$Module$Scope$Definition$Data; import org.enso.compiler.core.IR$Module$Scope$Definition$SugaredType; @@ -7,6 +9,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; public class AnnotationsCompilerTest extends CompilerTest { @@ -88,10 +91,12 @@ public void testInvalidComplexType() throws Exception { """); var typeDefinition = (IR$Module$Scope$Definition$SugaredType) ir.bindings().apply(0); - var method = (IR$Function$Binding) typeDefinition.body().apply(0); + var methodOrError = typeDefinition.body().apply(0); - assertEquals(method.name().name(), "bar"); - // FIXME method body is null. Should be `IR.Error.Syntax.UnexpectedDeclarationInType` - assertEquals(method.body(), null); + if (methodOrError instanceof IR$Error$Syntax error) { + assertEquals(error.reason(), IR$Error$Syntax$UnexpectedDeclarationInType$.MODULE$); + } else { + fail("Expecting error instead of bar function: " + methodOrError); + } } }