Beispiel #1
0
        public void TestApplyWithSpecificFunc()
        {
            Rule<int> rule = new Rule<int>(new Symbol<int>("A"),
                () => Enumerable.Repeat(0, 5).Select((e, i) => (i * 2)).Select(v => new Symbol<int>(v)));

            IEnumerable<Symbol<int>> to = rule.Produce();
            int[] sequence = to.Select(s => s.Value).ToArray();
            int[] expectedSequence = {0, 2, 4, 6, 8};
            Assert.AreElementsEqual(expectedSequence, sequence);
        }
Beispiel #2
0
 public void TestProduce()
 {
     Rule<string> rule = new Rule<string>(new Symbol<string>("A"), new[]
         {
             new Symbol<string>("a", ""),
             new Symbol<string>("b", ""),
             new Symbol<string>("c", "")
         });
     IEnumerable<Symbol<string>> to = rule.Produce();
     string[] sequence = to.Select(s => s.Value).ToArray();
     string[] expectedSequence = { "a", "b", "c"};
     Assert.AreElementsEqual(expectedSequence, sequence);
 }