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());
}
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());
}
Aggregations