Bug #15420 » fix-negative-time-interval-message.patch
| test/ruby/test_process.rb | ||
|---|---|---|
|
# coding: utf-8
|
||
|
# frozen_string_literal: false
|
||
|
require 'test/unit'
|
||
|
require '-test-/integer'
|
||
|
require 'tempfile'
|
||
|
require 'timeout'
|
||
|
require 'io/wait'
|
||
| ... | ... | |
|
def test_sleep
|
||
|
assert_raise(ArgumentError) { sleep(1, 1) }
|
||
|
[-1, -1.0, -1.to_bignum, -1r].each do |sec|
|
||
|
assert_raise_with_message(ArgumentError, /negative/) { sleep(sec) }
|
||
|
end
|
||
|
end
|
||
|
def test_getpgid
|
||
| time.c | ||
|---|---|---|
|
if (FIXNUM_P(num)) {
|
||
|
t.tv_sec = NUM2TIMET(num);
|
||
|
if (interval && t.tv_sec < 0)
|
||
|
rb_raise(rb_eArgError, "%s must be positive", tstr);
|
||
|
rb_raise(rb_eArgError, "%s must not be negative", tstr);
|
||
|
t.tv_nsec = 0;
|
||
|
}
|
||
|
else if (RB_FLOAT_TYPE_P(num)) {
|
||
|
if (interval && RFLOAT_VALUE(num) < 0.0)
|
||
|
rb_raise(rb_eArgError, "%s must be positive", tstr);
|
||
|
rb_raise(rb_eArgError, "%s must not be negative", tstr);
|
||
|
else {
|
||
|
double f, d;
|
||
| ... | ... | |
|
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
||
|
t.tv_sec = NUM2TIMET(num);
|
||
|
if (interval && t.tv_sec < 0)
|
||
|
rb_raise(rb_eArgError, "%s must be positive", tstr);
|
||
|
rb_raise(rb_eArgError, "%s must not be negative", tstr);
|
||
|
t.tv_nsec = 0;
|
||
|
}
|
||
|
else {
|
||
| ... | ... | |
|
f = rb_ary_entry(ary, 1);
|
||
|
t.tv_sec = NUM2TIMET(i);
|
||
|
if (interval && t.tv_sec < 0)
|
||
|
rb_raise(rb_eArgError, "%s must be positive", tstr);
|
||
|
rb_raise(rb_eArgError, "%s must not be negative", tstr);
|
||
|
f = rb_funcall(f, '*', 1, INT2FIX(1000000000));
|
||
|
t.tv_nsec = NUM2LONG(f);
|
||
|
}
|
||