1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/json/parser/parser.h (GET_PARSER): raise TypeError.

* ext/json/parser/parser.rl (cParser_initialize): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-02-05 02:29:18 +00:00
parent 9cc62abc6b
commit 1069e5d665
5 changed files with 10 additions and 6 deletions

View file

@ -1,4 +1,8 @@
Sat Feb 5 10:29:52 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
Sat Feb 5 11:29:10 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/json/parser/parser.h (GET_PARSER): raise TypeError.
* ext/json/parser/parser.rl (cParser_initialize): ditto.
* ext/json/parser/parser.h (GET_PARSER): check if initialized.
[ruby-core:35079]

View file

@ -1613,7 +1613,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
GET_PARSER_INIT;
if (json->Vsource) {
rb_raise(rb_eArgError, "already initialized instance");
rb_raise(rb_eTypeError, "already initialized instance");
}
rb_scan_args(argc, argv, "11", &source, &opts);
source = convert_encoding(StringValue(source));

View file

@ -45,7 +45,7 @@ typedef struct JSON_ParserStruct {
#define GET_PARSER \
GET_PARSER_INIT; \
if (!json->Vsource) rb_raise(rb_eArgError, "uninitialized instance")
if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
#define GET_PARSER_INIT \
JSON_Parser *json; \
Data_Get_Struct(self, JSON_Parser, json)

View file

@ -611,7 +611,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
GET_PARSER_INIT;
if (json->Vsource) {
rb_raise(rb_eArgError, "already initialized instance");
rb_raise(rb_eTypeError, "already initialized instance");
}
rb_scan_args(argc, argv, "11", &source, &opts);
source = convert_encoding(StringValue(source));

View file

@ -394,8 +394,8 @@ EOT
def test_allocate
json = JSON::Parser.new("{}")
assert_raises(ArgumentError, '[ruby-core:35079]') {json.__send__(:initialize, "{}")}
assert_raises(TypeError, '[ruby-core:35079]') {json.__send__(:initialize, "{}")}
json = JSON::Parser.allocate
assert_raises(ArgumentError, '[ruby-core:35079]') {json.source}
assert_raises(TypeError, '[ruby-core:35079]') {json.source}
end
end