Navigation Menu

Skip to content

Commit

Permalink
bq: throw exception for missing close parenthesis for and/or
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 6, 2012
1 parent 1f41ec3 commit d596d37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/bq-translator.js
Expand Up @@ -81,10 +81,10 @@ BooleanQueryTranslator.prototype = {
expression = this.translateGroupFilter();
break;
case "and":
expression = this.translateGroupSetOperation("&&");
expression = this.translateGroupSetOperation(operator, "&&");
break;
case "or":
expression = this.translateGroupSetOperation("||");
expression = this.translateGroupSetOperation(operator, "||");
break;
default:
this.offset = operatorEndOffset;
Expand Down Expand Up @@ -166,7 +166,7 @@ BooleanQueryTranslator.prototype = {

this.throwTranslateError("close parenthesis is missing: operator:<filter>");
},
translateGroupSetOperation: function(setOperator) {
translateGroupSetOperation: function(label, setOperator) {
var expressions = [];
while (this.offset < this.query.length) {
this.skipSpaces();
Expand All @@ -178,8 +178,8 @@ BooleanQueryTranslator.prototype = {
}
}

// TODO: report error: missing close paren <)>
return "";
this.throwTranslateError("close parenthesis is missing: " +
"operator:<" + label + ">");
},
translateExpression: function() {
if (this.query[this.offset] == "(") {
Expand Down
8 changes: 4 additions & 4 deletions test/bq-translator.test.js
Expand Up @@ -185,10 +185,10 @@ suite('BoolanQueryTranslator', function() {
"(filter ||",
"close parenthesis is missing: operator:<filter>");

// testGroupError("and: missing close parentheis",
// "(and f1:'k1' f2:'k2'",
// "(and f1:'k1' f2:'k2'||",
// "close parenthesis is missing: operator:<and>");
testGroupError("and: missing close parentheis",
"(and f1:'k1' f2:'k2'",
"(and f1:'k1' f2:'k2'||",
"close parenthesis is missing: operator:<and>");

testExpression("value only: stirng: and: space",
"'keyword1 keyword2' 'other keyword'",
Expand Down

0 comments on commit d596d37

Please sign in to comment.