Project

General

Profile

Backport #8436 ยป dir_eval.diff

Gat (Dawid Janczak), 05/23/2013 02:31 AM

View differences:

test/ruby/test_method.rb (working copy)
def test___dir__
assert_instance_of String, __dir__
assert_equal(File.dirname(__FILE__), __dir__)
assert_equal(File.dirname(File.realpath(__FILE__)), __dir__)
assert_equal(__dir__, eval("__dir__", binding))
end
def test_alias_owner
vm_eval.c (working copy)
int state;
VALUE result = Qundef;
VALUE envval;
VALUE absolute_path = Qnil;
rb_thread_t *th = GET_THREAD();
rb_env_t *env = NULL;
rb_block_t block, *base_block;
......
if (strcmp(file, "(eval)") == 0 && bind->path != Qnil) {
file = RSTRING_PTR(bind->path);
line = bind->first_lineno;
absolute_path = rb_current_realfilepath();
}
}
else {
......
/* make eval iseq */
th->parse_in_eval++;
th->mild_compile_error++;
iseqval = rb_iseq_compile_on_base(src, rb_str_new2(file), INT2FIX(line), base_block);
iseqval = rb_iseq_compile_with_option(src, rb_str_new2(file), absolute_path, INT2FIX(line), base_block, Qnil);
th->mild_compile_error--;
th->parse_in_eval--;
    (1-1/1)