Search in sources :

Example 96 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class TypeParserTests method testEmptyAbbrev.

@Test
public void testEmptyAbbrev() {
    Type type = new TypeParser(MockLoader.instance).decodeType("[]", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    TypeDeclaration declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof Interface);
    Assert.assertEquals("ceylon.language::Empty", 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) 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)

Example 97 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class TypeParserTests method testTuple1OrMoreAbbrev.

@Test
public void testTuple1OrMoreAbbrev() {
    Type type = new TypeParser(MockLoader.instance).decodeType("[a,b*]", 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*]", type.asString());
    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 98 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration 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 99 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration 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 100 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration 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)

Aggregations

TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)140 Type (com.redhat.ceylon.model.typechecker.model.Type)85 Test (org.junit.Test)51 Class (com.redhat.ceylon.model.typechecker.model.Class)40 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)37 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)36 IntersectionType (com.redhat.ceylon.model.typechecker.model.IntersectionType)33 UnionType (com.redhat.ceylon.model.typechecker.model.UnionType)33 TypeParser (com.redhat.ceylon.model.loader.TypeParser)32 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)32 Interface (com.redhat.ceylon.model.typechecker.model.Interface)27 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)24 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)20 ModelUtil.appliedType (com.redhat.ceylon.model.typechecker.model.ModelUtil.appliedType)19 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)19 Function (com.redhat.ceylon.model.typechecker.model.Function)18 ArrayList (java.util.ArrayList)17 JCTree (com.sun.tools.javac.tree.JCTree)16 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)14 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)14