#NEWLINE# def test_abstract_rule_and_object_reference( ) : #NEWLINE# #INDENT# grammar = "\n    Model: 'start' rules*=RuleA 'ref' ref=[RuleA];\n    RuleA: Rule1|Rule2;\n    Rule1: RuleI|RuleE;\n    Rule2: 'r2' name=ID;\n    RuleI: 'rI' name=ID;\n    RuleE: 'rE' name=ID;\n    " #NEWLINE# meta = metamodel_from_str ( grammar ) #NEWLINE# assert meta #NEWLINE# assert ( set ( [ x . __name__ for x in meta ] ) == set ( [ 'Model' , 'RuleA' , 'Rule1' , 'Rule2' , 'RuleI' , 'RuleE' ] ) . union ( set ( BASE_TYPE_NAMES ) ) ) #NEWLINE# model = meta . model_from_str ( 'start r2 rule1 rE rule2 ref rule2' ) #NEWLINE# assert model #NEWLINE# assert hasattr ( model , 'rules' ) #NEWLINE# assert hasattr ( model , 'ref' ) #NEWLINE# assert model . rules #NEWLINE# assert model . ref #NEWLINE# assert ( x . ref is model . rules [ 1 ] ) #NEWLINE# assert ( model . ref . __class__ . __name__ == 'RuleE' )