Navigation Menu

Skip to content

Commit

Permalink
bq: throw exception for missing close parenthesis in operator
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 6, 2012
1 parent 5fe20dd commit 83c5ac2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/bq-translator.js
Expand Up @@ -93,7 +93,8 @@ BooleanQueryTranslator.prototype = {
}
this.skipSpaces();
if (this.query[this.offset] != ")") {
this.throwTranslateError("close parenthesis is missing");
this.throwTranslateError("close parenthesis is missing " +
"for operator: <" + operator + ">");
}
this.offset++;
return expression;
Expand All @@ -105,8 +106,7 @@ BooleanQueryTranslator.prototype = {
}
}

// TODO: report error: missing close paren <)>
return "";
this.throwTranslateError("close parenthesis is missing");
},
translateGroupField: function() {
var field = "";
Expand Down
6 changes: 5 additions & 1 deletion test/bq-translator.test.js
Expand Up @@ -130,9 +130,13 @@ suite('BoolanQueryTranslator', function() {
"(nonexistent f1:'k1' f2:'k2')",
"(nonexistent| |f1:'k1' f2:'k2')",
"unknown operator: <nonexistent>");
testGroupError("missing close parentheis",
testGroupError("missing close parentheis: after operator",
"(and f1:'k1' f2:'k2'",
"(and f1:'k1' f2:'k2'||",
"close parenthesis is missing for operator: <and>");
testGroupError("missing close parentheis: in operator",
"(an",
"(an||",
"close parenthesis is missing");
testGroupError("missing operator",
"()",
Expand Down

0 comments on commit 83c5ac2

Please sign in to comment.