public void AlternativeInitializationConcept_Embedded() { string dsl = "SIMPLE s d { ALTER1 { ALTER2 d2; } }"; var grammar = new IConceptInfo[] { new SimpleConceptInfo(), new AlternativeConcept1(), new AlternativeConcept2() }; var parsedConcepts = new TestDslParser(dsl, grammar).ParsedConcepts; Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+SimpleConceptInfo Name=s Data=d", parsedConcepts.OfType<SimpleConceptInfo>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+AlternativeConcept1 Parent=s Name=a1 RefToParent=ref.s", parsedConcepts.OfType<AlternativeConcept1>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+AlternativeConcept2 Alter1=s.a1 Name=a2 Data=d2", parsedConcepts.OfType<AlternativeConcept2>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+RefConceptInfo Name=ref Reference=s", parsedConcepts.OfType<RefConceptInfo>().Single().GetErrorDescription()); // Embedded concepts have the parent reference resolved during parsing, so the SimpleConceptInfo reference has a value of the Data property: Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+SimpleConceptInfo Name=s Data=d", parsedConcepts.OfType<RefConceptInfo>().Single().Reference.GetErrorDescription()); }
public void AlternativeInitializationConceptTest() { string dsl = "SIMPLE s d; ALTER1 s; ALTER2 s.a1 d2;"; var grammar = new IConceptInfo[] { new SimpleConceptInfo(), new AlternativeConcept1(), new AlternativeConcept2() }; var parsedConcepts = new TestDslParser(dsl, grammar).ParsedConcepts; Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+SimpleConceptInfo Name=s Data=d", parsedConcepts.OfType<SimpleConceptInfo>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+AlternativeConcept1 Parent=s Name=a1 RefToParent=ref.s", parsedConcepts.OfType<AlternativeConcept1>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+AlternativeConcept2 Alter1=s.a1 Name=a2 Data=d2", parsedConcepts.OfType<AlternativeConcept2>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+RefConceptInfo Name=ref Reference=s", parsedConcepts.OfType<RefConceptInfo>().Single().GetErrorDescription()); // References are not yet resolved when evaluating IAlternativeInitializationConcept, so the SimpleConceptInfo reference does not have a value of the Data property: Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+SimpleConceptInfo Name=s Data=<null>", parsedConcepts.OfType<RefConceptInfo>().Single().Reference.GetErrorDescription(), "This test does not describe the wanted behavior, it just describes the current state of the parser."); }
public void AlternativeInitializationConcept_Embedded() { string dsl = "SIMPLE s d { ALTER1 { ALTER2 d2; } }"; var grammar = new IConceptInfo[] { new SimpleConceptInfo(), new AlternativeConcept1(), new AlternativeConcept2() }; var parsedConcepts = new TestDslParser(dsl, grammar).ParsedConcepts; Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+SimpleConceptInfo Name=s Data=d", parsedConcepts.OfType <SimpleConceptInfo>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+AlternativeConcept1 Parent=s Name=a1 RefToParent=ref.s", parsedConcepts.OfType <AlternativeConcept1>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+AlternativeConcept2 Alter1=s.a1 Name=a2 Data=d2", parsedConcepts.OfType <AlternativeConcept2>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+RefConceptInfo Name=ref Reference=s", parsedConcepts.OfType <RefConceptInfo>().Single().GetErrorDescription()); // Embedded concepts have the parent reference resolved during parsing, so the SimpleConceptInfo reference has a value of the Data property: Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+SimpleConceptInfo Name=s Data=d", parsedConcepts.OfType <RefConceptInfo>().Single().Reference.GetErrorDescription()); }
public void AlternativeInitializationConceptTest() { string dsl = "SIMPLE s d; ALTER1 s; ALTER2 s.a1 d2;"; var grammar = new IConceptInfo[] { new SimpleConceptInfo(), new AlternativeConcept1(), new AlternativeConcept2() }; var parsedConcepts = new TestDslParser(dsl, grammar).ParsedConcepts; Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+SimpleConceptInfo Name=s Data=d", parsedConcepts.OfType <SimpleConceptInfo>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+AlternativeConcept1 Parent=s Name=a1 RefToParent=ref.s", parsedConcepts.OfType <AlternativeConcept1>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+AlternativeConcept2 Alter1=s.a1 Name=a2 Data=d2", parsedConcepts.OfType <AlternativeConcept2>().Single().GetErrorDescription()); Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+RefConceptInfo Name=ref Reference=s", parsedConcepts.OfType <RefConceptInfo>().Single().GetErrorDescription()); // References are not yet resolved when evaluating IAlternativeInitializationConcept, so the SimpleConceptInfo reference does not have a value of the Data property: Assert.AreEqual("Rhetos.Dsl.Test.DslParserTest+SimpleConceptInfo Name=s Data=<null>", parsedConcepts.OfType <RefConceptInfo>().Single().Reference.GetErrorDescription(), "This test does not describe the wanted behavior, it just describes the current state of the parser."); }