public void LoadFooProduction() { var symbol = new Symbol(typeof(A)); var expected = new ProductionRule(symbol, new[] { symbol, symbol }, mFooInfo); var actual = ProductionRule.Load(mFooInfo); Assert.AreEqual(expected, actual); }
public void ReductionFoo() { var lhs = Node.Make(new A(42)); var rhs = Node.Make(new A(-41)); var production = ProductionRule.Load(mFooInfo); var product = production.Reduce(new[] { lhs, rhs }); Assert.AreEqual(1, (product.Payload as A).Val); }
public void LoadBarProduction() { var symbolA = new Symbol(typeof(A)); var symbolB = new Symbol(typeof(A.B)); var expected = new ProductionRule(symbolA, new[] { symbolA, symbolB, symbolA }, mBarInfo); var actual = ProductionRule.Load(mBarInfo); Assert.AreEqual(expected, actual); }
public void ReductionBar() { var lhs = Node.Make(new A(1)); var mid = Node.Make(new A.B(2)); var rhs = Node.Make(new A(3)); var production = ProductionRule.Load(mBarInfo); var product = production.Reduce(new[] { lhs, mid, rhs }); Assert.AreEqual(6, (product.Payload as A).Val); }
public void LoadAllProductionsFromClass() { var expected = new[] { ProductionRule.Load(mFooInfo), ProductionRule.Load(mBarInfo) }; var actual = ProductionRule.LoadAllInClass(typeof(A)); Assert.IsTrue(actual.ToHashSet().SetEquals(expected)); }