Commit 04edab4c authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2368 from take-cheeze/partial_hook_fix

Treat partial hook success '\n' to fix #2361 .
parents ff4ca4c1 39bbdd5f
require 'tempfile'
assert('Compiling multiple files without new line in last line. #2361') do
a, b, out = Tempfile.new('a.rb'), Tempfile.new('b.rb'), Tempfile.new('out.mrb')
a.write('module A; end')
a.flush
b.write('module B; end')
b.flush
result = `bin/mrbc -c -o #{out.path} #{a.path} #{b.path} 2>&1`
assert_equal "bin/mrbc:#{a.path}:Syntax OK", result.chomp
assert_equal 0, $?.exitstatus
end
......@@ -3389,7 +3389,7 @@ nextc(parser_state *p)
else {
if (p->cxt->partial_hook(p) < 0)
return -1;
return -2;
return '\n';
}
}
......@@ -3777,7 +3777,6 @@ read_escape(parser_state *p)
eof:
case -1:
case -2:
yyerror(p, "Invalid escape character syntax");
return '\0';
......@@ -4093,7 +4092,6 @@ parser_yylex(parser_state *p)
case '#': /* it's a comment */
skip(p, '\n');
/* fall through */
case -2: /* end of partial script. */
case '\n':
maybe_heredoc:
heredoc_treat_nextline(p);
......@@ -4128,7 +4126,6 @@ parser_yylex(parser_state *p)
goto retry;
}
case -1: /* EOF */
case -2: /* end of partial script */
goto normal_newline;
default:
pushback(p, c);
......@@ -5450,7 +5447,7 @@ mrb_parser_set_filename(struct mrb_parser_state *p, const char *f)
sym = mrb_intern_cstr(p->mrb, f);
p->filename = mrb_sym2name_len(p->mrb, sym, NULL);
p->lineno = (p->filename_table_length > 0)? 0 : 1;
p->lineno = (p->filename_table_length > 0)? -1 : 1;
for (i = 0; i < p->filename_table_length; ++i) {
if (p->filename_table[i] == sym) {
......
......@@ -209,6 +209,7 @@ module MRuby
def run_bintest
targets = @gems.select { |v| File.directory? "#{v.dir}/bintest" }.map { |v| filename v.dir }
targets << filename(".") if File.directory? "./bintest"
sh "ruby test/bintest.rb #{targets.join ' '}"
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment