use of com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.
the class TypeParserTests method testParamsVariance1.
@Test
public void testParamsVariance1() {
Type type = new TypeParser(MockLoader.instance).decodeType("t2<in b,out c>", null, mockDefaultModule, mockPkgUnit);
assertTypeWithParameters(type);
Map<TypeParameter, SiteVariance> varianceOverrides = type.getVarianceOverrides();
Assert.assertNotNull(varianceOverrides);
Assert.assertEquals(2, varianceOverrides.size());
List<TypeParameter> tps = type.getDeclaration().getTypeParameters();
Assert.assertEquals(SiteVariance.IN, varianceOverrides.get(tps.get(0)));
Assert.assertEquals(SiteVariance.OUT, varianceOverrides.get(tps.get(1)));
}
use of com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.
the class TypeParserTests method testParams.
@Test
public void testParams() {
Type type = new TypeParser(MockLoader.instance).decodeType("t2<b,c>", null, mockDefaultModule, mockPkgUnit);
assertTypeWithParameters(type);
Assert.assertTrue(type.getVarianceOverrides().isEmpty());
}
use of com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.
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 com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.
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 com.redhat.ceylon.model.loader.TypeParser in project ceylon-compiler by ceylon.
the class TypeParserTests method testTuple3Abbrev.
@Test
public void testTuple3Abbrev() {
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());
}
Aggregations