[Groonga-commit] groonga/gcs [master] bq: throw exception for missing close parenthesis in operator

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 6日 (月) 13:22:03 JST


Kouhei Sutou	2012-08-06 13:22:03 +0900 (Mon, 06 Aug 2012)

  New Revision: 83c5ac299b390a7eb0b4610ea315cf591ad13844
  https://github.com/groonga/gcs/commit/83c5ac299b390a7eb0b4610ea315cf591ad13844

  Log:
    bq: throw exception for missing close parenthesis in operator

  Modified files:
    lib/bq-translator.js
    test/bq-translator.test.js

  Modified: lib/bq-translator.js (+3 -3)
===================================================================
--- lib/bq-translator.js    2012-08-06 13:17:22 +0900 (1e97797)
+++ lib/bq-translator.js    2012-08-06 13:22:03 +0900 (6d57652)
@@ -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;
@@ -105,8 +106,7 @@ BooleanQueryTranslator.prototype = {
       }
     }
 
-    // TODO: report error: missing close paren <)>
-    return "";
+    this.throwTranslateError("close parenthesis is missing");
   },
   translateGroupField: function() {
     var field = "";

  Modified: test/bq-translator.test.js (+5 -1)
===================================================================
--- test/bq-translator.test.js    2012-08-06 13:17:22 +0900 (8229d7d)
+++ test/bq-translator.test.js    2012-08-06 13:22:03 +0900 (2345a44)
@@ -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",
                  "()",
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
下載 



Groonga-commit メーリングリストの案内
Back to archive index