Search in sources :

Example 21 with TypeParser

use of com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.

the class TypeParserTests method testTypeCallPackage.

@Test
public void testTypeCallPackage() {
    Type type = new TypeParser(MockLoader.instance).decodeType("pkg::package", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    TypeDeclaration declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof Class);
    Assert.assertEquals("pkg::package", printType(type));
    Assert.assertNull(type.getQualifyingType());
}
Also used : IntersectionType(com.redhat.ceylon.model.typechecker.model.IntersectionType) Type(com.redhat.ceylon.model.typechecker.model.Type) UnionType(com.redhat.ceylon.model.typechecker.model.UnionType) TypeParser(com.redhat.ceylon.model.loader.TypeParser) Class(com.redhat.ceylon.model.typechecker.model.Class) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 22 with TypeParser

use of com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.

the class TypeParserTests method testPackageQualified.

@Test
public void testPackageQualified() {
    Type type = new TypeParser(MockLoader.instance).decodeType("pkg::v", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    TypeDeclaration declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof Class);
    Assert.assertEquals("pkg::v", declaration.getQualifiedNameString());
    Assert.assertNull(type.getQualifyingType());
}
Also used : IntersectionType(com.redhat.ceylon.model.typechecker.model.IntersectionType) Type(com.redhat.ceylon.model.typechecker.model.Type) UnionType(com.redhat.ceylon.model.typechecker.model.UnionType) TypeParser(com.redhat.ceylon.model.loader.TypeParser) Class(com.redhat.ceylon.model.typechecker.model.Class) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 23 with TypeParser

use of com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.

the class TypeParserTests method testOptionalEntry.

@Test
public void testOptionalEntry() {
    Type type = new TypeParser(MockLoader.instance).decodeType("<ceylon.language::Boolean->a>?", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    TypeDeclaration declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof UnionType);
    Assert.assertEquals("ceylon.language::Null|ceylon.language::Entry<ceylon.language::Boolean,a>", printType(type));
    Assert.assertNull(type.getQualifyingType());
}
Also used : UnionType(com.redhat.ceylon.model.typechecker.model.UnionType) IntersectionType(com.redhat.ceylon.model.typechecker.model.IntersectionType) Type(com.redhat.ceylon.model.typechecker.model.Type) UnionType(com.redhat.ceylon.model.typechecker.model.UnionType) TypeParser(com.redhat.ceylon.model.loader.TypeParser) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 24 with TypeParser

use of com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.

the class TypeParserTests method testTuple1To3StarAbbrev.

// [a,b=,c+] it not allowed (for good reason)
@Test
public void testTuple1To3StarAbbrev() {
    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("ceylon.language::Tuple<a|b|c,a,ceylon.language::Empty|ceylon.language::Tuple<b|c,b,ceylon.language::Sequential<c>>>", printType(type));
    Assert.assertNull(type.getQualifyingType());
}
Also used : IntersectionType(com.redhat.ceylon.model.typechecker.model.IntersectionType) Type(com.redhat.ceylon.model.typechecker.model.Type) UnionType(com.redhat.ceylon.model.typechecker.model.UnionType) TypeParser(com.redhat.ceylon.model.loader.TypeParser) Class(com.redhat.ceylon.model.typechecker.model.Class) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 25 with TypeParser

use of com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.

the class TypeParserTests method testCallableOfEntry.

@Test
public void testCallableOfEntry() {
    Type type = new TypeParser(MockLoader.instance).decodeType("ceylon.language::Boolean(ceylon.language::Nothing->ceylon.language::Nothing)", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    TypeDeclaration declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof Interface);
    Assert.assertEquals("ceylon.language::Callable<ceylon.language::Boolean,ceylon.language::Tuple<ceylon.language::Entry<ceylon.language::Nothing,ceylon.language::Nothing>,ceylon.language::Entry<ceylon.language::Nothing,ceylon.language::Nothing>,ceylon.language::Empty>>", printType(type));
    Assert.assertNull(type.getQualifyingType());
}
Also used : IntersectionType(com.redhat.ceylon.model.typechecker.model.IntersectionType) Type(com.redhat.ceylon.model.typechecker.model.Type) UnionType(com.redhat.ceylon.model.typechecker.model.UnionType) TypeParser(com.redhat.ceylon.model.loader.TypeParser) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Interface(com.redhat.ceylon.model.typechecker.model.Interface) ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) Test(org.junit.Test)

Aggregations

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