mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* hash.c (env_clear): new Hash compatible method.
* hash.c (env_shift): ditto. * hash.c (env_invert): ditto. * hash.c (env_replace): ditto. * hash.c (env_update): ditto. * array.c (rb_ary_join): dispatch based on "to_str". * array.c (rb_ary_times): ditto. * array.c (rb_ary_equal): ditto. * process.c (rb_f_exec): dispatch based on "to_ary". * eval.c (umethod_bind): exact class match is not required. relax the restriction to subclasses. * eval.c (rb_eval): call "inherited" before executing class body. * class.c (rb_define_class): call "inherited" after defining the constant. * class.c (rb_define_class_under): ditto. * eval.c (massign): expand first element if RHS is an array and its size is 1, and LHS has concrete assignment target (i.e. LHS has target(s) other than *var). * eval.c (massign): avoid unnecessary avalue/svalue conversion. * eval.c (rb_yield_0): ditto * array.c (rb_ary_update): do not allocate unused array if rpl is nil (i.e. merely removing elements). * io.c (io_read): should resize supplied string if it's shorter than expected. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
954826f7a8
commit
6d481a4ae4
10 changed files with 505 additions and 124 deletions
54
ChangeLog
54
ChangeLog
|
@ -3,6 +3,18 @@ Tue Jan 7 07:48:01 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
|||
* eval.c (rb_f_local_variables): skip $_, $~ and flip states in
|
||||
dynamic variables. [ruby-core:00681]
|
||||
|
||||
Tue Jan 7 02:46:29 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* hash.c (env_clear): new Hash compatible method.
|
||||
|
||||
* hash.c (env_shift): ditto.
|
||||
|
||||
* hash.c (env_invert): ditto.
|
||||
|
||||
* hash.c (env_replace): ditto.
|
||||
|
||||
* hash.c (env_update): ditto.
|
||||
|
||||
Mon Jan 6 23:36:29 2003 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* st.h, st.c: Introduce new conventional typedef's, st_data_t,
|
||||
|
@ -33,6 +45,16 @@ Mon Jan 6 18:31:45 2003 WATANABE Hirofumi <eban@ruby-lang.org>
|
|||
|
||||
* lib/fileutils.rb (cp_r): add 'p' in the verbose message.
|
||||
|
||||
Mon Jan 6 16:44:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_join): dispatch based on "to_str".
|
||||
|
||||
* array.c (rb_ary_times): ditto.
|
||||
|
||||
* array.c (rb_ary_equal): ditto.
|
||||
|
||||
* process.c (rb_f_exec): dispatch based on "to_ary".
|
||||
|
||||
Mon Jan 6 13:26:35 2003 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* process.c (proc_exec_v): follow to proc_spawn_v(). call do_aspawn()
|
||||
|
@ -137,6 +159,11 @@ Sat Jan 4 14:29:52 2003 NAKAMURA Usaku <usa@ruby-lang.org>
|
|||
* win32/Makefile.sub (config.h): define NEED_IO_FLUSH_BETWEE_SEEK.
|
||||
(pointed out by moriq [ruby-dev:19299])
|
||||
|
||||
Sat Jan 4 03:12:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (umethod_bind): exact class match is not required. relax
|
||||
the restriction to subclasses.
|
||||
|
||||
Sat Jan 4 01:33:40 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* file.c (rb_file_s_lchmod): get rid of gcc-3 -O3 warning.
|
||||
|
@ -145,6 +172,33 @@ Fri Jan 3 22:26:07 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
|||
|
||||
* process.c (rb_proc_times): need to initialize first.
|
||||
|
||||
Fri Jan 3 01:10:17 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_eval): call "inherited" before executing class body.
|
||||
|
||||
* class.c (rb_define_class): call "inherited" after defining the
|
||||
constant.
|
||||
|
||||
* class.c (rb_define_class_under): ditto.
|
||||
|
||||
Thu Jan 2 19:37:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (massign): expand first element if RHS is an array and
|
||||
its size is 1, and LHS has concrete assignment target (i.e. LHS
|
||||
has target(s) other than *var).
|
||||
|
||||
* eval.c (massign): avoid unnecessary avalue/svalue conversion.
|
||||
|
||||
* eval.c (rb_yield_0): ditto
|
||||
|
||||
* array.c (rb_ary_update): do not allocate unused array if rpl is
|
||||
nil (i.e. merely removing elements).
|
||||
|
||||
Thu Jan 2 13:55:08 2003 Mathieu Bouchard <matju@sympatico.ca>
|
||||
|
||||
* io.c (io_read): should resize supplied string if it's shorter
|
||||
than expected.
|
||||
|
||||
Thu Jan 02 11:01:20 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* eval.c (bmcall): arguments should be an array.
|
||||
|
|
45
array.c
45
array.c
|
@ -648,9 +648,6 @@ rb_ary_update(ary, beg, len, rpl)
|
|||
{
|
||||
long rlen;
|
||||
|
||||
rpl = (NIL_P(rpl)) ? rb_ary_new2(0) : rb_ary_to_ary(rpl);
|
||||
rlen = RARRAY(rpl)->len;
|
||||
|
||||
if (len < 0) rb_raise(rb_eIndexError, "negative length (%ld)", len);
|
||||
if (beg < 0) {
|
||||
beg += RARRAY(ary)->len;
|
||||
|
@ -664,6 +661,14 @@ rb_ary_update(ary, beg, len, rpl)
|
|||
}
|
||||
|
||||
rb_ary_modify(ary);
|
||||
if (NIL_P(rpl)) {
|
||||
rlen = 0;
|
||||
}
|
||||
else {
|
||||
rpl = rb_ary_to_ary(rpl);
|
||||
rlen = RARRAY(rpl)->len;
|
||||
}
|
||||
|
||||
if (beg >= RARRAY(ary)->len) {
|
||||
len = beg + rlen;
|
||||
if (len >= RARRAY(ary)->aux.capa) {
|
||||
|
@ -671,7 +676,9 @@ rb_ary_update(ary, beg, len, rpl)
|
|||
RARRAY(ary)->aux.capa = len;
|
||||
}
|
||||
rb_mem_clear(RARRAY(ary)->ptr + RARRAY(ary)->len, beg - RARRAY(ary)->len);
|
||||
MEMCPY(RARRAY(ary)->ptr + beg, RARRAY(rpl)->ptr, VALUE, rlen);
|
||||
if (rlen > 0) {
|
||||
MEMCPY(RARRAY(ary)->ptr + beg, RARRAY(rpl)->ptr, VALUE, rlen);
|
||||
}
|
||||
RARRAY(ary)->len = len;
|
||||
}
|
||||
else {
|
||||
|
@ -692,7 +699,9 @@ rb_ary_update(ary, beg, len, rpl)
|
|||
VALUE, RARRAY(ary)->len - (beg + len));
|
||||
RARRAY(ary)->len = alen;
|
||||
}
|
||||
MEMMOVE(RARRAY(ary)->ptr + beg, RARRAY(rpl)->ptr, VALUE, rlen);
|
||||
if (rlen > 0) {
|
||||
MEMMOVE(RARRAY(ary)->ptr + beg, RARRAY(rpl)->ptr, VALUE, rlen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -836,12 +845,8 @@ rb_ary_join(ary, sep)
|
|||
if (OBJ_TAINTED(ary) || OBJ_TAINTED(sep)) taint = Qtrue;
|
||||
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
if (TYPE(RARRAY(ary)->ptr[i]) == T_STRING) {
|
||||
len += RSTRING(RARRAY(ary)->ptr[i])->len;
|
||||
}
|
||||
else {
|
||||
len += 10;
|
||||
}
|
||||
tmp = rb_check_string_type(RARRAY(ary)->ptr[i]);
|
||||
len += NIL_P(tmp) ? 10 : RSTRING(tmp)->len;
|
||||
}
|
||||
if (!NIL_P(sep)) {
|
||||
StringValue(sep);
|
||||
|
@ -1488,11 +1493,12 @@ static VALUE
|
|||
rb_ary_times(ary, times)
|
||||
VALUE ary, times;
|
||||
{
|
||||
VALUE ary2;
|
||||
VALUE ary2, tmp;
|
||||
long i, len;
|
||||
|
||||
if (TYPE(times) == T_STRING) {
|
||||
return rb_ary_join(ary, times);
|
||||
tmp = rb_check_string_type(times);
|
||||
if (!NIL_P(tmp)) {
|
||||
return rb_ary_join(ary, tmp);
|
||||
}
|
||||
|
||||
len = NUM2LONG(times);
|
||||
|
@ -1557,7 +1563,10 @@ rb_ary_equal(ary1, ary2)
|
|||
long i;
|
||||
|
||||
if (ary1 == ary2) return Qtrue;
|
||||
if (TYPE(ary2) != T_ARRAY) return Qfalse;
|
||||
if (TYPE(ary2) != T_ARRAY) {
|
||||
ary2 = rb_check_array_type(ary2);
|
||||
if (NIL_P(ary2)) return Qfalse;
|
||||
}
|
||||
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
|
||||
for (i=0; i<RARRAY(ary1)->len; i++) {
|
||||
if (!rb_equal(RARRAY(ary1)->ptr[i], RARRAY(ary2)->ptr[i]))
|
||||
|
@ -1572,7 +1581,11 @@ rb_ary_eql(ary1, ary2)
|
|||
{
|
||||
long i;
|
||||
|
||||
if (TYPE(ary2) != T_ARRAY) return Qfalse;
|
||||
if (ary1 == ary2) return Qtrue;
|
||||
if (TYPE(ary2) != T_ARRAY) {
|
||||
ary2 = rb_check_array_type(ary2);
|
||||
if (NIL_P(ary2)) return Qfalse;
|
||||
}
|
||||
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
|
||||
for (i=0; i<RARRAY(ary1)->len; i++) {
|
||||
if (!rb_eql(RARRAY(ary1)->ptr[i], RARRAY(ary2)->ptr[i]))
|
||||
|
|
4
class.c
4
class.c
|
@ -214,8 +214,8 @@ rb_define_class(name, super)
|
|||
rb_warn("no super class for `%s', Object assumed", name);
|
||||
}
|
||||
klass = rb_define_class_id(id, super);
|
||||
rb_class_inherited(super, klass);
|
||||
st_add_direct(rb_class_tbl, id, klass);
|
||||
rb_class_inherited(super, klass);
|
||||
|
||||
return klass;
|
||||
}
|
||||
|
@ -246,8 +246,8 @@ rb_define_class_under(outer, name, super)
|
|||
}
|
||||
klass = rb_define_class_id(id, super);
|
||||
rb_set_class_path(klass, outer, name);
|
||||
rb_class_inherited(super, klass);
|
||||
rb_const_set(outer, id, klass);
|
||||
rb_class_inherited(super, klass);
|
||||
|
||||
return klass;
|
||||
}
|
||||
|
|
85
eval.c
85
eval.c
|
@ -2158,7 +2158,7 @@ call_trace_func(event, node, self, id, klass)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
mrhs_to_svalue(v)
|
||||
avalue_to_svalue(v)
|
||||
VALUE v;
|
||||
{
|
||||
VALUE tmp;
|
||||
|
@ -2178,7 +2178,7 @@ mrhs_to_svalue(v)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
mrhs_to_avalue(v)
|
||||
svalue_to_avalue(v)
|
||||
VALUE v;
|
||||
{
|
||||
VALUE tmp;
|
||||
|
@ -2189,34 +2189,18 @@ mrhs_to_avalue(v)
|
|||
if (NIL_P(tmp)) {
|
||||
return rb_ary_new3(1, v);
|
||||
}
|
||||
if (RARRAY(tmp)->len <= 1) {
|
||||
return rb_ary_new3(1, tmp);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
args_to_svalue(v)
|
||||
VALUE v;
|
||||
{
|
||||
VALUE tmp;
|
||||
|
||||
if (v == Qundef) return v;
|
||||
tmp = rb_check_array_type(v);
|
||||
if (NIL_P(tmp)) {
|
||||
return v;
|
||||
}
|
||||
if (RARRAY(tmp)->len == 0) {
|
||||
return Qundef;
|
||||
}
|
||||
if (RARRAY(tmp)->len == 1) {
|
||||
v = rb_check_array_type(tmp);
|
||||
if (NIL_P(v)) {
|
||||
return RARRAY(tmp)->ptr[0];
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static void return_check _((void));
|
||||
#define return_value(v) prot_tag->retval = (v)
|
||||
#define return_value(v) do {\
|
||||
if ((prot_tag->retval = (v)) == Qundef) {\
|
||||
prot_tag->retval = Qnil;\
|
||||
}\
|
||||
} while (0)
|
||||
|
||||
static VALUE
|
||||
rb_eval(self, n)
|
||||
|
@ -2563,7 +2547,7 @@ rb_eval(self, n)
|
|||
break;
|
||||
|
||||
case NODE_REXPAND:
|
||||
result = mrhs_to_svalue(rb_eval(self, node->nd_head));
|
||||
result = avalue_to_svalue(rb_eval(self, node->nd_head));
|
||||
break;
|
||||
|
||||
case NODE_SVALUE:
|
||||
|
@ -2928,7 +2912,8 @@ rb_eval(self, n)
|
|||
break;
|
||||
|
||||
case NODE_MASGN:
|
||||
result = massign(self, node, rb_eval(self, node->nd_value), 0);
|
||||
result = svalue_to_avalue(rb_eval(self, node->nd_value));
|
||||
result = massign(self, node, result, 0);
|
||||
break;
|
||||
|
||||
case NODE_LASGN:
|
||||
|
@ -3333,9 +3318,8 @@ rb_eval(self, n)
|
|||
rb_extend_object(klass, ruby_wrapper);
|
||||
rb_include_module(klass, ruby_wrapper);
|
||||
}
|
||||
|
||||
result = module_setup(klass, node->nd_body);
|
||||
if (super) rb_class_inherited(super, klass);
|
||||
result = module_setup(klass, node->nd_body);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -3856,10 +3840,11 @@ rb_yield_0(val, self, klass, pcall, avalue)
|
|||
}
|
||||
}
|
||||
else if (nd_type(block->var) == NODE_MASGN) {
|
||||
if (!avalue) val = svalue_to_avalue(val);
|
||||
massign(self, block->var, val, pcall);
|
||||
}
|
||||
else {
|
||||
if (avalue) val = mrhs_to_svalue(val);
|
||||
if (avalue) val = avalue_to_svalue(val);
|
||||
if (val == Qundef) val = Qnil;
|
||||
assign(self, block->var, val, pcall);
|
||||
}
|
||||
|
@ -3876,6 +3861,7 @@ rb_yield_0(val, self, klass, pcall, avalue)
|
|||
result = Qnil;
|
||||
}
|
||||
else if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
|
||||
if (avalue) val = avalue_to_svalue(val);
|
||||
result = (*node->nd_cfnc)(val, node->nd_tval, self);
|
||||
}
|
||||
else {
|
||||
|
@ -3970,12 +3956,30 @@ massign(self, node, val, pcall)
|
|||
NODE *list;
|
||||
long i = 0, len;
|
||||
|
||||
val = mrhs_to_avalue(val);
|
||||
len = RARRAY(val)->len;
|
||||
list = node->nd_head;
|
||||
for (i=0; list && i<len; i++) {
|
||||
assign(self, list->nd_head, RARRAY(val)->ptr[i], pcall);
|
||||
list = list->nd_next;
|
||||
if (len == 1 && list) {
|
||||
VALUE v = RARRAY(val)->ptr[0];
|
||||
VALUE tmp = rb_check_array_type(v);
|
||||
|
||||
if (NIL_P(tmp)) {
|
||||
assign(self, list->nd_head, v, pcall);
|
||||
list = list->nd_next;
|
||||
}
|
||||
else {
|
||||
len = RARRAY(tmp)->len;
|
||||
for (i=0; list && i<len; i++) {
|
||||
assign(self, list->nd_head, RARRAY(tmp)->ptr[i], pcall);
|
||||
list = list->nd_next;
|
||||
}
|
||||
}
|
||||
i = 1;
|
||||
}
|
||||
else {
|
||||
for (; list && i<len; i++) {
|
||||
assign(self, list->nd_head, RARRAY(val)->ptr[i], pcall);
|
||||
list = list->nd_next;
|
||||
}
|
||||
}
|
||||
if (pcall && list) goto arg_error;
|
||||
if (node->nd_args) {
|
||||
|
@ -4059,7 +4063,7 @@ assign(self, lhs, val, pcall)
|
|||
break;
|
||||
|
||||
case NODE_MASGN:
|
||||
massign(self, lhs, val, pcall);
|
||||
massign(self, lhs, svalue_to_avalue(val), pcall);
|
||||
break;
|
||||
|
||||
case NODE_CALL:
|
||||
|
@ -7012,12 +7016,19 @@ umethod_bind(method, recv)
|
|||
st_lookup(RCLASS(CLASS_OF(recv))->m_tbl, data->oid, 0)) {
|
||||
rb_raise(rb_eTypeError, "method `%s' overridden", rb_id2name(data->oid));
|
||||
}
|
||||
#if 0
|
||||
if (!((TYPE(data->rklass) == T_MODULE) ?
|
||||
rb_obj_is_kind_of(recv, data->rklass) :
|
||||
rb_obj_is_instance_of(recv, data->rklass))) {
|
||||
rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
|
||||
rb_class2name(data->rklass));
|
||||
}
|
||||
#else
|
||||
if(!rb_obj_is_kind_of(recv, data->rklass)) {
|
||||
rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
|
||||
rb_class2name(data->rklass));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
method = Data_Make_Struct(rb_cMethod,struct METHOD,bm_mark,free,bound);
|
||||
|
@ -7128,7 +7139,7 @@ static VALUE
|
|||
bmcall(args, method)
|
||||
VALUE args, method;
|
||||
{
|
||||
args = mrhs_to_avalue(args);
|
||||
args = svalue_to_avalue(args);
|
||||
return method_call(RARRAY(args)->len, RARRAY(args)->ptr, method);
|
||||
}
|
||||
|
||||
|
|
110
hash.c
110
hash.c
|
@ -1386,6 +1386,28 @@ env_select(argc, argv)
|
|||
return result;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_clear()
|
||||
{
|
||||
volatile VALUE keys;
|
||||
VALUE *ptr;
|
||||
long len;
|
||||
|
||||
rb_secure(4);
|
||||
keys = env_keys();
|
||||
ptr = RARRAY(keys)->ptr;
|
||||
len = RARRAY(keys)->len;
|
||||
|
||||
while (len--) {
|
||||
VALUE val = rb_f_getenv(Qnil, *ptr);
|
||||
if (!NIL_P(val)) {
|
||||
env_delete(Qnil, *ptr);
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
return envtbl;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_to_s()
|
||||
{
|
||||
|
@ -1585,6 +1607,88 @@ env_reject()
|
|||
return rb_hash_delete_if(env_to_hash());
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_shift()
|
||||
{
|
||||
char **env;
|
||||
|
||||
env = GET_ENVIRON(environ);
|
||||
if (*env) {
|
||||
char *s = strchr(*env, '=');
|
||||
if (s) {
|
||||
VALUE key = rb_tainted_str_new(*env, s-*env);
|
||||
VALUE val = rb_tainted_str_new2(getenv(RSTRING(key)->ptr));
|
||||
env_delete(Qnil, key);
|
||||
return rb_assoc_new(key, val);
|
||||
}
|
||||
}
|
||||
FREE_ENVIRON(environ);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_invert()
|
||||
{
|
||||
return rb_hash_invert(env_to_hash());
|
||||
}
|
||||
|
||||
static int
|
||||
env_replace_i(key, val, keys)
|
||||
VALUE key, val, keys;
|
||||
{
|
||||
if (key != Qundef) {
|
||||
env_aset(Qnil, key, val);
|
||||
if (rb_ary_includes(keys, key)) {
|
||||
rb_ary_delete(keys, key);
|
||||
}
|
||||
}
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_replace(env, hash)
|
||||
VALUE env, hash;
|
||||
{
|
||||
volatile VALUE keys = env_keys();
|
||||
VALUE *ptr;
|
||||
long len;
|
||||
|
||||
if (env == hash) return env;
|
||||
hash = to_hash(hash);
|
||||
st_foreach(RHASH(hash)->tbl, env_replace_i, keys);
|
||||
|
||||
ptr = RARRAY(keys)->ptr;
|
||||
len = RARRAY(keys)->len;
|
||||
|
||||
while (len--) {
|
||||
env_delete(env, *ptr++);
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
static int
|
||||
env_update_i(key, val)
|
||||
VALUE key, val;
|
||||
{
|
||||
if (key != Qundef) {
|
||||
if (rb_block_given_p()) {
|
||||
val = rb_yield(rb_ary_new3(3, key, rb_f_getenv(Qnil, key), val));
|
||||
}
|
||||
env_aset(Qnil, key, val);
|
||||
}
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_update(env, hash)
|
||||
VALUE env, hash;
|
||||
{
|
||||
if (env == hash) return env;
|
||||
hash = to_hash(hash);
|
||||
st_foreach(RHASH(hash)->tbl, env_update_i, 0);
|
||||
return env;
|
||||
}
|
||||
|
||||
void
|
||||
Init_Hash()
|
||||
{
|
||||
|
@ -1665,10 +1769,14 @@ Init_Hash()
|
|||
rb_define_singleton_method(envtbl,"each_value", env_each_value, 0);
|
||||
rb_define_singleton_method(envtbl,"delete", env_delete_m, 1);
|
||||
rb_define_singleton_method(envtbl,"delete_if", env_delete_if, 0);
|
||||
rb_define_singleton_method(envtbl,"clear", env_clear, 0);
|
||||
rb_define_singleton_method(envtbl,"reject", env_reject, 0);
|
||||
rb_define_singleton_method(envtbl,"reject!", env_reject_bang, 0);
|
||||
rb_define_singleton_method(envtbl,"select", env_select, -1);
|
||||
rb_define_singleton_method(envtbl,"to_s", env_to_s, 0);
|
||||
rb_define_singleton_method(envtbl,"shift", env_shift, 0);
|
||||
rb_define_singleton_method(envtbl,"invert", env_invert, 0);
|
||||
rb_define_singleton_method(envtbl,"replace", env_replace, 1);
|
||||
rb_define_singleton_method(envtbl,"update", env_update, 1);
|
||||
rb_define_singleton_method(envtbl,"inspect", env_inspect, 0);
|
||||
rb_define_singleton_method(envtbl,"rehash", env_none, 0);
|
||||
rb_define_singleton_method(envtbl,"to_a", env_to_a, 0);
|
||||
|
|
3
io.c
3
io.c
|
@ -829,6 +829,9 @@ io_read(argc, argv, io)
|
|||
rb_str_resize(str, 0);
|
||||
return str;
|
||||
}
|
||||
if (len > RSTRING(str)->len) {
|
||||
rb_str_resize(str,len);
|
||||
}
|
||||
}
|
||||
|
||||
READ_CHECK(fptr->f);
|
||||
|
|
|
@ -24,9 +24,6 @@ class PStore
|
|||
unless File::directory? dir
|
||||
raise PStore::Error, format("directory %s does not exist", dir)
|
||||
end
|
||||
unless File::writable? dir
|
||||
raise PStore::Error, format("directory %s not writable", dir)
|
||||
end
|
||||
if File::exist? file and not File::readable? file
|
||||
raise PStore::Error, format("file %s not readable", file)
|
||||
end
|
||||
|
@ -93,7 +90,7 @@ class PStore
|
|||
value = nil
|
||||
backup = @filename+"~"
|
||||
begin
|
||||
file = File::open(@filename, "rb+")
|
||||
file = File::open(@filename, read_only ? "rb" : "rb+")
|
||||
orig = true
|
||||
rescue Errno::ENOENT
|
||||
raise if read_only
|
||||
|
|
15
parse.y
15
parse.y
|
@ -137,7 +137,6 @@ static NODE *new_evstr();
|
|||
static NODE *call_op();
|
||||
static int in_defined = 0;
|
||||
|
||||
static NODE *yield_args();
|
||||
static NODE *ret_args();
|
||||
static NODE *arg_blk_pass();
|
||||
static NODE *new_call();
|
||||
|
@ -553,7 +552,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
|||
}
|
||||
| mlhs '=' arg_value
|
||||
{
|
||||
$1->nd_value = NEW_RESTARY($3);
|
||||
$1->nd_value = $3;
|
||||
$$ = $1;
|
||||
}
|
||||
| mlhs '=' mrhs
|
||||
|
@ -695,7 +694,7 @@ command : operation command_args %prec tLOWEST
|
|||
}
|
||||
| kYIELD command_args
|
||||
{
|
||||
$$ = NEW_YIELD(yield_args($2));
|
||||
$$ = NEW_YIELD(ret_args($2));
|
||||
fixpos($$, $2);
|
||||
}
|
||||
;
|
||||
|
@ -1404,7 +1403,7 @@ primary : literal
|
|||
}
|
||||
| kYIELD '(' call_args ')'
|
||||
{
|
||||
$$ = NEW_YIELD(yield_args($3));
|
||||
$$ = NEW_YIELD(ret_args($3));
|
||||
}
|
||||
| kYIELD '(' ')'
|
||||
{
|
||||
|
@ -5198,14 +5197,6 @@ ret_args(node)
|
|||
node = node->nd_head;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static NODE *
|
||||
yield_args(node)
|
||||
NODE *node;
|
||||
{
|
||||
node = ret_args(node);
|
||||
if (node && nd_type(node) == NODE_RESTARY) {
|
||||
nd_set_type(node, NODE_REXPAND);
|
||||
}
|
||||
|
|
12
process.c
12
process.c
|
@ -695,20 +695,20 @@ rb_f_exec(argc, argv)
|
|||
VALUE *argv;
|
||||
{
|
||||
VALUE prog = 0;
|
||||
VALUE tmp;
|
||||
|
||||
if (argc == 0) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
|
||||
if (TYPE(argv[0]) == T_ARRAY) {
|
||||
if (RARRAY(argv[0])->len != 2) {
|
||||
tmp = rb_check_array_type(argv[0]);
|
||||
if (!NIL_P(tmp)) {
|
||||
if (RARRAY(tmp)->len != 2) {
|
||||
rb_raise(rb_eArgError, "wrong first argument");
|
||||
}
|
||||
prog = RARRAY(argv[0])->ptr[0];
|
||||
argv[0] = RARRAY(argv[0])->ptr[1];
|
||||
}
|
||||
if (prog) {
|
||||
prog = RARRAY(tmp)->ptr[0];
|
||||
SafeStringValue(prog);
|
||||
argv[0] = RARRAY(tmp)->ptr[1];
|
||||
}
|
||||
if (argc == 1 && prog == 0) {
|
||||
VALUE cmd = argv[0];
|
||||
|
|
296
sample/test.rb
296
sample/test.rb
|
@ -66,13 +66,13 @@ a = *[*[1,2]]; test_ok(a == [1,2])
|
|||
|
||||
*a = nil; test_ok(a == [nil])
|
||||
*a = 1; test_ok(a == [1])
|
||||
*a = []; test_ok(a == [])
|
||||
*a = [1]; test_ok(a == [1])
|
||||
*a = [nil]; test_ok(a == [nil])
|
||||
*a = [[]]; test_ok(a == [[]])
|
||||
*a = []; test_ok(a == [[]])
|
||||
*a = [1]; test_ok(a == [[1]])
|
||||
*a = [nil]; test_ok(a == [[nil]])
|
||||
*a = [[]]; test_ok(a == [[[]]])
|
||||
*a = [1,2]; test_ok(a == [1,2])
|
||||
*a = [*[]]; test_ok(a == [])
|
||||
*a = [*[1]]; test_ok(a == [1])
|
||||
*a = [*[]]; test_ok(a == [[]])
|
||||
*a = [*[1]]; test_ok(a == [[1]])
|
||||
*a = [*[1,2]]; test_ok(a == [1,2])
|
||||
|
||||
*a = *nil; test_ok(a == [nil])
|
||||
|
@ -80,7 +80,7 @@ a = *[*[1,2]]; test_ok(a == [1,2])
|
|||
*a = *[]; test_ok(a == [])
|
||||
*a = *[1]; test_ok(a == [1])
|
||||
*a = *[nil]; test_ok(a == [nil])
|
||||
*a = *[[]]; test_ok(a == [])
|
||||
*a = *[[]]; test_ok(a == [[]])
|
||||
*a = *[1,2]; test_ok(a == [1,2])
|
||||
*a = *[*[]]; test_ok(a == [])
|
||||
*a = *[*[1]]; test_ok(a == [1])
|
||||
|
@ -132,12 +132,13 @@ def f; yield *[*[1,2]]; end; f {|a| test_ok(a == [1,2])}
|
|||
def f; yield; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield nil; end; f {|*a| test_ok(a == [nil])}
|
||||
def f; yield 1; end; f {|*a| test_ok(a == [1])}
|
||||
def f; yield []; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield [1]; end; f {|*a| test_ok(a == [1])}
|
||||
def f; yield [nil]; end; f {|*a| test_ok(a == [nil])}
|
||||
def f; yield [[]]; end; f {|*a| test_ok(a == [[]])}
|
||||
def f; yield [*[]]; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield [*[1]]; end; f {|*a| test_ok(a == [1])}
|
||||
def f; yield []; end; f {|*a| test_ok(a == [[]])}
|
||||
def f; yield [1]; end; f {|*a| test_ok(a == [[1]])}
|
||||
def f; yield [nil]; end; f {|*a| test_ok(a == [[nil]])}
|
||||
def f; yield [[]]; end; f {|*a| test_ok(a == [[[]]])}
|
||||
def f; yield [1,2]; end; f {|*a| test_ok(a == [1,2])}
|
||||
def f; yield [*[]]; end; f {|*a| test_ok(a == [[]])}
|
||||
def f; yield [*[1]]; end; f {|*a| test_ok(a == [[1]])}
|
||||
def f; yield [*[1,2]]; end; f {|*a| test_ok(a == [1,2])}
|
||||
|
||||
def f; yield *nil; end; f {|*a| test_ok(a == [nil])}
|
||||
|
@ -145,7 +146,7 @@ def f; yield *1; end; f {|*a| test_ok(a == [1])}
|
|||
def f; yield *[]; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield *[1]; end; f {|*a| test_ok(a == [1])}
|
||||
def f; yield *[nil]; end; f {|*a| test_ok(a == [nil])}
|
||||
def f; yield *[[]]; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield *[[]]; end; f {|*a| test_ok(a == [[]])}
|
||||
def f; yield *[*[]]; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield *[*[1]]; end; f {|*a| test_ok(a == [1])}
|
||||
def f; yield *[*[1,2]]; end; f {|*a| test_ok(a == [1,2])}
|
||||
|
@ -171,6 +172,209 @@ def f; yield *[*[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
|
|||
def f; yield *[*[1]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
|
||||
def f; yield *[*[1,2]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,2,[]])}
|
||||
|
||||
def r; return; end; a = r(); test_ok(a == nil)
|
||||
def r; return nil; end; a = r(); test_ok(a == nil)
|
||||
def r; return 1; end; a = r(); test_ok(a == 1)
|
||||
def r; return []; end; a = r(); test_ok(a == [])
|
||||
def r; return [1]; end; a = r(); test_ok(a == [1])
|
||||
def r; return [nil]; end; a = r(); test_ok(a == [nil])
|
||||
def r; return [[]]; end; a = r(); test_ok(a == [[]])
|
||||
def r; return [*[]]; end; a = r(); test_ok(a == [])
|
||||
def r; return [*[1]]; end; a = r(); test_ok(a == [1])
|
||||
def r; return [*[1,2]]; end; a = r(); test_ok(a == [1,2])
|
||||
|
||||
def r; return *nil; end; a = r(); test_ok(a == nil)
|
||||
def r; return *1; end; a = r(); test_ok(a == 1)
|
||||
def r; return *[]; end; a = r(); test_ok(a == nil)
|
||||
def r; return *[1]; end; a = r(); test_ok(a == 1)
|
||||
def r; return *[nil]; end; a = r(); test_ok(a == nil)
|
||||
def r; return *[[]]; end; a = r(); test_ok(a == [])
|
||||
def r; return *[*[]]; end; a = r(); test_ok(a == nil)
|
||||
def r; return *[*[1]]; end; a = r(); test_ok(a == 1)
|
||||
def r; return *[*[1,2]]; end; a = r(); test_ok(a == [1,2])
|
||||
|
||||
def r; return; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return nil; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return 1; end; *a = r(); test_ok(a == [1])
|
||||
def r; return []; end; *a = r(); test_ok(a == [[]])
|
||||
def r; return [1]; end; *a = r(); test_ok(a == [[1]])
|
||||
def r; return [nil]; end; *a = r(); test_ok(a == [[nil]])
|
||||
def r; return [[]]; end; *a = r(); test_ok(a == [[[]]])
|
||||
def r; return [1,2]; end; *a = r(); test_ok(a == [1,2])
|
||||
def r; return [*[]]; end; *a = r(); test_ok(a == [[]])
|
||||
def r; return [*[1]]; end; *a = r(); test_ok(a == [[1]])
|
||||
def r; return [*[1,2]]; end; *a = r(); test_ok(a == [1,2])
|
||||
|
||||
def r; return *nil; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return *1; end; *a = r(); test_ok(a == [1])
|
||||
def r; return *[]; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return *[1]; end; *a = r(); test_ok(a == [1])
|
||||
def r; return *[nil]; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return *[[]]; end; *a = r(); test_ok(a == [[]])
|
||||
def r; return *[1,2]; end; *a = r(); test_ok(a == [1,2])
|
||||
def r; return *[*[]]; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return *[*[1]]; end; *a = r(); test_ok(a == [1])
|
||||
def r; return *[*[1,2]]; end; *a = r(); test_ok(a == [1,2])
|
||||
|
||||
def r; return; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return nil; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return 1; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
|
||||
def r; return []; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return [1]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
|
||||
def r; return [nil]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return [[]]; end; a,b,*c = r(); test_ok([a,b,c] == [[],nil,[]])
|
||||
def r; return [1,2]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]])
|
||||
def r; return [*[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return [*[1]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
|
||||
def r; return [*[1,2]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]])
|
||||
|
||||
def r; return *nil; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return *1; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
|
||||
def r; return *[]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return *[1]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
|
||||
def r; return *[nil]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return *[[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return *[1,2]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]])
|
||||
def r; return *[*[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return *[*[1]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
|
||||
def r; return *[*[1,2]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]])
|
||||
|
||||
a = loop do break; end; test_ok(a == nil)
|
||||
a = loop do break nil; end; test_ok(a == nil)
|
||||
a = loop do break 1; end; test_ok(a == 1)
|
||||
a = loop do break []; end; test_ok(a == [])
|
||||
a = loop do break [1]; end; test_ok(a == [1])
|
||||
a = loop do break [nil]; end; test_ok(a == [nil])
|
||||
a = loop do break [[]]; end; test_ok(a == [[]])
|
||||
a = loop do break [*[]]; end; test_ok(a == [])
|
||||
a = loop do break [*[1]]; end; test_ok(a == [1])
|
||||
a = loop do break [*[1,2]]; end; test_ok(a == [1,2])
|
||||
|
||||
a = loop do break *nil; end; test_ok(a == nil)
|
||||
a = loop do break *1; end; test_ok(a == 1)
|
||||
a = loop do break *[]; end; test_ok(a == nil)
|
||||
a = loop do break *[1]; end; test_ok(a == 1)
|
||||
a = loop do break *[nil]; end; test_ok(a == nil)
|
||||
a = loop do break *[[]]; end; test_ok(a == [])
|
||||
a = loop do break *[*[]]; end; test_ok(a == nil)
|
||||
a = loop do break *[*[1]]; end; test_ok(a == 1)
|
||||
a = loop do break *[*[1,2]]; end; test_ok(a == [1,2])
|
||||
|
||||
*a = loop do break; end; test_ok(a == [nil])
|
||||
*a = loop do break nil; end; test_ok(a == [nil])
|
||||
*a = loop do break 1; end; test_ok(a == [1])
|
||||
*a = loop do break []; end; test_ok(a == [[]])
|
||||
*a = loop do break [1]; end; test_ok(a == [[1]])
|
||||
*a = loop do break [nil]; end; test_ok(a == [[nil]])
|
||||
*a = loop do break [[]]; end; test_ok(a == [[[]]])
|
||||
*a = loop do break [1,2]; end; test_ok(a == [1,2])
|
||||
*a = loop do break [*[]]; end; test_ok(a == [[]])
|
||||
*a = loop do break [*[1]]; end; test_ok(a == [[1]])
|
||||
*a = loop do break [*[1,2]]; end; test_ok(a == [1,2])
|
||||
|
||||
*a = loop do break *nil; end; test_ok(a == [nil])
|
||||
*a = loop do break *1; end; test_ok(a == [1])
|
||||
*a = loop do break *[]; end; test_ok(a == [nil])
|
||||
*a = loop do break *[1]; end; test_ok(a == [1])
|
||||
*a = loop do break *[nil]; end; test_ok(a == [nil])
|
||||
*a = loop do break *[[]]; end; test_ok(a == [[]])
|
||||
*a = loop do break *[1,2]; end; test_ok(a == [1,2])
|
||||
*a = loop do break *[*[]]; end; test_ok(a == [nil])
|
||||
*a = loop do break *[*[1]]; end; test_ok(a == [1])
|
||||
*a = loop do break *[*[1,2]]; end; test_ok(a == [1,2])
|
||||
|
||||
a,b,*c = loop do break; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break nil; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break 1; end; test_ok([a,b,c] == [1,nil,[]])
|
||||
a,b,*c = loop do break []; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break [1]; end; test_ok([a,b,c] == [1,nil,[]])
|
||||
a,b,*c = loop do break [nil]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break [[]]; end; test_ok([a,b,c] == [[],nil,[]])
|
||||
a,b,*c = loop do break [1,2]; end; test_ok([a,b,c] == [1,2,[]])
|
||||
a,b,*c = loop do break [*[]]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break [*[1]]; end; test_ok([a,b,c] == [1,nil,[]])
|
||||
a,b,*c = loop do break [*[1,2]]; end; test_ok([a,b,c] == [1,2,[]])
|
||||
|
||||
a,b,*c = loop do break *nil; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break *1; end; test_ok([a,b,c] == [1,nil,[]])
|
||||
a,b,*c = loop do break *[]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break *[1]; end; test_ok([a,b,c] == [1,nil,[]])
|
||||
a,b,*c = loop do break *[nil]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break *[[]]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break *[1,2]; end; test_ok([a,b,c] == [1,2,[]])
|
||||
a,b,*c = loop do break *[*[]]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break *[*[1]]; end; test_ok([a,b,c] == [1,nil,[]])
|
||||
a,b,*c = loop do break *[*[1,2]]; end; test_ok([a,b,c] == [1,2,[]])
|
||||
|
||||
def r(val); a = yield(); test_ok(a == val); end
|
||||
r(nil){next}
|
||||
r(nil){next nil}
|
||||
r(1){next 1}
|
||||
r([]){next []}
|
||||
r([1]){next [1]}
|
||||
r([nil]){next [nil]}
|
||||
r([[]]){next [[]]}
|
||||
r([]){next [*[]]}
|
||||
r([1]){next [*[1]]}
|
||||
r([1,2]){next [*[1,2]]}
|
||||
|
||||
r(nil){next *nil}
|
||||
r(1){next *1}
|
||||
r(nil){next *[]}
|
||||
r(1){next *[1]}
|
||||
r(nil){next *[nil]}
|
||||
r([]){next *[[]]}
|
||||
r(nil){next *[*[]]}
|
||||
r(1){next *[*[1]]}
|
||||
r([1,2]){next *[*[1,2]]}
|
||||
|
||||
def r(val); *a = yield(); test_ok(a == val); end
|
||||
r([nil]){next}
|
||||
r([nil]){next nil}
|
||||
r([1]){next 1}
|
||||
r([[]]){next []}
|
||||
r([[1]]){next [1]}
|
||||
r([[nil]]){next [nil]}
|
||||
r([[[]]]){next [[]]}
|
||||
r([1,2]){next [1,2]}
|
||||
r([[]]){next [*[]]}
|
||||
r([[1]]){next [*[1]]}
|
||||
r([1,2]){next [*[1,2]]}
|
||||
|
||||
r([nil]){next *nil}
|
||||
r([1]){next *1}
|
||||
r([nil]){next *[]}
|
||||
r([1]){next *[1]}
|
||||
r([nil]){next *[nil]}
|
||||
r([[]]){next *[[]]}
|
||||
r([1,2]){next *[1,2]}
|
||||
r([nil]){next *[*[]]}
|
||||
r([1]){next *[*[1]]}
|
||||
r([1,2]){next *[*[1,2]]}
|
||||
|
||||
def r(val); a,b,*c = yield(); test_ok([a,b,c] == val); end
|
||||
r([nil,nil,[]]){next}
|
||||
r([nil,nil,[]]){next nil}
|
||||
r([1,nil,[]]){next 1}
|
||||
r([nil,nil,[]]){next []}
|
||||
r([1,nil,[]]){next [1]}
|
||||
r([nil,nil,[]]){next [nil]}
|
||||
r([[],nil,[]]){next [[]]}
|
||||
r([1,2,[]]){next [1,2]}
|
||||
r([nil,nil,[]]){next [*[]]}
|
||||
r([1,nil,[]]){next [*[1]]}
|
||||
r([1,2,[]]){next [*[1,2]]}
|
||||
|
||||
r([nil,nil,[]]){next *nil}
|
||||
r([1,nil,[]]){next *1}
|
||||
r([nil,nil,[]]){next *[]}
|
||||
r([1,nil,[]]){next *[1]}
|
||||
r([nil,nil,[]]){next *[nil]}
|
||||
r([nil,nil,[]]){next *[[]]}
|
||||
r([1,2,[]]){next *[1,2]}
|
||||
r([nil,nil,[]]){next *[*[]]}
|
||||
r([1,nil,[]]){next *[*[1]]}
|
||||
r([1,2,[]]){next *[*[1,2]]}
|
||||
test_check "condition"
|
||||
|
||||
$x = '0';
|
||||
|
@ -673,14 +877,14 @@ class IterTest
|
|||
def initialize(e); @body = e; end
|
||||
|
||||
def each0(&block); @body.each(&block); end
|
||||
def each1(&block); @body.each { |*x| block.call(*x) } end
|
||||
def each2(&block); @body.each { |*x| block.call(x) } end
|
||||
def each3(&block); @body.each { |x| block.call(*x) } end
|
||||
def each4(&block); @body.each { |x| block.call(x) } end
|
||||
def each5; @body.each { |*x| yield(*x) } end
|
||||
def each6; @body.each { |*x| yield(x) } end
|
||||
def each7; @body.each { |x| yield(*x) } end
|
||||
def each8; @body.each { |x| yield(x) } end
|
||||
def each1(&block); @body.each {|*x| block.call(*x) } end
|
||||
def each2(&block); @body.each {|*x| block.call(x) } end
|
||||
def each3(&block); @body.each {|x| block.call(*x) } end
|
||||
def each4(&block); @body.each {|x| block.call(x) } end
|
||||
def each5; @body.each {|*x| yield(*x) } end
|
||||
def each6; @body.each {|*x| yield(x) } end
|
||||
def each7; @body.each {|x| yield(*x) } end
|
||||
def each8; @body.each {|x| yield(x) } end
|
||||
|
||||
def f(a)
|
||||
test_ok(a == [1])
|
||||
|
@ -688,38 +892,38 @@ class IterTest
|
|||
end
|
||||
IterTest.new(nil).method(:f).to_proc.call([1])
|
||||
|
||||
IterTest.new([0]).each0 { |x| test_ok(x == 0)}
|
||||
IterTest.new([1]).each1 { |x| test_ok(x == 1)}
|
||||
IterTest.new([2]).each2 { |x| test_ok(x == [2])}
|
||||
IterTest.new([3]).each3 { |x| test_ok(x == 3)}
|
||||
IterTest.new([4]).each4 { |x| test_ok(x == 4)}
|
||||
IterTest.new([5]).each5 { |x| test_ok(x == 5)}
|
||||
IterTest.new([6]).each6 { |x| test_ok(x == [6])}
|
||||
IterTest.new([7]).each7 { |x| test_ok(x == 7)}
|
||||
IterTest.new([8]).each8 { |x| test_ok(x == 8)}
|
||||
IterTest.new([0]).each0 {|x| test_ok(x == 0)}
|
||||
IterTest.new([1]).each1 {|x| test_ok(x == 1)}
|
||||
IterTest.new([2]).each2 {|x| test_ok(x == [2])}
|
||||
IterTest.new([3]).each3 {|x| test_ok(x == 3)}
|
||||
IterTest.new([4]).each4 {|x| test_ok(x == 4)}
|
||||
IterTest.new([5]).each5 {|x| test_ok(x == 5)}
|
||||
IterTest.new([6]).each6 {|x| test_ok(x == [6])}
|
||||
IterTest.new([7]).each7 {|x| test_ok(x == 7)}
|
||||
IterTest.new([8]).each8 {|x| test_ok(x == 8)}
|
||||
|
||||
IterTest.new([[0]]).each0 { |x| test_ok(x == [0])}
|
||||
IterTest.new([[1]]).each1 { |x| test_ok(x == 1)}
|
||||
IterTest.new([[2]]).each2 { |x| test_ok(x == [2])}
|
||||
IterTest.new([[3]]).each3 { |x| test_ok(x == 3)}
|
||||
IterTest.new([[4]]).each4 { |x| test_ok(x == [4])}
|
||||
IterTest.new([[5]]).each5 { |x| test_ok(x == 5)}
|
||||
IterTest.new([[6]]).each6 { |x| test_ok(x == [6])}
|
||||
IterTest.new([[7]]).each7 { |x| test_ok(x == 7)}
|
||||
IterTest.new([[8]]).each8 { |x| test_ok(x == [8])}
|
||||
IterTest.new([[0]]).each0 {|x| test_ok(x == [0])}
|
||||
IterTest.new([[1]]).each1 {|x| test_ok(x == [1])}
|
||||
IterTest.new([[2]]).each2 {|x| test_ok(x == [[2]])}
|
||||
IterTest.new([[3]]).each3 {|x| test_ok(x == 3)}
|
||||
IterTest.new([[4]]).each4 {|x| test_ok(x == [4])}
|
||||
IterTest.new([[5]]).each5 {|x| test_ok(x == [5])}
|
||||
IterTest.new([[6]]).each6 {|x| test_ok(x == [[6]])}
|
||||
IterTest.new([[7]]).each7 {|x| test_ok(x == 7)}
|
||||
IterTest.new([[8]]).each8 {|x| test_ok(x == [8])}
|
||||
|
||||
IterTest.new([[0,0]]).each0 { |x| test_ok(x == [0,0])}
|
||||
IterTest.new([[8,8]]).each8 { |x| test_ok(x == [8,8])}
|
||||
IterTest.new([[0,0]]).each0 {|x| test_ok(x == [0,0])}
|
||||
IterTest.new([[8,8]]).each8 {|x| test_ok(x == [8,8])}
|
||||
|
||||
test_check "float"
|
||||
test_ok(2.6.floor == 2)
|
||||
test_ok(-2.6.floor == -3)
|
||||
test_ok((-2.6).floor == -3)
|
||||
test_ok(2.6.ceil == 3)
|
||||
test_ok(-2.6.ceil == -2)
|
||||
test_ok((-2.6).ceil == -2)
|
||||
test_ok(2.6.truncate == 2)
|
||||
test_ok(-2.6.truncate == -2)
|
||||
test_ok((-2.6).truncate == -2)
|
||||
test_ok(2.6.round == 3)
|
||||
test_ok(-2.4.truncate == -2)
|
||||
test_ok((-2.4).truncate == -2)
|
||||
test_ok((13.4 % 1 - 0.4).abs < 0.0001)
|
||||
|
||||
test_check "bignum"
|
||||
|
|
Loading…
Add table
Reference in a new issue