コード例 #1
0
        /// <summary>
        /// Registers a change in the text buffer for the language service. The processing of the change is asynchronous, so it does not block the caller.
        /// </summary>
        public void TextBufferChanged(GherkinTextBufferChange change)
        {
            if (isDisposed)
                throw new ObjectDisposedException("GherkinLanguageService");

            var task = new ParsingTask(this, change);

            projectScope.GherkinProcessingScheduler.EnqueueParsingRequest(task);
//            task.Apply(); // synchronous execution
        }
コード例 #2
0
            public IGherkinProcessingTask Merge(IGherkinProcessingTask other)
            {
                ParsingTask otherParsingTask = other as ParsingTask;

                if (otherParsingTask == null || languageService != otherParsingTask.languageService)
                {
                    return(null);
                }

                return(new ParsingTask(
                           languageService, GherkinTextBufferChange.Merge(change, otherParsingTask.change)));
            }
コード例 #3
0
        /// <summary>
        /// Registers a change in the text buffer for the language service. The processing of the change is asynchronous, so it does not block the caller.
        /// </summary>
        public void TextBufferChanged(GherkinTextBufferChange change)
        {
            if (isDisposed)
            {
                throw new ObjectDisposedException("GherkinLanguageService");
            }

            var task = new ParsingTask(this, change);

            projectScope.GherkinProcessingScheduler.EnqueueParsingRequest(task);
//            task.Apply(); // synchronous execution
        }
コード例 #4
0
        public void TwoSymbolsOneDuplicate_WillReturnOneEntry()
        {
            // Arrange
            var symbolTable = new SymbolTable();

            symbolTable.Add(new Symbol("a", QLType.Decimal, null));
            symbolTable.Add(new Symbol("a", QLType.Decimal, null));

            // Act & Assert
            var duplicateDetector = new DuplicateSymbolDetectionPipelineElement();
            var task = new ParsingTask("");

            task.SymbolTable = symbolTable;
            Assert.AreEqual(1, duplicateDetector.Process(task).Errors.Count);
        }
コード例 #5
0
        public void FourSymbolsTwoDuplicatedOnce_WillReturnTwoEntries()
        {
            // Arrange
            var symbolTable = new SymbolTable();

            symbolTable.Add(new Symbol("a", QLType.Decimal, null));
            symbolTable.Add(new Symbol("a", QLType.Decimal, null));
            symbolTable.Add(new Symbol("d", QLType.Decimal, null));
            symbolTable.Add(new Symbol("d", QLType.Boolean, null));

            // Act & Assert
            var duplicateDetector = new DuplicateSymbolDetectionPipelineElement();
            var task = new ParsingTask("");

            task.SymbolTable = symbolTable;
            Assert.AreEqual(2, duplicateDetector.Process(task).Errors.Count);
        }
コード例 #6
0
        public void OneConditionalAssignment_WillRemoveTheIfBlock()
        {
            // Arrange
            var         parsingTask = new ParsingTask(TestDataResolver.LoadTestFile("oneConditional.ql"));
            ParsingTask taskOutput  = _parsingPipeline.Process(parsingTask);
            var         newAst      = _interpreter.EvaluateAst(parsingTask.Ast, _memory, parsingTask.SymbolTable);

            _assertVisitor.EnqueueQuestionNodeCallback(q =>
            {
                Assert.AreEqual("elseQuestion", q.Description);
            });

            // Act
            newAst.Accept(_assertVisitor);

            // Verify
            _assertVisitor.VerifyAll();
        }
コード例 #7
0
        public void OneLiteralBooleanEvaluation_WillEvaluateCorrectly()
        {
            // Arrange
            var         parsingTask = new ParsingTask(TestDataResolver.LoadTestFile("oneBooleanEvaluation.ql"));
            ParsingTask taskOutput  = _parsingPipeline.Process(parsingTask);
            var         newAst      = _interpreter.EvaluateAst(taskOutput.Ast, _memory, taskOutput.SymbolTable);

            _assertVisitor.EnqueueLiteralNodeCallback(ln =>
            {
                Assert.AreEqual(true, bool.Parse(ln.Value));
            });

            // Act
            newAst.Accept(_assertVisitor);

            // Verify
            _assertVisitor.VerifyAll();
        }
コード例 #8
0
        public void TwoQuestionsOneReference_WillResolveTheReferenceAndCalculateCorrectValue()
        {
            // Arrange
            var         parsingTask = new ParsingTask(TestDataResolver.LoadTestFile("twoQuestionsOneReference.ql"));
            ParsingTask taskOutput  = _parsingPipeline.Process(parsingTask);

            _memory.AssignValue("whatIsMeaning", _valueFactory.CreateValue(42, QLType.Integer));
            var newAst = _interpreter.EvaluateAst(parsingTask.Ast, _memory, parsingTask.SymbolTable);

            _assertVisitor.EnqueueLiteralNodeCallback(lt =>
            {
                Assert.AreEqual(42, int.Parse(lt.Value));
            });
            _assertVisitor.EnqueueLiteralNodeCallback(lt =>
            {
                Assert.AreEqual(84, int.Parse(lt.Value));
            });

            // Act
            newAst.Accept(_assertVisitor);

            // Verify
            _assertVisitor.VerifyAll();
        }