public void Accept1() { int level = 1; string name = "FOO"; string patt = "9V99"; BcProgram program = BackDoor.Parse( X.A(X.D(X.DA_DIV)), X.A(X.PIC(level, name, patt)), X.A(X.D(X.PR_DIV)), X.B(X.ACCEPT(name)) ); Assert.IsNotNull(program); Assert.AreEqual(0, program.Identifications.Count); Assert.AreEqual(1, program.Data.Count); ValidateDataField(program.Data[0], level, name, patt); Assert.AreEqual(1, program.Paragraphs.Count); var paraname = program.Paragraphs.Keys.First(); Assert.AreEqual("", paraname); Assert.AreEqual(1, program.Paragraphs[paraname].Sentences.Count); Assert.AreEqual(1, program.Paragraphs[paraname].Sentences[0].Statements.Count); var stmt = program.Paragraphs[paraname].Sentences[0].Statements[0] as BcAccept; Assert.IsNotNull(stmt); Assert.AreEqual(1, stmt.Accepted.Count); Assert.AreEqual(name, stmt.Accepted[0].Name); }
public void EmptyProgram() { string input = String.Empty; BcProgram program = BackDoor.Parse( X.A(X.D(X.ID_DIV)) ); Assert.IsNotNull(program); Assert.AreEqual(0, program.Identifications.Count); Assert.AreEqual(0, program.Paragraphs.Count); }
public void TopLevelPicName() { int level = 1; string name = "PICTUREISCOOL"; string patt = "X(20)"; BcProgram program = BackDoor.Parse( X.A(X.D(X.DA_DIV)), X.A(X.PIC(level, name, patt)) ); Assert.IsNotNull(program); Assert.AreEqual(0, program.Identifications.Count); Assert.AreEqual(1, program.Data.Count); X.ValidateDataField(program.Data[0], level, name, patt); }
public void TopLevelLike() { int level = 3; string name1 = "FOO", name2 = "BAR"; string patt = "X(20)"; BcProgram program = BackDoor.Parse( X.A(X.D(X.DA_DIV)), X.A(X.PIC(level, name1, patt)), X.A(X.LIKE(level, name2, name1)) ); Assert.IsNotNull(program); Assert.AreEqual(0, program.Identifications.Count); Assert.AreEqual(2, program.Data.Count); X.ValidateDataField(program.Data[0], level, name1, patt); X.ValidateDataField(program.Data[1], level, name2, patt); }
public void TopLevelPicLike() { int level = 3; string name1 = "LY"; string patt1 = "S9(10)V9(2)"; BcProgram program = BackDoor.Parse( X.A(X.D(X.DA_DIV)), X.A(X.PIC(level, name1, patt1)), X.A("03 UNLIKELY.") // should be perceived as UN LIKE LY where LY is a PIC above ); Assert.IsNotNull(program); Assert.AreEqual(0, program.Identifications.Count); Assert.AreEqual(2, program.Data.Count); X.ValidateDataField(program.Data[0], level, name1, patt1); X.ValidateDataField(program.Data[1], level, "UN", patt1); }
public void OneClaimBoolean() { string claim = "AUTHOR-is-grammarware"; string input = String.Empty; BcProgram program = BackDoor.Parse( X.A(X.D(X.ID_DIV)), X.B(X.D(claim)) ); Assert.IsNotNull(program); Assert.AreEqual(1, program.Identifications.Count); string k = program.Identifications.Keys.First(); Assert.AreEqual(claim, k); Assert.AreEqual("", program.Identifications[k]); Assert.AreEqual(0, program.Paragraphs.Count); }
public void OneClaimManyDots() { string claim1 = "AUTHOR"; string claim2 = "g.r.a.m.m.a.r.w.a.r.e"; string input = String.Empty; BcProgram program = BackDoor.Parse( X.A(X.D(X.ID_DIV)), X.B(X.D(claim1) + X.D(claim2)) ); Assert.IsNotNull(program); Assert.AreEqual(1, program.Identifications.Count); string k = program.Identifications.Keys.First(); Assert.AreEqual(claim1, k); Assert.AreEqual(claim2, program.Identifications[k]); Assert.AreEqual(0, program.Paragraphs.Count); }
public void NestedPicName2() { int level1 = 1, level2 = 5; string name1 = "UNLIKELY", name2 = "FOO"; string patt = "99999V999"; BcProgram program = BackDoor.Parse( X.A(X.D(X.DA_DIV)), X.A(X.VIEW(level1, name1)), X.B(X.PIC(level2, name2, patt)) ); Assert.IsNotNull(program); Assert.AreEqual(0, program.Identifications.Count); Assert.AreEqual(1, program.Data.Count); var view = program.Data[0] as BcDataView; Assert.IsNotNull(view); Assert.AreEqual(level1, view.Level); Assert.AreEqual(name1, view.Name); Assert.AreEqual(1, view.Inners.Count); X.ValidateDataField(view.Inners[0], level2, name2, patt); }