@@ -852,8 +852,6 @@ def test_parse_error_snippet
852852 end
853853
854854 def test_parse_error_json_path
855- omit "JRuby errors don't contain positions" if RUBY_ENGINE == "jruby"
856-
857855 assert_parse_error_at "$" , "xyz"
858856 assert_parse_error_at "$.a" , '{"a": xyz}'
859857 assert_parse_error_at "$[3]" , '[1, 2, "hi", xyz]'
@@ -870,9 +868,17 @@ def test_parse_error_json_path
870868 assert_parse_error_at "$[5]" , '[1,2,3,4,5,]'
871869 end
872870
873- def test_parse_error_json_path_on_load
874- omit "JRuby errors don't contain positions" if RUBY_ENGINE == "jruby"
871+ def test_parse_error_position
872+ error = assert_raise ( JSON ::ParserError ) { JSON . parse ( "[1,\n @" ) }
873+ assert_equal 2 , error . line
874+ assert_equal 1 , error . column
875+
876+ error = assert_raise ( JSON ::ParserError ) { JSON . parse ( '{"a": {"b": [1, {"c": 1, "c": 2}]}}' ) }
877+ assert_equal 1 , error . line
878+ assert_equal 17 , error . column
879+ end
875880
881+ def test_parse_error_json_path_on_load
876882 assert_parse_error_at "$" do
877883 JSON . load ( '{"a": {"b": {"c":' , -> ( obj ) {
878884 if String === obj
@@ -895,8 +901,6 @@ def test_parse_error_json_path_on_load
895901 end
896902
897903 def test_parse_error_json_path_key_escaping
898- omit "JRuby errors don't contain positions" if RUBY_ENGINE == "jruby"
899-
900904 assert_parse_error_at '$["hello world"]' , '{"hello world": xyz}'
901905 assert_parse_error_at '$["a\"b"]' , '{"a\"b": xyz}'
902906 assert_parse_error_at '$[""]' , '{"": xyz}'
@@ -905,8 +909,6 @@ def test_parse_error_json_path_key_escaping
905909 end
906910
907911 def test_parse_error_json_path_duplicate_key
908- omit "JRuby errors don't contain positions" if RUBY_ENGINE == "jruby"
909-
910912 assert_parse_error_at "$.a" , '{"a": 1, "a": 2}'
911913 assert_parse_error_at "$.x.a" , '{"x": {"a": 1, "b": 2, "a": 3}}'
912914 assert_parse_error_at "$.arr[0].a" , '{"arr": [{"a": 1, "a": 2}]}'
0 commit comments