Skip to content

Commit 84469ec

Browse files
authored
Fix broken SPA and Integration Test (#224)
* Fix broken builds * Revert erroneous refactor * Clang-format
1 parent d1d1da2 commit 84469ec

File tree

4 files changed

+16
-35
lines changed

4 files changed

+16
-35
lines changed

Team20/Code20/IntegrationTesting/TestPQLEvaluator.cpp

-23
Original file line numberDiff line numberDiff line change
@@ -387,29 +387,6 @@ TEST_CLASS(TestPqlEvaluator) {
387387
Assert::IsTrue(expected == actual);
388388
}
389389

390-
TEST_METHOD(TestEvaluateParsedQuery_SelectMultipleNoClause) {
391-
// constant c; procedure p; Select <p, c>
392-
ParsedQuery pq = {{{"c", TokenType::CONSTANT}, {"p", TokenType::PROCEDURE}},
393-
{"p", "c"},
394-
{}};
395-
std::list<std::string> expected = {
396-
"main 0", "main 1",
397-
"main 5", "main 11111111111111111111111111111111111111",
398-
"extra 0", "extra 1",
399-
"extra 5", "extra 11111111111111111111111111111111111111",
400-
"complicate 0", "complicate 1",
401-
"complicate 5", "complicate 11111111111111111111111111111111111111",
402-
"aux 0", "aux 1",
403-
"aux 5", "aux 11111111111111111111111111111111111111",
404-
405-
};
406-
std::list<std::string> actual;
407-
Pql::evaluate(pq, pkb.getQueryInterface(), actual);
408-
expected.sort();
409-
actual.sort();
410-
Assert::IsTrue(expected == actual);
411-
}
412-
413390
TEST_METHOD(TestEvaluateParsedQuery_SelectTuple) {
414391
/* All seen synonyms
415392
read r1; read r2; Select <r2, r1> such that Follows(r1, r2)

Team20/Code20/source/PQLEvaluator.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ void Pql::evaluate(ParsedQuery pq, PkbQueryInterface *queryHandler,
1414
for (auto &relationship : pq.relationships) {
1515
ClauseDispatcher *dispatcher =
1616
ClauseDispatcher::FromRelationship(relationship, queryHandler);
17-
// Early termination if clause evaluates to false
18-
if (dispatcher->willReturnBoolean() && !dispatcher->booleanDispatch()) {
19-
delete dispatcher;
20-
return;
17+
if (dispatcher->willReturnBoolean()) {
18+
// Early termination if clause evaluates to false
19+
if (!dispatcher->booleanDispatch()) {
20+
delete dispatcher;
21+
return;
22+
}
2123
} else {
2224
EvaluationTable clauseResult = dispatcher->resultDispatch();
2325
delete dispatcher;
@@ -29,10 +31,12 @@ void Pql::evaluate(ParsedQuery pq, PkbQueryInterface *queryHandler,
2931
for (auto &pattern : pq.patterns) {
3032
ClauseDispatcher *dispatcher =
3133
ClauseDispatcher::FromPattern(pattern, queryHandler);
32-
// Early termination if clause evaluates to false
33-
if (dispatcher->willReturnBoolean() && !dispatcher->booleanDispatch()) {
34-
delete dispatcher;
35-
return;
34+
if (dispatcher->willReturnBoolean()) {
35+
// Early termination if clause evaluates to false
36+
if (!dispatcher->booleanDispatch()) {
37+
delete dispatcher;
38+
return;
39+
}
3640
} else {
3741
EvaluationTable clauseResult = dispatcher->resultDispatch();
3842
delete dispatcher;

Team20/Code20/source/PQLParser.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,13 @@ void PqlParser::parseWithClause() {
390390
}
391391

392392
void PqlParser::parseAttributeCompare() {
393-
const auto firstRef = getRef();
393+
getRef();
394394
getNextExpectedToken(TokenType::EQUALS);
395-
const auto secondRef = getRef();
395+
getRef();
396396
// TODO: Add ref to with clause handling
397397
}
398398

399-
PqlToken PqlParser::getRef() {
399+
void PqlParser::getRef() {
400400
// TODO: Return new ref instead of pqltoken
401401
switch (it->type) {
402402
case TokenType::STRING: {

Team20/Code20/source/PQLParser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ class PqlParser {
3535
PqlToken getNextExpectedToken(TokenType expectedTokenType);
3636
PqlToken getNextTokenWithDeclarationTypeInArgumentsList(
3737
std::unordered_set<TokenType> &argumentsList);
38-
PqlToken getRef();
38+
void getRef();
3939
};

0 commit comments

Comments
 (0)