Example #1
0
        public void ValidateSelect_ShouldReturnFalse_WhenCallsSyntaxIsIncorrect(string queryToValidate)
        {
            DeclarationsArray declarations = new DeclarationsArray();
            SelectValidator   validator    = new SelectValidator(declarations);
            bool result = validator.ValidateSelectQuery(queryToValidate);

            Assert.True(result);
        }
Example #2
0
        public void SelectWithValidator_ShouldReturnFalse_WhenDeclarationMissing(string queryToValidate)
        {
            DeclarationsArray declarationsArray = new DeclarationsArray();

            SelectWithValidator validator = new SelectWithValidator(queryToValidate, declarationsArray);
            bool result = validator.isGrammarCorrect();

            Assert.False(result);
        }
Example #3
0
        public void ValidateSelectBoolean_ShouldReturnFalse_WhenModifiesIsAmbiguous()
        {
            DeclarationsArray declarations = new DeclarationsArray();
            // Use of underscore must not lead to ambiguities. For example, the following query should be rejected
            // as incorrect as it is not clear if underscore refers to a statement or to a procedure
            SelectValidator validator = new SelectValidator(declarations);
            bool            result    = validator.ValidateSelectQuery("select boolean such that Modifies (_, \"x\")");

            Assert.False(result);
        }
Example #4
0
        public void SelectWithValidator_ShouldReturnFalse_WhenSynonymTypeOtherThanProgLine(string queryToValidate, string declarationName, string declarationType)
        {
            DeclarationsArray declarationsArray = new DeclarationsArray();

            declarationsArray.AddDeclaration(declarationType, declarationName);

            SelectWithValidator validator = new SelectWithValidator(queryToValidate, declarationsArray);
            bool result = validator.isGrammarCorrect();

            Assert.False(result);
        }
Example #5
0
        public void SelectWithValidator_ShouldReturnTrue(string queryToValidate, string declarationName, string declarationType)
        {
            DeclarationsArray declarationsArray = new DeclarationsArray();

            declarationsArray.AddDeclaration(declarationType, declarationName);

            SelectWithValidator validator = new SelectWithValidator(queryToValidate, declarationsArray);
            bool result = validator.isGrammarCorrect();

            Assert.True(result);
        }
Example #6
0
        public void ValidateAttrRef_ShouldReturnFalse_WhenWrongDesignEntity(string input, string designEntity, string declarationName)
        {
            DeclarationsArray declarationsArray = new DeclarationsArray();

            declarationsArray.AddDeclaration(designEntity, declarationName);

            AttrRef attrRef = new AttrRef(input, declarationsArray);
            bool    result  = attrRef.IsGrammarCorrect();

            Assert.False(result);
        }
Example #7
0
        public void ValidateAttrName_ShouldReturnFalse_WhenIncorrectDeclarationType(string attrName, string declarationName, string declarationType)
        {
            DeclarationsArray declarations = new DeclarationsArray();

            declarations.AddDeclaration(declarationType, declarationName);

            AbstractAuxiliaryGrammar attrNameValidator = new AttrName(attrName, declarationName, declarations);
            bool result = attrNameValidator.IsGrammarCorrect();

            Assert.False(result);
        }
Example #8
0
        public void ValidateSelectBoolean_ShouldReturnTrue_WhenModifies(string queryToValidate)
        {
            DeclarationsArray declarations = new DeclarationsArray();
            // Modifies design entity relationships:
            // Modifies(procedure, variable)
            // Modifies(stmt, variable)
            SelectValidator validator = new SelectValidator(declarations);
            bool            result    = validator.ValidateSelectQuery(queryToValidate);

            Assert.True(result);
        }
Example #9
0
        public void ValidateSelect_ShouldReturnFalse_WhenSuchThatUsedIncorrectly(string queryToValidate)
        {
            DeclarationsArray declarations = new DeclarationsArray();
            // **such that grammar rules** //
            // suchthat - cl : ‘such that’ relCond
            // relCond : relRef( ‘and’ relRef) *
            // relRef: ModifiesP | ModifiesS | UsesP | UsesS | Calls | CallsT | Parent | ParentT |
            //          Follows | FollowsT | Next | NextT | Affects | AffectsT
            SelectValidator validator = new SelectValidator(declarations);
            bool            result    = validator.ValidateSelectQuery(queryToValidate);

            Assert.True(result);
        }
Example #10
0
 public AttrCompare(string text, DeclarationsArray Declarations)
 {
     this.text         = text;
     this.Declarations = Declarations;
 }
Example #11
0
 public ProglineSynonym(string text, DeclarationsArray declarations) : base(text)
 {
     this.declarations = declarations;
 }
Example #12
0
 public AttrRef(string text, DeclarationsArray declarations)
 {
     entry             = text;
     this.declarations = declarations;
 }
Example #13
0
 public AttrName(string attrName, string declarationName, DeclarationsArray declarations) : base(attrName)
 {
     this.declarationName = declarationName;
     this.declarations    = declarations;
 }
Example #14
0
 public SuchThat(DeclarationsArray Declarations)
 {
     this.Declarations = Declarations;
     Pkb = Initialization.PkbReference;
 }
Example #15
0
 public Ref(string text, DeclarationsArray declarations)
 {
     this.text         = text.Trim();
     this.declarations = declarations;
 }