Search in sources :

Example 1 with MagikTypedCheck

use of nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck in project magik-tools by StevenLooman.

the class GlobalKnownTypedCheckTest method testUnknownGlobal.

@Test
void testUnknownGlobal() {
    final String code = "" + "abc.m";
    final ITypeKeeper typeKeeper = new TypeKeeper();
    final MagikTypedCheck check = new GlobalKnownTypedCheck();
    final List<MagikIssue> checkResults = this.runCheck(code, typeKeeper, check);
    assertThat(checkResults).hasSize(1);
}
Also used : MagikTypedCheck(nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck) TypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.TypeKeeper) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) MagikIssue(nl.ramsolutions.sw.magik.checks.MagikIssue) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) Test(org.junit.jupiter.api.Test)

Example 2 with MagikTypedCheck

use of nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck in project magik-tools by StevenLooman.

the class MethodArgumentParameterTypeCheckTest method testArgumentTypeMatches.

@Test
void testArgumentTypeMatches() {
    final String code = "integer.m1(:symbol)";
    final ITypeKeeper typeKeeper = new TypeKeeper();
    final MagikType integerType = (MagikType) typeKeeper.getType(GlobalReference.of("sw:integer"));
    final AbstractType symbolType = typeKeeper.getType(GlobalReference.of("sw:symbol"));
    final Parameter param1 = new Parameter("p1", Parameter.Modifier.NONE, symbolType);
    integerType.addMethod(EnumSet.noneOf(Method.Modifier.class), null, "m1()", List.of(param1), null, ExpressionResult.UNDEFINED);
    final MagikTypedCheck check = new MethodArgumentParameterTypedCheck();
    final List<MagikIssue> checkResults = this.runCheck(code, typeKeeper, check);
    assertThat(checkResults).isEmpty();
}
Also used : MagikTypedCheck(nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck) TypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.TypeKeeper) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) AbstractType(nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType) Parameter(nl.ramsolutions.sw.magik.analysis.typing.types.Parameter) MagikIssue(nl.ramsolutions.sw.magik.checks.MagikIssue) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) MagikType(nl.ramsolutions.sw.magik.analysis.typing.types.MagikType) Test(org.junit.jupiter.api.Test)

Example 3 with MagikTypedCheck

use of nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck in project magik-tools by StevenLooman.

the class MethodArgumentParameterTypeCheckTest method testArgumentTypeNotMatches.

@Test
void testArgumentTypeNotMatches() {
    final String code = "integer.m1(1)";
    final ITypeKeeper typeKeeper = new TypeKeeper();
    final MagikType integerType = (MagikType) typeKeeper.getType(GlobalReference.of("sw:integer"));
    final AbstractType symbolType = typeKeeper.getType(GlobalReference.of("sw:symbol"));
    final Parameter param1 = new Parameter("p1", Parameter.Modifier.NONE, symbolType);
    integerType.addMethod(EnumSet.noneOf(Method.Modifier.class), null, "m1()", List.of(param1), null, ExpressionResult.UNDEFINED);
    final MagikTypedCheck check = new MethodArgumentParameterTypedCheck();
    final List<MagikIssue> checkResults = this.runCheck(code, typeKeeper, check);
    assertThat(checkResults).hasSize(1);
}
Also used : MagikTypedCheck(nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck) TypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.TypeKeeper) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) AbstractType(nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType) Parameter(nl.ramsolutions.sw.magik.analysis.typing.types.Parameter) MagikIssue(nl.ramsolutions.sw.magik.checks.MagikIssue) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) MagikType(nl.ramsolutions.sw.magik.analysis.typing.types.MagikType) Test(org.junit.jupiter.api.Test)

Example 4 with MagikTypedCheck

use of nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck in project magik-tools by StevenLooman.

the class MethodReturnMatchesDocTypedCheckTest method testTypesMatches.

@Test
void testTypesMatches() {
    final String code = "" + "_method a.b\n" + "  ## @return {integer}\n" + "  _return 1\n" + "_endmethod";
    final MagikTypedCheck check = new MethodReturnMatchesDocTypedCheck();
    final ITypeKeeper typeKeeper = new TypeKeeper();
    final List<MagikIssue> issues = this.runCheck(code, typeKeeper, check);
    assertThat(issues).isEmpty();
}
Also used : MagikTypedCheck(nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck) TypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.TypeKeeper) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) MagikIssue(nl.ramsolutions.sw.magik.checks.MagikIssue) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) Test(org.junit.jupiter.api.Test)

Example 5 with MagikTypedCheck

use of nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck in project magik-tools by StevenLooman.

the class NewDocTypeExistsTypeCheckTest method testSlotUnknownType.

@Test
void testSlotUnknownType() {
    final String code = "" + "_method a.b(p1)\n" + "  ## @param {user:missing_type} p1\n" + "_endmethod";
    final MagikTypedCheck check = new NewDocTypeExistsTypeCheck();
    final ITypeKeeper typeKeeper = new TypeKeeper();
    final List<MagikIssue> issues = this.runCheck(code, typeKeeper, check);
    assertThat(issues).hasSize(1);
}
Also used : MagikTypedCheck(nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck) TypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.TypeKeeper) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) MagikIssue(nl.ramsolutions.sw.magik.checks.MagikIssue) ITypeKeeper(nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper) Test(org.junit.jupiter.api.Test)

Aggregations

ITypeKeeper (nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper)13 TypeKeeper (nl.ramsolutions.sw.magik.analysis.typing.TypeKeeper)13 MagikIssue (nl.ramsolutions.sw.magik.checks.MagikIssue)13 MagikTypedCheck (nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck)13 Test (org.junit.jupiter.api.Test)13 AbstractType (nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType)4 MagikType (nl.ramsolutions.sw.magik.analysis.typing.types.MagikType)4 Parameter (nl.ramsolutions.sw.magik.analysis.typing.types.Parameter)4