Exemplo n.º 1
0
		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);
		}
Exemplo n.º 2
0
		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 }));
		}
Exemplo n.º 3
0
		public void asososTest()
		{
			var a = new AtomicNameInstance('a', new LinearPosition(0));
			var s = new AtomicNameInstance('s', new LinearPosition(1));
			var o = new AtomicNameInstance('o', new LinearPosition(2));
			var s_ = new AtomicNameInstance('s', new LinearPosition(3));
			var o_ = new AtomicNameInstance('o', new LinearPosition(4));
			var s__ = new AtomicNameInstance('s', new LinearPosition(5));

			var root = new CompositeNameInstance(new NameInstance[] { a, s, o, s_, o_, s__ }.ToList(), new LinearPosition(0));
			root.SetParent(null);

			var inferrer = new NameInstanceNameInferrer(new[] { Notations.sos, Notations.aso }.ToReadOnlyList());

			var result = inferrer.Match(root).ToList();

			Contract.Assert(result.Count == 1);
			Contract.Assert(result[0].Select(match => (match.Binding.Name as Name).Notation).ContainsSameElements(Notations.aso.Notation, Notations.sos.Notation));
			Contract.Assert(result[0][result[0].IndexOf(match => (match.Binding.Name as Name).Notation == Notations.aso)].Binding.Index.Index == 0);
			Contract.Assert(result[0][result[0].IndexOf(match => (match.Binding.Name as Name).Notation == Notations.sos)].Binding.Index.Index == 3);

		}