예제 #1
0
 void GetStartingFixture(Tree <Cell> table)
 {
     try {
         activeFixture = processor.ParseTree <Cell, Interpreter>(table.Branches[0]);
         flowFixture   = null;
     }
     catch (TypeMissingException) {
         activeFixture = processor.ParseTree <Cell, Interpreter>(new CellTree("fitlibrary.DoFixture"));
         flowFixture   = (FlowInterpreter)activeFixture;
     }
 }
예제 #2
0
        public void Interpret(CellProcessor processor, Tree <Cell> table)
        {
            processor.TestStatus.TableCount--;
            var name = processor.ParseTree <Cell, MemberName>(new EnumeratedTree <Cell>(table.Branches[0].Branches.Skip(1).Alternate()));

            processor.Get <Procedures>().Save(name.ToString(), table);
        }
예제 #3
0
        public BindingOperation Make(Tree <Cell> nameCell)
        {
            var name = nameCell.Value.Text.Trim();

            if (NoOperationIsImpliedBy(name))
            {
                return(new NoBinding());
            }

            if (CheckIsImpliedBy(name))
            {
                return(new CheckBinding(processor, targetProvider, nameCell));
            }

            var memberName = processor.ParseTree <Cell, MemberName>(nameCell);
            var member     = MemberQuery.FindInstance(processor.FindMember, targetProvider,
                                                      new MemberSpecification(memberName, 1));

            if (member == null && newIdentifier.IsStartOf(name))
            {
                string newMemberName = name.Substring(4);
                return(new CreateBinding(processor, adapter, newMemberName));
            }

            return(new InputBinding(processor, targetProvider, nameCell));
        }
예제 #4
0
        public static TypedValue InvokeSpecialAction(this Tree <Cell> row, CellProcessor processor, FlowInterpreter interpreter)
        {
            var specialActionName = processor.ParseTree <Cell, MemberName>(row.Branches[0]);
            var result            = processor.Operate <InvokeSpecialOperator>(new TypedValue(interpreter), specialActionName, row.Branches[0]);

            return(result);
        }
예제 #5
0
        public object Evaluate(DomainAdapter theFixture, CellProcessor processor) {
            cells.ValueAt(0).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);

            var cellCount = cells.Branches.Count;
            if (cellCount < 2) throw MakeException("missing cells");
            var identifier = cells.ValueAt(1).Text;
            if (newIdentifier.Equals(identifier)) {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return new MethodPhrase(cells.Skip(1)).EvaluateNew(processor);
            }
            if (typeIdentifier.Equals(identifier)) {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                if (cellCount < 3) throw MakeException("missing cells");
                cells.ValueAt(2).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxSUT);
                return processor.ParseTree(typeof (Type), cells.Branches[2]).Value;
            }
            if (currentIdentifier.Equals(identifier)) {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return theFixture.SystemUnderTest;
            }
            var fixture = theFixture as FlowInterpreter;
            if (fixture == null) throw MakeException("flow fixture required");

            return processor.Get<Symbols>().HasValue(identifier)
                ? processor.Get<Symbols>().GetValue(identifier)
                : fixture.ExecuteFlowRowMethod(processor, cells);
        }
예제 #6
0
        public BindingOperation Make(Tree <Cell> nameCell)
        {
            string name = nameCell.Value.Text.Trim();

            if (NoOperationIsImpliedBy(name))
            {
                return(new NoBinding());
            }

            var cellOperation = new CellOperationImpl(processor);

            if (CheckIsImpliedBy(name))
            {
                return(new CheckBinding(cellOperation, targetProvider, nameCell));
            }

            string memberName = processor.ParseTree <Cell, MemberName>(nameCell).ToString();

            RuntimeMember member = RuntimeType.FindInstance(targetProvider, new IdentifierName(memberName), 1);

            if (member == null && newIdentifier.IsStartOf(name))
            {
                string newMemberName = name.Substring(4);
                return(new CreateBinding(processor, adapter, newMemberName));
            }

            return(new InputBinding(processor, targetProvider, nameCell));
        }
예제 #7
0
 static Interpreter MakeNewFixture(CellProcessor processor, Tree<Cell> firstRow) {
     var fixture = processor.ParseTree<Cell, Interpreter>(firstRow.Skip(1));
     if (firstRow.Branches.Count > 2) {
         var adapter = fixture as MutableDomainAdapter;
         if (adapter != null) {
             var parent = processor.CallStack.DomainAdapter.GetValueAs<DomainAdapter>();
             adapter.SetSystemUnderTest(new MethodPhrase(firstRow.Skip(2)).Evaluate(parent, processor));
         }
     }
     return fixture;
 }
예제 #8
0
파일: Compute.cs 프로젝트: GibSral/fitsharp
        void ComputeRow(CellProcessor processor, Tree<Cell> row) {
            var memberName = processor.ParseTree<Cell, MemberName>(headerRow.Branches.Last()).WithNamedParameters();

            var parameterList = new List<Tree<Cell>>();
            for (var i = 0; i < headerRow.Branches.Count - 1; i++) {
                parameterList.Add(new CellTreeLeaf(new GracefulName(headerRow.ValueAt(i).Text).ToString()));
                parameterList.Add(row.Branches[i]);
            }
            var result = processor.Invoke(processor.CallStack.DomainAdapter, memberName, 
                                          new EnumeratedTree<Cell>(parameterList));
            processor.Check(result, row.Branches.Last());
        }
예제 #9
0
        void ComputeRow(CellProcessor processor, Tree<Cell> row)
        {
            var memberName = MemberName.NamedParameterPrefix + processor.ParseTree<Cell, MemberName>(headerRow.Branches.Last());

            var parameterList = new List<Tree<Cell>>();
            for (var i = 0; i < headerRow.Branches.Count - 1; i++) {
                parameterList.Add(new CellTreeLeaf(new GracefulName(headerRow.Branches[i].Value.Text).ToString()));
                parameterList.Add(row.Branches[i]);
            }
            var result = processor.Invoke(new TypedValue(SystemUnderTest), memberName,
                                          new EnumeratedTree<Cell>(parameterList));
            new CellOperationImpl(processor).Check(result, row.Branches.Last());
        }
예제 #10
0
 public static TypedValue InvokeSpecialAction(this Tree<Cell> row, CellProcessor processor, FlowInterpreter interpreter)
 {
     var specialActionName = processor.ParseTree<Cell, MemberName>(row.Branches[0]);
     try {
         var result = processor.Operate<InvokeSpecialOperator>(new TypedValue(interpreter), specialActionName, row);
         if (result.IsValid) {
             SetSyntaxKeyword(row);
         }
         return result;
     }
     catch (System.Exception) {
             SetSyntaxKeyword(row);
         throw;
     }
 }
예제 #11
0
        static Interpreter MakeNewFixture(CellProcessor processor, Tree <Cell> firstRow)
        {
            var fixture = processor.ParseTree <Cell, Interpreter>(firstRow.Skip(1));

            if (firstRow.Branches.Count > 2)
            {
                var adapter = fixture as MutableDomainAdapter;
                if (adapter != null)
                {
                    var parent = processor.CallStack.DomainAdapter.GetValueAs <DomainAdapter>();
                    adapter.SetSystemUnderTest(new MethodPhrase(firstRow.Skip(2)).Evaluate(parent, processor));
                }
            }
            return(fixture);
        }
예제 #12
0
        void ComputeRow(CellProcessor processor, Tree <Cell> row)
        {
            var memberName = MemberName.NamedParameterPrefix + processor.ParseTree <Cell, MemberName>(headerRow.Branches.Last());

            var parameterList = new List <Tree <Cell> >();

            for (var i = 0; i < headerRow.Branches.Count - 1; i++)
            {
                parameterList.Add(new CellTreeLeaf(new GracefulName(headerRow.Branches[i].Value.Text).ToString()));
                parameterList.Add(row.Branches[i]);
            }
            var result = processor.Invoke(new TypedValue(SystemUnderTest), memberName,
                                          new EnumeratedTree <Cell>(parameterList));

            new CellOperationImpl(processor).Check(result, row.Branches.Last());
        }
예제 #13
0
        public void Evaluate(CellProcessor processor, FlowInterpreter interpreter)
        {
            var specialActionName = processor.ParseTree<Cell, MemberName>(row.Branches[0]);
            var result = processor.Operate<InvokeSpecialOperator>(new TypedValue(interpreter), specialActionName, row.Branches[0]);
            if (result.IsValid) {
                row.ValueAt(0).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return;
            }

            if (!result.IsValid) {
                processor.Execute(interpreter,
                        interpreter.MethodRowSelector.SelectMethodCells(row),
                        interpreter.MethodRowSelector.SelectParameterCells(row),
                        row.ValueAt(0));
            }
        }
예제 #14
0
        void ComputeRow(CellProcessor processor, Tree <Cell> row)
        {
            var memberName = processor.ParseTree <Cell, MemberName>(headerRow.Branches.Last()).WithNamedParameters();

            var parameterList = new List <Tree <Cell> >();

            for (var i = 0; i < headerRow.Branches.Count - 1; i++)
            {
                parameterList.Add(new CellTreeLeaf(new GracefulName(headerRow.ValueAt(i).Text).ToString()));
                parameterList.Add(row.Branches[i]);
            }
            var result = processor.Invoke(processor.CallStack.DomainAdapter, memberName,
                                          new EnumeratedTree <Cell>(parameterList));

            processor.Check(result, row.Branches.Last());
        }
예제 #15
0
        public static TypedValue InvokeSpecialAction(this Tree <Cell> row, CellProcessor processor, FlowInterpreter interpreter)
        {
            var specialActionName = processor.ParseTree <Cell, MemberName>(row.Branches[0]);

            try {
                var result = processor.Operate <InvokeSpecialOperator>(new TypedValue(interpreter), specialActionName, row);
                if (result.IsValid)
                {
                    SetSyntaxKeyword(row);
                }
                return(result);
            }
            catch (System.Exception) {
                SetSyntaxKeyword(row);
                throw;
            }
        }
예제 #16
0
파일: FlowRow.cs 프로젝트: Tej-S/fitsharp
        public void Evaluate(CellProcessor processor, FlowInterpreter interpreter)
        {
            var specialActionName = processor.ParseTree <Cell, MemberName>(row.Branches[0]);
            var result            = processor.Operate <InvokeSpecialOperator>(new TypedValue(interpreter), specialActionName, row.Branches[0]);

            if (result.IsValid)
            {
                row.ValueAt(0).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return;
            }

            if (!result.IsValid)
            {
                processor.Execute(interpreter,
                                  interpreter.MethodRowSelector.SelectMethodCells(row),
                                  interpreter.MethodRowSelector.SelectParameterCells(row),
                                  row.ValueAt(0));
            }
        }
        public object Evaluate(DomainAdapter theFixture, CellProcessor processor)
        {
            cells.ValueAt(0).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);

            var cellCount = cells.Branches.Count;

            if (cellCount < 2)
            {
                throw MakeException("missing cells");
            }
            var identifier = cells.ValueAt(1).Text;

            if (newIdentifier.Equals(identifier))
            {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return(new MethodPhrase(cells.Skip(1)).EvaluateNew(processor));
            }
            if (typeIdentifier.Equals(identifier))
            {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                if (cellCount < 3)
                {
                    throw MakeException("missing cells");
                }
                cells.ValueAt(2).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxSUT);
                return(processor.ParseTree(typeof(Type), cells.Branches[2]).Value);
            }
            if (currentIdentifier.Equals(identifier))
            {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return(theFixture.SystemUnderTest);
            }
            var fixture = theFixture as FlowInterpreter;

            if (fixture == null)
            {
                throw MakeException("flow fixture required");
            }

            return(processor.Get <Symbols>().HasValue(identifier)
                ? processor.Get <Symbols>().GetValue(identifier)
                : fixture.ExecuteFlowRowMethod(processor, cells));
        }
예제 #18
0
파일: Binding.cs 프로젝트: skolima/fitsharp
 string GetMemberName(Tree<Cell> members)
 {
     return processor.ParseTree<Cell, MemberName>(members).ToString();
 }
예제 #19
0
 MemberName GetMemberName(Tree <Cell> members)
 {
     return(processor.ParseTree <Cell, MemberName>(members));
 }
예제 #20
0
파일: Define.cs 프로젝트: x97mdr/fitsharp
        public void Interpret(Tree <Cell> table)
        {
            var name = processor.ParseTree <Cell, MemberName>(new EnumeratedTree <Cell>(table.Branches[0].Branches.Skip(1).Alternate()));

            processor.Store(new Procedure(name.ToString(), table));
        }
예제 #21
0
 public void Interpret(CellProcessor processor, Tree<Cell> table)
 {
     processor.TestStatus.TableCount--;
     var name = processor.ParseTree<Cell, MemberName>(new EnumeratedTree<Cell>(table.Branches[0].Branches.Skip(1).Alternate()));
     processor.Get<Procedures>().Save(name.ToString(), table);
 }