Search in sources :

Example 36 with TypeParser

use of org.eclipse.ceylon.model.loader.TypeParser in project ceylon by eclipse.

the class TypeParserTests method testTuple3OrMoreAbbrev.

@Test
public void testTuple3OrMoreAbbrev() {
    Type type = new TypeParser(MockLoader.instance).decodeType("[a,b,c+]", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    TypeDeclaration declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof Class);
    Assert.assertEquals("ceylon.language::Tuple", declaration.getQualifiedNameString());
    Assert.assertEquals("[a, b, c+]", type.asString());
    Assert.assertNull(type.getQualifyingType());
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) UnionType(org.eclipse.ceylon.model.typechecker.model.UnionType) TypeParser(org.eclipse.ceylon.model.loader.TypeParser) Class(org.eclipse.ceylon.model.typechecker.model.Class) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 37 with TypeParser

use of org.eclipse.ceylon.model.loader.TypeParser in project ceylon by eclipse.

the class TypeParserTests method testOptionalAbbrev.

@Test
public void testOptionalAbbrev() {
    Type type = new TypeParser(MockLoader.instance).decodeType("a?", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    TypeDeclaration declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof UnionType);
    Assert.assertEquals("ceylon.language::Null|a", printType(type));
    Assert.assertNull(type.getQualifyingType());
    type = new TypeParser(MockLoader.instance).decodeType("pkg::u&pkg::v?", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof IntersectionType);
    Assert.assertEquals("pkg::u&<ceylon.language::Null|pkg::v>", printType(type));
    Assert.assertNull(type.getQualifyingType());
    type = new TypeParser(MockLoader.instance).decodeType("pkg::u|pkg::v[]?", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof UnionType);
    Assert.assertEquals("pkg::u|ceylon.language::Null|ceylon.language::Sequential<pkg::v>", printType(type));
    Assert.assertNull(type.getQualifyingType());
}
Also used : UnionType(org.eclipse.ceylon.model.typechecker.model.UnionType) Type(org.eclipse.ceylon.model.typechecker.model.Type) IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) UnionType(org.eclipse.ceylon.model.typechecker.model.UnionType) TypeParser(org.eclipse.ceylon.model.loader.TypeParser) IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Aggregations

TypeParser (org.eclipse.ceylon.model.loader.TypeParser)37 Test (org.junit.Test)37 IntersectionType (org.eclipse.ceylon.model.typechecker.model.IntersectionType)36 Type (org.eclipse.ceylon.model.typechecker.model.Type)36 UnionType (org.eclipse.ceylon.model.typechecker.model.UnionType)36 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)32 Class (org.eclipse.ceylon.model.typechecker.model.Class)21 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)8 Interface (org.eclipse.ceylon.model.typechecker.model.Interface)8 SiteVariance (org.eclipse.ceylon.model.typechecker.model.SiteVariance)3 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)3 TypeParserException (org.eclipse.ceylon.model.loader.TypeParserException)1