public void AToThePower2Test() { var treeLeafA = new AtomicNameInstance('a', new AbsoluteScriptPosition()); var treeLeafA2 = new AtomicNameInstance('2', new AbsoluteScriptPosition(Script.Super/********************/.ToSingleton())); var root = new CompositeNameInstance(new NameInstance[] { treeLeafA, treeLeafA2 }.ToList(), new LinearPosition(0)); treeLeafA.SetParent(root); treeLeafA2.SetParent(root); var inferrer = new NameInstanceNameInferrer(new[] { Notations.aSup2 }.ToReadOnlyList()); var result = inferrer.Match(root).ToList(); Contract.Assert(result.Count == 1); Contract.Assert(result[0].Count == 1); Contract.Assert((result[0][0].Binding.Name as Name).Notation == Notations.aSup2); Contract.Assert(result[0][0].Binding.Index == (LeafIndex)0); Contract.Assert(result[0][0].Occupation.SequenceEqual(new[] { true, true })); }
public void AToThePowerBSeparateTest() { var treeLeafA = new AtomicNameInstance('a', new AbsoluteScriptPosition()); var treeLeafA2 = new AtomicNameInstance('b', new AbsoluteScriptPosition(Script.Super.ToSingleton())); var root = new CompositeNameInstance(new NameInstance[] { treeLeafA, treeLeafA2 }.ToList(), new LinearPosition(0)); treeLeafA.SetParent(root); treeLeafA2.SetParent(root); var result = inferrer.Match(root).ToList(); Contract.Assert(result.Count == 1); }
public void ASub2FailTest() { //tests that a_2 is not matched by a^2 var treeLeafA = new AtomicNameInstance('a', new AbsoluteScriptPosition()); var treeLeafA2 = new AtomicNameInstance('2', new AbsoluteScriptPosition(Script.Sub/**********************/.ToSingleton())); var root = new CompositeNameInstance(new NameInstance[] { treeLeafA, treeLeafA2 }.ToList(), new LinearPosition(0)); treeLeafA.SetParent(root); treeLeafA2.SetParent(root); var inferrer = new NameInstanceNameInferrer(new[] { Notations.aSup2 }.ToReadOnlyList()); var result = inferrer.Match(root).ToList(); Contract.Assert(result.Count == 0); }
public void LeafTest() { var treeLeafA = new AtomicNameInstance('a', new LinearPosition(0)); treeLeafA.SetParent(null); var root = treeLeafA; var result = inferrer.Match(root).ToList(); Contract.Assert(result.Count == 1); Contract.Assert(result[0].Count == 1); Contract.Assert(Contract.ForAll(result[0], f => f.Occupation.Cast<bool>().All())); var expectation = new NameBindingWithFilling(Notations.a, (LeafIndex)0, null/*dummy*/, new[] { true }); Contract.Assert(expectation.Equals(result[0][0])); //nothing to reify here, there is only a root }