Commit f78d2fad authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

Merge branch 'master' of github.com:mruby/mruby

parents e65d4938 7752d2ab
......@@ -33,12 +33,13 @@ project(mruby C)
# TODO stop polluting source tree with CMakeFiles/ and CMakeCache.txt
# on build location check failure
# Make sure we are not trying to generate in in-tree build unless building
# with a MSVC IDE where it's OK.
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
# with an MSVC or Xcode IDE where it's OK.
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT (MSVC_IDE OR XCODE))
message(FATAL_ERROR
"\nIn-source builds are not allowed as CMake would overwrite the "
"Makefiles distributed with mruby. Please change to the 'build' "
"subdirectory and run CMake from there.")
"Makefiles distributed with mruby. Delete any created 'CMakeFiles' "
"subdirectory and 'CMakeCache.txt' file from the current directory, "
"change to the 'build' subdirectory, and re-run CMake from there.")
endif()
if(COMMAND cmake_policy)
......
......@@ -208,23 +208,19 @@ genop_peep(codegen_scope *s, mrb_code i, int val)
case OP_SETCV:
case OP_SETCONST:
case OP_SETMCNST:
switch (c0) {
case OP_MOVE:
if (c0 == OP_MOVE) {
if (GETARG_A(i) == GETARG_A(i0)) {
s->iseq[s->pc-1] = MKOP_ABx(c1, GETARG_B(i0), GETARG_Bx(i));
return;
}
break;
}
break;
case OP_SETUPVAR:
switch (c0) {
case OP_MOVE:
if (c0 == OP_MOVE) {
if (GETARG_A(i) == GETARG_A(i0)) {
s->iseq[s->pc-1] = MKOP_ABC(c1, GETARG_B(i0), GETARG_B(i), GETARG_C(i));
return;
}
break;
}
break;
case OP_EPOP:
......
......@@ -416,7 +416,7 @@ mrb_struct_initialize_withArg(mrb_state *mrb, int argc, mrb_value *argv, mrb_val
mrb_raise(mrb, E_ARGUMENT_ERROR, "struct size differs");
}
st = RSTRUCT(self);
st->ptr = malloc(sizeof(mrb_value)*argc);
st->ptr = mrb_malloc(mrb, sizeof(mrb_value)*argc);
st->len = n;
memcpy(st->ptr, argv, sizeof(mrb_value)*argc);
//if (n > argc) {
......
......@@ -112,7 +112,17 @@ assert('Kernel#respond_to?', '15.3.1.2.43') do
respond_to? :nil?
end
# TODO at the moment doesn't comply to ISO assert('Kernel#send', '15.3.1.2.44') do
assert('Kernel#send', '15.3.1.2.44') do
# test with block
l = send(:lambda) do
true
end
l.call and l.class == Proc and
# test with argument
send(:respond_to?, :nil?) and
# test without argument and without block
send(:public_methods).class == Array
end
assert('Kernel#singleton_methods', '15.3.1.2.45') do
singleton_methods.class == Array
......
......@@ -5,6 +5,53 @@ assert('Module', '15.2.2') do
Module.class == Class
end
assert('Module#const_defined?', '15.2.2.4.20') do
module Test4ConstDefined
Const4Test4ConstDefined = true
end
Test4ConstDefined.const_defined?(:Const4Test4ConstDefined) and
not Test4ConstDefined.const_defined?(:NotExisting)
end
assert('Module#const_get', '15.2.2.4.21') do
module Test4ConstGet
Const4Test4ConstGet = 42
end
Test4ConstGet.const_get(:Const4Test4ConstGet) == 42
end
assert('Module.const_missing', '15.2.2.4.22') do
e1 = nil
module Test4ConstMissing
def const_missing(sym)
# ATM this redirect doesn't work
puts "PLEASE GO TO TEST CASE Module.const_missing!"
puts "IT IS WORKING NOW!! PLEASE FINALIZE."
puts "Thanks :)"
end
end
begin
Test4ConstMissing.const_get(:ConstDoesntExist)
rescue => e2
e1 = e2
end
e1.class == NameError
end
assert('Module#const_get', '15.2.2.4.23') do
module Test4ConstSet
Const4Test4ConstSet = 42
end
Test4ConstSet.const_set(:Const4Test4ConstSet, 23)
Test4ConstSet.const_get(:Const4Test4ConstSet) == 23
end
# TODO not implemented ATM assert('Module.constants', '15.2.2') do
# TODO not implemented ATM assert('Module.nesting', '15.2.2') do
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