use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class TypeParserTests method testIntersection.
@Test
public void testIntersection() {
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 IntersectionType);
IntersectionType intersection = (IntersectionType) declaration;
List<Type> types = intersection.getSatisfiedTypes();
Assert.assertEquals(3, types.size());
Assert.assertEquals("a", types.get(0).getDeclaration().getName());
Assert.assertTrue(types.get(0).getDeclaration() instanceof Class);
Assert.assertEquals("b", types.get(1).getDeclaration().getName());
Assert.assertTrue(types.get(1).getDeclaration() instanceof Class);
Assert.assertEquals("c", types.get(2).getDeclaration().getName());
Assert.assertTrue(types.get(2).getDeclaration() instanceof Class);
}
use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class TypeParserTests method testTuple1To3Abbrev.
@Test
public void testTuple1To3Abbrev() {
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());
// can only test this for Callable as TypeNamePrinter only prints '=' for Callable
// Assert.assertEquals("[a, b=, c=]", type.asString());
Assert.assertEquals("ceylon.language::Tuple<a|b|c,a,ceylon.language::Empty|ceylon.language::Tuple<b|c,b,ceylon.language::Empty|ceylon.language::Tuple<c,c,ceylon.language::Empty>>>", printType(type));
Assert.assertNull(type.getQualifyingType());
}
use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class TypeParserTests method testComplexQualified.
@Test
public void testComplexQualified() {
Type type = new TypeParser(MockLoader.instance).decodeType("<pkg::u&pkg::v>.w", null, mockDefaultModule, mockPkgUnit);
Assert.assertNotNull(type);
TypeDeclaration declaration = type.getDeclaration();
Assert.assertNotNull(declaration);
Assert.assertTrue(declaration instanceof Class);
Assert.assertEquals("pkg::v.w", declaration.getQualifiedNameString());
Type qualifyingType = type.getQualifyingType();
Assert.assertNotNull(qualifyingType);
TypeDeclaration qualifyingDeclaration = qualifyingType.getDeclaration();
Assert.assertNotNull(qualifyingDeclaration);
Assert.assertTrue(qualifyingDeclaration instanceof IntersectionType);
Assert.assertEquals("u&v", qualifyingDeclaration.getName());
}
use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class TypeParserTests method testUnion.
@Test
public void testUnion() {
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 UnionType);
UnionType union = (UnionType) declaration;
List<Type> types = union.getCaseTypes();
Assert.assertEquals(3, types.size());
Assert.assertEquals("a", types.get(0).getDeclaration().getName());
Assert.assertTrue(types.get(0).getDeclaration() instanceof Class);
Assert.assertEquals("b", types.get(1).getDeclaration().getName());
Assert.assertTrue(types.get(1).getDeclaration() instanceof Class);
Assert.assertEquals("c", types.get(2).getDeclaration().getName());
Assert.assertTrue(types.get(2).getDeclaration() instanceof Class);
}
use of com.redhat.ceylon.model.typechecker.model.Class in project ceylon-compiler by ceylon.
the class TypeParserTests method testHomoTuple1.
@Test
public void testHomoTuple1() {
Type type = new TypeParser(MockLoader.instance).decodeType("a[1]", 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]", type.asString());
Assert.assertNull(type.getQualifyingType());
}
Aggregations