use of org.eclipse.ceylon.model.loader.TypeParser in project ceylon by eclipse.
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 org.eclipse.ceylon.model.loader.TypeParser in project ceylon by eclipse.
the class TypeParserTests method testPossiblyEmptyIterableAbbrev.
@Test
public void testPossiblyEmptyIterableAbbrev() {
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 Interface);
Assert.assertEquals("ceylon.language::Iterable", declaration.getQualifiedNameString());
Assert.assertEquals("{a*}", type.asString());
Assert.assertNull(type.getQualifyingType());
}
use of org.eclipse.ceylon.model.loader.TypeParser in project ceylon by eclipse.
the class TypeParserTests method testEntryAbbrev.
@Test
public void testEntryAbbrev() {
Type type = new TypeParser(MockLoader.instance).decodeType(" a -> b ", null, mockDefaultModule, mockDefaultUnit);
Assert.assertNotNull(type);
TypeDeclaration declaration = type.getDeclaration();
Assert.assertNotNull(declaration);
Assert.assertTrue(declaration instanceof Class);
Assert.assertEquals("ceylon.language::Entry", declaration.getQualifiedNameString());
Assert.assertEquals("ceylon.language::Entry<a,b>", printType(type));
Assert.assertNull(type.getQualifyingType());
type = new TypeParser(MockLoader.instance).decodeType("pkg::u|pkg::v->b", null, mockPkgModule, mockPkgUnit);
Assert.assertNotNull(type);
declaration = type.getDeclaration();
Assert.assertNotNull(declaration);
Assert.assertTrue(declaration instanceof Class);
Assert.assertEquals("ceylon.language::Entry", declaration.getQualifiedNameString());
Assert.assertEquals("ceylon.language::Entry<pkg::u|pkg::v,b>", printType(type));
Assert.assertNull(type.getQualifyingType());
}
use of org.eclipse.ceylon.model.loader.TypeParser in project ceylon by eclipse.
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());
}
use of org.eclipse.ceylon.model.loader.TypeParser in project ceylon by eclipse.
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);
}
Aggregations