use of com.redhat.ceylon.model.typechecker.model.UnionType in project ceylon-compiler by ceylon.
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