Skip to content

Commit

Permalink
Missing body yields an error
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Apr 1, 2023
1 parent 55c4002 commit 487620f
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
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;
import org.enso.compiler.core.IR$Name$Annotation;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

public class AnnotationsCompilerTest extends CompilerTest {

Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 487620f

Please sign in to comment.