Search in sources :

Example 1 with UndefinedType

use of nl.ramsolutions.sw.magik.analysis.typing.types.UndefinedType in project magik-tools by StevenLooman.

the class LocalTypeReasonerTest method testUnknownMethodCall.

@Test
void testUnknownMethodCall() {
    final String code = "" + "_method object.test\n" + "    _return object.unknown()\n" + "_endmethod\n";
    // Set up TypeKeeper/TypeReasoner.
    final TypeKeeper typeKeeper = new TypeKeeper();
    // Do analysis.
    final MagikTypedFile magikFile = this.createMagikFile(code, typeKeeper);
    final LocalTypeReasoner reasoner = magikFile.getTypeReasoner();
    // Assert user:object.test type determined.resul
    final AstNode topNode = magikFile.getTopNode();
    final AstNode methodNode = topNode.getFirstChild(MagikGrammar.METHOD_DEFINITION);
    final ExpressionResult result = reasoner.getNodeType(methodNode);
    assertThat(result).isEqualTo(ExpressionResult.UNDEFINED);
    final UndefinedType resultType = (UndefinedType) result.get(0, null);
    assertThat(resultType).isNotNull();
    assertThat(resultType.getFullName()).isEqualTo(UndefinedType.SERIALIZED_NAME);
}
Also used : ExpressionResult(nl.ramsolutions.sw.magik.analysis.typing.types.ExpressionResult) MagikTypedFile(nl.ramsolutions.sw.magik.MagikTypedFile) AstNode(com.sonar.sslr.api.AstNode) UndefinedType(nl.ramsolutions.sw.magik.analysis.typing.types.UndefinedType) Test(org.junit.jupiter.api.Test)

Aggregations

AstNode (com.sonar.sslr.api.AstNode)1 MagikTypedFile (nl.ramsolutions.sw.magik.MagikTypedFile)1 ExpressionResult (nl.ramsolutions.sw.magik.analysis.typing.types.ExpressionResult)1 UndefinedType (nl.ramsolutions.sw.magik.analysis.typing.types.UndefinedType)1 Test (org.junit.jupiter.api.Test)1