mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* prec.c: removed. Precision will be redesigned and be back again.
c.f. [ruby-dev:36352]. * common.mk (COMMON_OBJS): removed prec.o. * inits.c (rb_call_inits): removed Init_Precision. * numeric.c (Init_Numeric): removed inclusion of Precision. removed #induced_from from each class. * rational.c: ditto. * ext/bigdecimal/bigdecimal.c: ditto. * lib/rdoc/knwon_classes.rb: removed the entry for Precision. * test/ruby/test_prec.rb: removed. * test/ruby/test_integer.rb: removed tests for Precision. * test/ruby/test_fixnum.rb: ditto. * test/ruby/test_float.rb: ditto. * test/ruby/test_rational.rb: ditto. * test/ruby/test_complex.rb: ditto. * test/bigdecimal/test_bigdecimal.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									e6ad87c3ba
								
							
						
					
					
						commit
						396650e0bd
					
				
					 15 changed files with 32 additions and 291 deletions
				
			
		
							
								
								
									
										32
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										32
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,3 +1,35 @@
 | 
			
		|||
Fri Sep 19 20:48:06 2008  Yuki Sonoda  <yugui@yugui.jp>
 | 
			
		||||
 | 
			
		||||
	* prec.c: removed. Precision will be redesigned and be back again.
 | 
			
		||||
	  c.f. [ruby-dev:36352].
 | 
			
		||||
 | 
			
		||||
	* common.mk (COMMON_OBJS): removed prec.o.
 | 
			
		||||
 | 
			
		||||
	* inits.c (rb_call_inits): removed Init_Precision.
 | 
			
		||||
 | 
			
		||||
	* numeric.c (Init_Numeric): removed inclusion of Precision.
 | 
			
		||||
	  removed #induced_from from each class.
 | 
			
		||||
 | 
			
		||||
	* rational.c: ditto.
 | 
			
		||||
 | 
			
		||||
	* ext/bigdecimal/bigdecimal.c: ditto.
 | 
			
		||||
 | 
			
		||||
	* lib/rdoc/knwon_classes.rb: removed the entry for Precision.
 | 
			
		||||
 | 
			
		||||
	* test/ruby/test_prec.rb: removed.
 | 
			
		||||
 | 
			
		||||
	* test/ruby/test_integer.rb: removed tests for Precision.
 | 
			
		||||
 | 
			
		||||
	* test/ruby/test_fixnum.rb: ditto.
 | 
			
		||||
 | 
			
		||||
	* test/ruby/test_float.rb: ditto.
 | 
			
		||||
 | 
			
		||||
	* test/ruby/test_rational.rb: ditto.
 | 
			
		||||
 | 
			
		||||
	* test/ruby/test_complex.rb: ditto.
 | 
			
		||||
 | 
			
		||||
	* test/bigdecimal/test_bigdecimal.rb: ditto.
 | 
			
		||||
 | 
			
		||||
Fri Sep 19 19:43:40 2008  Yuki Sonoda  <yugui@yugui.jp>
 | 
			
		||||
 | 
			
		||||
	* common.mk : Reverts the changeset 18994.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,7 +49,6 @@ COMMONOBJS    = array.$(OBJEXT) \
 | 
			
		|||
		pack.$(OBJEXT) \
 | 
			
		||||
		parse.$(OBJEXT) \
 | 
			
		||||
		process.$(OBJEXT) \
 | 
			
		||||
		prec.$(OBJEXT) \
 | 
			
		||||
		random.$(OBJEXT) \
 | 
			
		||||
		range.$(OBJEXT) \
 | 
			
		||||
		rational.$(OBJEXT) \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -579,13 +579,6 @@ BigDecimal_to_i(VALUE self)
 | 
			
		|||
    return rb_cstr2inum(psz,10);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
BigDecimal_induced_from(VALUE self, VALUE x)
 | 
			
		||||
{
 | 
			
		||||
    Real *p = GetVpValue(x,1);
 | 
			
		||||
    return p->obj;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Returns a new Float object having approximately the same value as the
 | 
			
		||||
 * BigDecimal number. Normal accuracy limits and built-in errors of binary
 | 
			
		||||
 * Float arithmetic apply.
 | 
			
		||||
| 
						 | 
				
			
			@ -1807,7 +1800,6 @@ Init_bigdecimal(void)
 | 
			
		|||
    rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1);
 | 
			
		||||
    rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1);
 | 
			
		||||
    rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0);
 | 
			
		||||
    rb_define_singleton_method(rb_cBigDecimal, "induced_from",BigDecimal_induced_from, 1);
 | 
			
		||||
    rb_define_singleton_method(rb_cBigDecimal, "_load", BigDecimal_load, 1);
 | 
			
		||||
    rb_define_singleton_method(rb_cBigDecimal, "ver", BigDecimal_version, 0);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								inits.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								inits.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -34,7 +34,6 @@ void Init_marshal(void);
 | 
			
		|||
void Init_Numeric(void);
 | 
			
		||||
void Init_Object(void);
 | 
			
		||||
void Init_pack(void);
 | 
			
		||||
void Init_Precision(void);
 | 
			
		||||
void Init_sym(void);
 | 
			
		||||
void Init_process(void);
 | 
			
		||||
void Init_RandomSeed(void);
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +65,6 @@ rb_call_inits()
 | 
			
		|||
    Init_Encoding();
 | 
			
		||||
    Init_Comparable();
 | 
			
		||||
    Init_Enumerable();
 | 
			
		||||
    Init_Precision();
 | 
			
		||||
    Init_String();
 | 
			
		||||
    Init_Exception();
 | 
			
		||||
    Init_eval();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,7 +62,6 @@ module RDoc
 | 
			
		|||
    "rb_mGC"               => "GC",
 | 
			
		||||
    "rb_mKernel"           => "Kernel",
 | 
			
		||||
    "rb_mMath"             => "Math",
 | 
			
		||||
    "rb_mPrecision"        => "Precision",
 | 
			
		||||
    "rb_mProcess"          => "Process"
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										67
									
								
								numeric.c
									
										
									
									
									
								
							
							
						
						
									
										67
									
								
								numeric.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1949,66 +1949,6 @@ int_denominator(VALUE num)
 | 
			
		|||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * call-seq:
 | 
			
		||||
 *   Fixnum.induced_from(obj)    =>  fixnum
 | 
			
		||||
 *
 | 
			
		||||
 * Convert <code>obj</code> to a Fixnum. Works with numeric parameters.
 | 
			
		||||
 * Also works with Symbols, but this is deprecated.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
rb_fix_induced_from(VALUE klass, VALUE x)
 | 
			
		||||
{
 | 
			
		||||
    return rb_num2fix(x);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * call-seq:
 | 
			
		||||
 *   Integer.induced_from(obj)    =>  fixnum, bignum
 | 
			
		||||
 *
 | 
			
		||||
 * Convert <code>obj</code> to an Integer.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
rb_int_induced_from(VALUE klass, VALUE x)
 | 
			
		||||
{
 | 
			
		||||
    switch (TYPE(x)) {
 | 
			
		||||
      case T_FIXNUM:
 | 
			
		||||
      case T_BIGNUM:
 | 
			
		||||
	return x;
 | 
			
		||||
      case T_FLOAT:
 | 
			
		||||
      case T_RATIONAL:
 | 
			
		||||
	return rb_funcall(x, id_to_i, 0);
 | 
			
		||||
      default:
 | 
			
		||||
	rb_raise(rb_eTypeError, "failed to convert %s into Integer",
 | 
			
		||||
		 rb_obj_classname(x));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * call-seq:
 | 
			
		||||
 *   Float.induced_from(obj)    =>  float
 | 
			
		||||
 *
 | 
			
		||||
 * Convert <code>obj</code> to a float.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
rb_flo_induced_from(VALUE klass, VALUE x)
 | 
			
		||||
{
 | 
			
		||||
    switch (TYPE(x)) {
 | 
			
		||||
      case T_FIXNUM:
 | 
			
		||||
      case T_BIGNUM:
 | 
			
		||||
      case T_RATIONAL:
 | 
			
		||||
	return rb_funcall(x, rb_intern("to_f"), 0);
 | 
			
		||||
      case T_FLOAT:
 | 
			
		||||
	return x;
 | 
			
		||||
      default:
 | 
			
		||||
	rb_raise(rb_eTypeError, "failed to convert %s into Float",
 | 
			
		||||
		 rb_obj_classname(x));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * call-seq:
 | 
			
		||||
 *   -fix   =>  integer
 | 
			
		||||
| 
						 | 
				
			
			@ -3172,7 +3112,6 @@ Init_Numeric(void)
 | 
			
		|||
    rb_define_method(rb_cInteger, "upto", int_upto, 1);
 | 
			
		||||
    rb_define_method(rb_cInteger, "downto", int_downto, 1);
 | 
			
		||||
    rb_define_method(rb_cInteger, "times", int_dotimes, 0);
 | 
			
		||||
    rb_include_module(rb_cInteger, rb_mPrecision);
 | 
			
		||||
    rb_define_method(rb_cInteger, "succ", int_succ, 0);
 | 
			
		||||
    rb_define_method(rb_cInteger, "next", int_succ, 0);
 | 
			
		||||
    rb_define_method(rb_cInteger, "pred", int_pred, 0);
 | 
			
		||||
| 
						 | 
				
			
			@ -3185,9 +3124,6 @@ Init_Numeric(void)
 | 
			
		|||
    rb_define_method(rb_cInteger, "round", int_round, -1);
 | 
			
		||||
 | 
			
		||||
    rb_cFixnum = rb_define_class("Fixnum", rb_cInteger);
 | 
			
		||||
    rb_include_module(rb_cFixnum, rb_mPrecision);
 | 
			
		||||
    rb_define_singleton_method(rb_cFixnum, "induced_from", rb_fix_induced_from, 1);
 | 
			
		||||
    rb_define_singleton_method(rb_cInteger, "induced_from", rb_int_induced_from, 1);
 | 
			
		||||
 | 
			
		||||
    rb_define_method(rb_cInteger, "numerator", int_numerator, 0);
 | 
			
		||||
    rb_define_method(rb_cInteger, "denominator", int_denominator, 0);
 | 
			
		||||
| 
						 | 
				
			
			@ -3237,9 +3173,6 @@ Init_Numeric(void)
 | 
			
		|||
    rb_undef_alloc_func(rb_cFloat);
 | 
			
		||||
    rb_undef_method(CLASS_OF(rb_cFloat), "new");
 | 
			
		||||
 | 
			
		||||
    rb_define_singleton_method(rb_cFloat, "induced_from", rb_flo_induced_from, 1);
 | 
			
		||||
    rb_include_module(rb_cFloat, rb_mPrecision);
 | 
			
		||||
 | 
			
		||||
    rb_define_const(rb_cFloat, "ROUNDS", INT2FIX(FLT_ROUNDS));
 | 
			
		||||
    rb_define_const(rb_cFloat, "RADIX", INT2FIX(FLT_RADIX));
 | 
			
		||||
    rb_define_const(rb_cFloat, "MANT_DIG", INT2FIX(DBL_MANT_DIG));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										138
									
								
								prec.c
									
										
									
									
									
								
							
							
						
						
									
										138
									
								
								prec.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,138 +0,0 @@
 | 
			
		|||
/**********************************************************************
 | 
			
		||||
 | 
			
		||||
  prec.c -
 | 
			
		||||
 | 
			
		||||
  $Author$
 | 
			
		||||
  created at: Tue Jan 26 02:40:41 2000
 | 
			
		||||
 | 
			
		||||
  Copyright (C) 1993-2007 Yukihiro Matsumoto
 | 
			
		||||
 | 
			
		||||
**********************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "ruby/ruby.h"
 | 
			
		||||
 | 
			
		||||
VALUE rb_mPrecision;
 | 
			
		||||
 | 
			
		||||
static ID prc_pr, prc_if;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  call-seq:
 | 
			
		||||
 *   num.prec(klass)   => a_class
 | 
			
		||||
 *
 | 
			
		||||
 *  Converts _self_ into an instance of _klass_. By default,
 | 
			
		||||
 *  +prec+ invokes 
 | 
			
		||||
 *
 | 
			
		||||
 *     klass.induced_from(num)
 | 
			
		||||
 *
 | 
			
		||||
 *  and returns its value. So, if <code>klass.induced_from</code>
 | 
			
		||||
 *  doesn't return an instance of _klass_, it will be necessary
 | 
			
		||||
 *  to reimplement +prec+.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
prec_prec(VALUE x, VALUE klass)
 | 
			
		||||
{
 | 
			
		||||
    return rb_funcall(klass, prc_if, 1, x);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  call-seq:
 | 
			
		||||
 *    num.prec_i  =>  Integer
 | 
			
		||||
 *
 | 
			
		||||
 *  Returns an +Integer+ converted from _num_. It is equivalent 
 | 
			
		||||
 *  to <code>prec(Integer)</code>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
prec_prec_i(VALUE x)
 | 
			
		||||
{
 | 
			
		||||
    VALUE klass = rb_cInteger;
 | 
			
		||||
 | 
			
		||||
    return rb_funcall(x, prc_pr, 1, klass);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  call-seq:
 | 
			
		||||
 *    num.prec_f  =>  Float
 | 
			
		||||
 *
 | 
			
		||||
 *  Returns a +Float+ converted from _num_. It is equivalent 
 | 
			
		||||
 *  to <code>prec(Float)</code>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
prec_prec_f(VALUE x)
 | 
			
		||||
{
 | 
			
		||||
    VALUE klass = rb_cFloat;
 | 
			
		||||
 | 
			
		||||
    return rb_funcall(x, prc_pr, 1, klass);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * call-seq:
 | 
			
		||||
 *   Mod.induced_from(number)  =>  a_mod
 | 
			
		||||
 * 
 | 
			
		||||
 * Creates an instance of mod from. This method is overridden
 | 
			
		||||
 * by concrete +Numeric+ classes, so that (for example)
 | 
			
		||||
 *
 | 
			
		||||
 *   Fixnum.induced_from(9.9)   #=>  9
 | 
			
		||||
 *
 | 
			
		||||
 * Note that a use of +prec+ in a redefinition may cause
 | 
			
		||||
 * an infinite loop.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
prec_induced_from(VALUE module, VALUE x)
 | 
			
		||||
{
 | 
			
		||||
    rb_raise(rb_eTypeError, "undefined conversion from %s into %s",
 | 
			
		||||
            rb_obj_classname(x), rb_class2name(module));
 | 
			
		||||
    return Qnil;		/* not reached */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * call_seq:
 | 
			
		||||
 *   included
 | 
			
		||||
 *
 | 
			
		||||
 * When the +Precision+ module is mixed-in to a class, this +included+
 | 
			
		||||
 * method is used to add our default +induced_from+ implementation
 | 
			
		||||
 * to the host class.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
prec_included(VALUE module, VALUE include)
 | 
			
		||||
{
 | 
			
		||||
    switch (TYPE(include)) {
 | 
			
		||||
      case T_CLASS:
 | 
			
		||||
      case T_MODULE:
 | 
			
		||||
       break;
 | 
			
		||||
      default:
 | 
			
		||||
       Check_Type(include, T_CLASS);
 | 
			
		||||
       break;
 | 
			
		||||
    }
 | 
			
		||||
    rb_define_singleton_method(include, "induced_from", prec_induced_from, 1);
 | 
			
		||||
    return module;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Precision is a mixin for concrete numeric classes with
 | 
			
		||||
 * precision.  Here, `precision' means the fineness of approximation
 | 
			
		||||
 * of a real number, so, this module should not be included into
 | 
			
		||||
 * anything which is not a subset of Real (so it should not be
 | 
			
		||||
 * included in classes such as +Complex+ or +Matrix+).
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
Init_Precision(void)
 | 
			
		||||
{
 | 
			
		||||
#undef rb_intern
 | 
			
		||||
#define rb_intern(str) rb_intern_const(str)
 | 
			
		||||
 | 
			
		||||
    rb_mPrecision = rb_define_module("Precision");
 | 
			
		||||
    rb_define_singleton_method(rb_mPrecision, "included", prec_included, 1);
 | 
			
		||||
    rb_define_method(rb_mPrecision, "prec", prec_prec, 1);
 | 
			
		||||
    rb_define_method(rb_mPrecision, "prec_i", prec_prec_i, 0);
 | 
			
		||||
    rb_define_method(rb_mPrecision, "prec_f", prec_prec_f, 0);
 | 
			
		||||
 | 
			
		||||
    prc_pr = rb_intern("prec");
 | 
			
		||||
    prc_if = rb_intern("induced_from");
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										10
									
								
								rational.c
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								rational.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1470,12 +1470,6 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
nurat_s_induced_from(VALUE klass, VALUE n)
 | 
			
		||||
{
 | 
			
		||||
    return f_to_r(n);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
Init_Rational(void)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -1592,10 +1586,6 @@ Init_Rational(void)
 | 
			
		|||
    rb_define_singleton_method(rb_cRational, "convert", nurat_s_convert, -1);
 | 
			
		||||
    rb_funcall(rb_cRational, rb_intern("private_class_method"), 1,
 | 
			
		||||
	       ID2SYM(rb_intern("convert")));
 | 
			
		||||
 | 
			
		||||
    rb_include_module(rb_cRational, rb_mPrecision);
 | 
			
		||||
    rb_define_singleton_method(rb_cRational, "induced_from",
 | 
			
		||||
			       nurat_s_induced_from, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -245,13 +245,6 @@ class TestBigDecimal < Test::Unit::TestCase
 | 
			
		|||
    assert_operator(BigDecimal.new((2**100).to_s), :==, d)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_induced_from
 | 
			
		||||
    assert_instance_of(BigDecimal, BigDecimal.induced_from(1))
 | 
			
		||||
    assert_raise(TypeError) do
 | 
			
		||||
      BigDecimal.induced_from(Time.now)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_precs
 | 
			
		||||
    a = BigDecimal.new("1").precs
 | 
			
		||||
    assert_instance_of(Array, a)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -882,10 +882,6 @@ class Complex_Test < Test::Unit::TestCase
 | 
			
		|||
    assert_equal([1, 2], [c.real, c.image])
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_prec
 | 
			
		||||
    assert_equal(nil, Complex < Precision)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_supp
 | 
			
		||||
    assert_equal(true, 1.real?)
 | 
			
		||||
    assert_equal(true, 1.1.real?)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -119,15 +119,6 @@ class TestFixnum < Test::Unit::TestCase
 | 
			
		|||
    assert_equal(0x4000000000000000, (-0x4000000000000000).abs)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_induced_from
 | 
			
		||||
    assert_equal(1, Fixnum.induced_from(1))
 | 
			
		||||
    assert_raise(RangeError) do
 | 
			
		||||
      Fixnum.induced_from(2**31-1)
 | 
			
		||||
      Fixnum.induced_from(2**63-1)
 | 
			
		||||
    end
 | 
			
		||||
    assert_equal(1, Fixnum.induced_from((2**32).coerce(1).first))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_to_s
 | 
			
		||||
    assert_equal("1010", 10.to_s(2))
 | 
			
		||||
    assert_equal("a", 10.to_s(36))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -275,13 +275,6 @@ class TestFloat < Test::Unit::TestCase
 | 
			
		|||
    assert_equal(11100.0, 11111.1.round(-2))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_induced_from
 | 
			
		||||
    assert_equal(1.0, Float.induced_from(1))
 | 
			
		||||
    assert_equal(1.0, Float.induced_from(1.0))
 | 
			
		||||
    assert_raise(TypeError) { Float.induced_from(nil) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  VS = [
 | 
			
		||||
    18446744073709551617.0,
 | 
			
		||||
    18446744073709551616.0,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -122,12 +122,6 @@ class TestInteger < Test::Unit::TestCase
 | 
			
		|||
    assert_raise(RangeError) { 0x100.chr }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_induced_from
 | 
			
		||||
    assert_equal(1, Integer.induced_from(1))
 | 
			
		||||
    assert_equal(1, Integer.induced_from(1.0))
 | 
			
		||||
    assert_raise(TypeError) { Integer.induced_from(nil) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_upto
 | 
			
		||||
    a = []
 | 
			
		||||
    1.upto(3) {|x| a << x }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,21 +0,0 @@
 | 
			
		|||
require 'test/unit'
 | 
			
		||||
 | 
			
		||||
class TestPrecision < Test::Unit::TestCase
 | 
			
		||||
  def test_prec_i
 | 
			
		||||
    assert_same(1, 1.0.prec(Integer))
 | 
			
		||||
    assert_same(1, 1.0.prec_i)
 | 
			
		||||
    assert_same(1, Integer.induced_from(1.0))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_prec_f
 | 
			
		||||
    assert_equal(1.0, 1.prec(Float))
 | 
			
		||||
    assert_equal(1.0, 1.prec_f)
 | 
			
		||||
    assert_equal(1.0, Float.induced_from(1))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_induced_from
 | 
			
		||||
    m = Module.new
 | 
			
		||||
    m.instance_eval { include(Precision) }
 | 
			
		||||
    assert_raise(TypeError) { m.induced_from(0) }
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -1028,16 +1028,6 @@ class Rational_Test < Test::Unit::TestCase
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_prec
 | 
			
		||||
    assert_equal(true, Rational < Precision)
 | 
			
		||||
 | 
			
		||||
    c = Rational(3,2)
 | 
			
		||||
 | 
			
		||||
    assert_eql(1, c.prec(Integer))
 | 
			
		||||
    assert_eql(1.5, c.prec(Float))
 | 
			
		||||
    assert_eql(c, c.prec(Rational))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_gcdlcm
 | 
			
		||||
    assert_equal(7, 91.gcd(-49))
 | 
			
		||||
    assert_equal(5, 5.gcd(0))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue