@Test @SuppressWarnings("unchecked") public void testSimpleMethods() { // simple1 Map<String, Object> method = (Map<String, Object>) model.get("simple1"); Assert.assertNotNull(method); ModelUtils.checkMap( method, MetamodelGenerator.KEY_NAME, "simple1", MetamodelGenerator.KEY_METATYPE, MetamodelGenerator.METATYPE_METHOD); ModelUtils.checkType(method, "ceylon.language::Anything"); method = (Map<String, Object>) model.get("simple2"); ModelUtils.checkMap( method, MetamodelGenerator.KEY_NAME, "simple2", MetamodelGenerator.KEY_METATYPE, MetamodelGenerator.METATYPE_METHOD); ModelUtils.checkAnnotations(method, "shared"); ModelUtils.checkType(method, "ceylon.language::Integer"); method = (Map<String, Object>) model.get("simple3"); ModelUtils.checkMap( method, MetamodelGenerator.KEY_NAME, "simple3", MetamodelGenerator.KEY_METATYPE, MetamodelGenerator.METATYPE_METHOD); ModelUtils.checkType(method, "ceylon.language::Anything"); ModelUtils.checkParam(method, 0, "p1", "ceylon.language::Integer", false, false); ModelUtils.checkParam(method, 1, "p2", "ceylon.language::String", false, false); }
@Test @SuppressWarnings("unchecked") public void testSequentials() { Map<String, Object> attrib = (Map<String, Object>) model.get("sequentialAttribute1"); ModelUtils.checkType(attrib, "ceylon.language::Sequential<ceylon.language::Integer>"); attrib = (Map<String, Object>) model.get("sequentialAttribute2"); ModelUtils.checkType(attrib, "ceylon.language::Sequential<ceylon.language::Integer>"); }
@Test @SuppressWarnings("unchecked") public void testMultipleParameterLists() { Map<String, Object> method = (Map<String, Object>) model.get("mpl1"); ModelUtils.checkParam(method, 0, "a", "ceylon.language::String", false, false); ModelUtils.checkType(method, "ceylon.language::Integer"); method = (Map<String, Object>) model.get("mpl2"); ModelUtils.checkParam(method, 0, "a", "ceylon.language::Integer", false, false); ModelUtils.checkType(method, "ceylon.language::String"); }
@Test @SuppressWarnings("unchecked") public void testParameterTypes() { Map<String, Object> method = (Map<String, Object>) model.get("parmtypes1"); ModelUtils.checkParam( method, 0, "x", "ceylon.language::Sequence<ceylon.language::Integer>", false, false); method = (Map<String, Object>) model.get("parmtypes2"); ModelUtils.checkParam( method, 0, "xx", "ceylon.language::Sequence<ceylon.language::Iterable<ceylon.language::String>>", false, false); method = (Map<String, Object>) model.get("parmtypes3"); ModelUtils.checkType(method, "ceylon.language::Sequence<ceylon.language::String>"); method = (Map<String, Object>) model.get("parmtypes4"); ModelUtils.checkType(method, "SomethingElse"); List<Map<String, Object>> cons = (List<Map<String, Object>>) method.get(MetamodelGenerator.KEY_TYPE_PARAMS); ModelUtils.checkTypeParameters( 0, (List<Map<String, Object>>) cons.get(0).get(MetamodelGenerator.KEY_SATISFIES), "ceylon.language::Comparable<Something>"); ModelUtils.checkTypeParameters( 0, (List<Map<String, Object>>) cons.get(1).get(MetamodelGenerator.KEY_SATISFIES), "Something"); method = (Map<String, Object>) model.get("parmtypes5"); ModelUtils.checkParam(method, 0, "x", "Value", false, false); cons = (List<Map<String, Object>>) method.get(MetamodelGenerator.KEY_TYPE_PARAMS); Assert.assertNotNull("parmtypes5 should have parameters", cons); Assert.assertNotNull("parmtypes5 should have case types", cons.get(0).get("of")); ModelUtils.checkTypeParameters( 0, (List<Map<String, Object>>) cons.get(0).get("of"), "ceylon.language::Integer,ceylon.language::Float"); }
@Test @SuppressWarnings("unchecked") public void testAttributes() { Map<String, Object> attrib = (Map<String, Object>) model.get("i1"); ModelUtils.checkType(attrib, "ceylon.language::Integer"); Assert.assertEquals( "Wrong model type for i1", MetamodelGenerator.METATYPE_ATTRIBUTE, attrib.get(MetamodelGenerator.KEY_METATYPE)); attrib = (Map<String, Object>) model.get("s1"); ModelUtils.checkType(attrib, "ceylon.language::String"); ModelUtils.checkAnnotations(attrib, "shared"); attrib = (Map<String, Object>) model.get("pi"); ModelUtils.checkType(attrib, "ceylon.language::Float"); ModelUtils.checkAnnotations(attrib, "variable"); attrib = (Map<String, Object>) model.get("seq"); ModelUtils.checkType(attrib, "ceylon.language::Sequence<ceylon.language::Integer>"); ModelUtils.checkAnnotations(attrib, "shared", "variable"); attrib = (Map<String, Object>) model.get("union"); ModelUtils.checkType(attrib, "ceylon.language::Integer|ceylon.language::String"); attrib = (Map<String, Object>) model.get("useq"); ModelUtils.checkType( attrib, "ceylon.language::Iterable<ceylon.language::Singleton<ceylon.language::Integer>|ceylon.language::String>"); }