[Groonga-commit] groonga/groonga-command at c4bad05 [fix-travis-ci-error] Support correct error message for garbage before JSON case

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jan 13 17:18:38 JST 2016


Kouhei Sutou	2012-11-27 22:56:44 +0900 (Tue, 27 Nov 2012)

  New Revision: c4bad057d74364c106982bad69be8102d95ff5d7
  https://github.com/groonga/groonga-command/commit/c4bad057d74364c106982bad69be8102d95ff5d7

  Message:
    Support correct error message for garbage before JSON case

  Modified files:
    lib/groonga/command/parser.rb
    test/test-parser.rb

  Modified: lib/groonga/command/parser.rb (+3 -1)
===================================================================
--- lib/groonga/command/parser.rb    2012-11-27 22:26:20 +0900 (1f310ff)
+++ lib/groonga/command/parser.rb    2012-11-27 22:56:44 +0900 (312fe47)
@@ -255,7 +255,9 @@ module Groonga
         else
           spaces, start_json, rest =****@buffe*****("[")
           unless /\A\s*\z/ =~ spaces
-            raise ParseError, "garbage before JSON"
+            raise ParseError.new("there are garbages before JSON",
+                                 @command.original_source.lines.to_a.last,
+                                 spaces)
           end
           if start_json.empty?
             @command.original_source << @buffer

  Modified: test/test-parser.rb (+16 -0)
===================================================================
--- test/test-parser.rb    2012-11-27 22:26:20 +0900 (292d4b8)
+++ test/test-parser.rb    2012-11-27 22:56:44 +0900 (3b75eb5)
@@ -234,6 +234,22 @@ load --table Users
 EOC
             end
           end
+
+          def test_garbage_before_json
+            message = "there are garbages before JSON"
+            before = "load --table Users\n"
+            after = "XXX\n"
+            error = Groonga::Command::ParseError.new(message, before, after)
+            assert_raise(error) do
+              @parser << <<-EOC
+load --table Users
+XXX
+[
+{"_key": "alice", "name": "Alice"}
+]
+EOC
+            end
+          end
         end
       end
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index