Search in sources :

Example 1 with IntrinsicType

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

the class TypeMatcherTest method testCombinedTypeNotMatchesCombinedType.

@Test
void testCombinedTypeNotMatchesCombinedType() {
    final AbstractType type = new CombinedType(new IntrinsicType(GlobalReference.of("sw:type1")), new IntrinsicType(GlobalReference.of("sw:type2")));
    final AbstractType criterium = new CombinedType(new IntrinsicType(GlobalReference.of("sw:type2")), new IntrinsicType(GlobalReference.of("sw:type3")));
    final boolean matches = TypeMatcher.typeMatches(type, criterium);
    assertThat(matches).isFalse();
}
Also used : IntrinsicType(nl.ramsolutions.sw.magik.analysis.typing.types.IntrinsicType) CombinedType(nl.ramsolutions.sw.magik.analysis.typing.types.CombinedType) AbstractType(nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType) Test(org.junit.jupiter.api.Test)

Example 2 with IntrinsicType

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

the class TypeMatcherTest method testCombinedTypeMatchesCombinedType.

@Test
void testCombinedTypeMatchesCombinedType() {
    final AbstractType type = new CombinedType(new IntrinsicType(GlobalReference.of("sw:type1")), new IntrinsicType(GlobalReference.of("sw:type2")));
    final AbstractType criterium = new CombinedType(new IntrinsicType(GlobalReference.of("sw:type1")), new IntrinsicType(GlobalReference.of("sw:type2")), new IntrinsicType(GlobalReference.of("sw:type3")));
    final boolean matches = TypeMatcher.typeMatches(type, criterium);
    assertThat(matches).isTrue();
}
Also used : IntrinsicType(nl.ramsolutions.sw.magik.analysis.typing.types.IntrinsicType) CombinedType(nl.ramsolutions.sw.magik.analysis.typing.types.CombinedType) AbstractType(nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType) Test(org.junit.jupiter.api.Test)

Example 3 with IntrinsicType

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

the class TypeMatcherTest method testIsKindOfEquals.

@Test
void testIsKindOfEquals() {
    final AbstractType type = new IntrinsicType(GlobalReference.of("sw:type"));
    final AbstractType criterium = new IntrinsicType(GlobalReference.of("sw:type"));
    final boolean isKindOf = TypeMatcher.isKindOf(type, criterium);
    assertThat(isKindOf).isTrue();
}
Also used : IntrinsicType(nl.ramsolutions.sw.magik.analysis.typing.types.IntrinsicType) AbstractType(nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType) Test(org.junit.jupiter.api.Test)

Example 4 with IntrinsicType

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

the class TypeMatcherTest method testIsKindOfDirectParent.

@Test
void testIsKindOfDirectParent() {
    final AbstractType baseType = new IntrinsicType(GlobalReference.of("sw:base"));
    final MagikType childType = new IntrinsicType(GlobalReference.of("sw:child"));
    childType.addParent(baseType);
    final AbstractType criterium = new IntrinsicType(GlobalReference.of("sw:base"));
    final boolean isKindOf = TypeMatcher.isKindOf(childType, criterium);
    assertThat(isKindOf).isTrue();
}
Also used : IntrinsicType(nl.ramsolutions.sw.magik.analysis.typing.types.IntrinsicType) AbstractType(nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType) MagikType(nl.ramsolutions.sw.magik.analysis.typing.types.MagikType) Test(org.junit.jupiter.api.Test)

Example 5 with IntrinsicType

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

the class TypeMatcherTest method testTypeNotMatchesCombinedType.

@Test
void testTypeNotMatchesCombinedType() {
    final AbstractType type = new IntrinsicType(GlobalReference.of("sw:type3"));
    final AbstractType criterium = new CombinedType(new IntrinsicType(GlobalReference.of("sw:type1")), new IntrinsicType(GlobalReference.of("sw:type2")));
    final boolean matches = TypeMatcher.typeMatches(type, criterium);
    assertThat(matches).isFalse();
}
Also used : IntrinsicType(nl.ramsolutions.sw.magik.analysis.typing.types.IntrinsicType) CombinedType(nl.ramsolutions.sw.magik.analysis.typing.types.CombinedType) AbstractType(nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType) Test(org.junit.jupiter.api.Test)

Aggregations

IntrinsicType (nl.ramsolutions.sw.magik.analysis.typing.types.IntrinsicType)15 AbstractType (nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType)11 Test (org.junit.jupiter.api.Test)11 MagikType (nl.ramsolutions.sw.magik.analysis.typing.types.MagikType)6 CombinedType (nl.ramsolutions.sw.magik.analysis.typing.types.CombinedType)4 GlobalReference (nl.ramsolutions.sw.magik.analysis.typing.types.GlobalReference)3 IndexedType (nl.ramsolutions.sw.magik.analysis.typing.types.IndexedType)2 SlottedType (nl.ramsolutions.sw.magik.analysis.typing.types.SlottedType)2 AstNode (com.sonar.sslr.api.AstNode)1 Path (java.nio.file.Path)1 InvalidParameterException (java.security.InvalidParameterException)1 ObjectType (nl.ramsolutions.sw.magik.analysis.typing.types.ObjectType)1 Package (nl.ramsolutions.sw.magik.analysis.typing.types.Package)1 Slot (nl.ramsolutions.sw.magik.analysis.typing.types.Slot)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1