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);
}
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();
}
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);
}
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();
}
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);
}
Aggregations