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

ast.c: argument must be a string

[ruby-core:90904] [Bug #15511]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2019-01-06 05:07:10 +00:00
parent 6629588aa5
commit dd3ed41cd0
2 changed files with 9 additions and 1 deletions

2
ast.c
View file

@ -96,7 +96,7 @@ rb_ast_parse_str(VALUE str)
{
rb_ast_t *ast = 0;
str = rb_check_string_type(str);
StringValue(str);
ast = rb_parser_compile_string_path(ast_parse_new(), Qnil, str, 1);
return ast_parse_done(ast);
}

View file

@ -134,6 +134,14 @@ class TestAst < Test::Unit::TestCase
assert_raise(TypeError) {RubyVM::AbstractSyntaxTree::Node.allocate}
end
def test_parse_argument_error
assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(0)}
assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(nil)}
assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(false)}
assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(true)}
assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(:foo)}
end
def test_column_with_long_heredoc_identifier
term = "A"*257
ast = RubyVM::AbstractSyntaxTree.parse("<<-#{term}\n""ddddddd\n#{term}\n")