[前][次][番号順一覧][スレッド一覧]

ruby-changes:46318

From: hsbt <ko1@a...>
Date: Fri, 21 Apr 2017 15:16:16 +0900 (JST)
Subject: [ruby-changes:46318] hsbt:r58432 (trunk): Removed mathn.rb from stdlib. It's deprecated from Ruby 2.2.

hsbt	2017-04-21 15:16:11 +0900 (Fri, 21 Apr 2017)

  New Revision: 58432

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58432

  Log:
    Removed mathn.rb from stdlib. It's deprecated from Ruby 2.2.
    
      [Feature #10169][[ruby-core:64553]]

  Removed files:
    trunk/lib/mathn.gemspec
    trunk/lib/mathn.rb
    trunk/test/test_mathn.rb
  Modified files:
    trunk/NEWS
    trunk/doc/maintainers.rdoc
    trunk/doc/standard_library.rdoc
    trunk/test/bigdecimal/test_bigdecimal.rb
    trunk/test/ruby/test_array.rb
    trunk/test/ruby/test_enum.rb
    trunk/test/ruby/test_range.rb
Index: lib/mathn.rb
===================================================================
--- lib/mathn.rb	(revision 58431)
+++ lib/mathn.rb	(nonexistent)
@@ -1,167 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/lib/mathn.rb#L0
-# frozen_string_literal: false
-#--
-# $Release Version: 0.5 $
-# $Revision: 1.1.1.1.4.1 $
-
-##
-# = mathn
-#
-# mathn serves to make mathematical operations more precise in Ruby
-# and to integrate other mathematical standard libraries.
-#
-# Without mathn:
-#
-#   3 / 2 => 1 # Integer
-#
-# With mathn:
-#
-#   3 / 2 => 3/2 # Rational
-#
-# mathn keeps value in exact terms.
-#
-# Without mathn:
-#
-#   20 / 9 * 3 * 14 / 7 * 3 / 2 # => 18
-#
-# With mathn:
-#
-#   20 / 9 * 3 * 14 / 7 * 3 / 2 # => 20
-#
-#
-# When you require 'mathn', the libraries for Prime, CMath, Matrix and Vector
-# are also loaded.
-#
-# == Copyright
-#
-# Author: Keiju ISHITSUKA (SHL Japan Inc.)
-#--
-# class Numeric follows to make this documentation findable in a reasonable
-# location
-
-warn('lib/mathn.rb is deprecated') if $VERBOSE
-
-class Numeric; end
-
-require "cmath.rb"
-require "matrix.rb"
-require "prime.rb"
-
-unless defined?(Math.exp!)
-  Object.instance_eval{remove_const :Math}
-  Math = CMath # :nodoc:
-end
-
-##
-# When mathn is required, Integer's division is enhanced to
-# return more precise values from mathematical expressions.
-#
-#   2/3*3  # => 0
-#   require 'mathn'
-#   2/3*3  # => 2
-#
-#   (2**72) / ((2**70) * 3)  # => 4/3
-
-class Integer
-  remove_method :/
-
-  ##
-  # +/+ defines the Rational division for Bignum.
-  #
-  #   (2**72) / ((2**70) * 3)  # => 4/3
-
-  alias / quo
-end
-
-##
-# When mathn is required, the Math module changes as follows:
-#
-# Standard Math module behaviour:
-#   Math.sqrt(4/9)     # => 0.0
-#   Math.sqrt(4.0/9.0) # => 0.666666666666667
-#   Math.sqrt(- 4/9)   # => Errno::EDOM: Numerical argument out of domain - sqrt
-#
-# After require 'mathn', this is changed to:
-#
-#   require 'mathn'
-#   Math.sqrt(4/9)      # => 2/3
-#   Math.sqrt(4.0/9.0)  # => 0.666666666666667
-#   Math.sqrt(- 4/9)    # => Complex(0, 2/3)
-
-module Math
-  remove_method(:sqrt)
-
-  ##
-  # Computes the square root of +a+.  It makes use of Complex and
-  # Rational to have no rounding errors if possible.
-  #
-  #   Math.sqrt(4/9)      # => 2/3
-  #   Math.sqrt(- 4/9)    # => Complex(0, 2/3)
-  #   Math.sqrt(4.0/9.0)  # => 0.666666666666667
-
-  def sqrt(a)
-    if a.kind_of?(Complex)
-      sqrt!(a)
-    elsif a.respond_to?(:nan?) and a.nan?
-      a
-    elsif a >= 0
-      rsqrt(a)
-    else
-      Complex(0,rsqrt(-a))
-    end
-  end
-
-  ##
-  # Compute square root of a non negative number. This method is
-  # internally used by +Math.sqrt+.
-
-  def rsqrt(a) # :nodoc:
-    if a.kind_of?(Float)
-      sqrt!(a)
-    elsif a.kind_of?(Rational)
-      rsqrt(a.numerator)/rsqrt(a.denominator)
-    else
-      src = a
-      max = 2 ** 32
-      byte_a = [src & 0xffffffff]
-      # ruby's bug
-      while (src >= max) and (src >>= 32)
-        byte_a.unshift src & 0xffffffff
-      end
-
-      answer = 0
-      main = 0
-      side = 0
-      for elm in byte_a
-        main = (main << 32) + elm
-        side <<= 16
-        if answer != 0
-          if main * 4  < side * side
-            applo = main.div(side)
-          else
-            applo = ((sqrt!(side * side + 4 * main) - side)/2.0).to_i + 1
-          end
-        else
-          applo = sqrt!(main).to_i + 1
-        end
-
-        while (x = (side + applo) * applo) > main
-          applo -= 1
-        end
-        main -= x
-        answer = (answer << 16) + applo
-        side += applo * 2
-      end
-      if main == 0
-        answer
-      else
-        sqrt!(a)
-      end
-    end
-  end
-
-  class << self
-    remove_method(:sqrt)
-  end
-  module_function :sqrt
-  module_function :rsqrt
-end

Property changes on: lib/mathn.rb
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-LF
\ No newline at end of property
Index: lib/mathn.gemspec
===================================================================
--- lib/mathn.gemspec	(revision 58431)
+++ lib/mathn.gemspec	(nonexistent)
@@ -1,16 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/lib/mathn.gemspec#L0
-Gem::Specification.new do |s|
-  s.name = "mathn"
-  s.version = '0.0.1'
-  s.date = '2017-03-20'
-  s.summary = "Deprecated library that extends math operations."
-  s.description = "Deprecated library that extends math operations."
-
-  s.require_path = %w{lib}
-  s.files = %w{mathn.rb}
-  s.required_ruby_version = ">= 2.5.0dev"
-
-  s.authors = ["Keiju ISHITSUKA"]
-  s.email = [nil]
-  s.homepage = "https://www.ruby-lang.org"
-  s.license = "BSD-2-Clause"
-end
Index: test/test_mathn.rb
===================================================================
--- test/test_mathn.rb	(revision 58431)
+++ test/test_mathn.rb	(nonexistent)
@@ -1,190 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/test/test_mathn.rb#L0
-# frozen_string_literal: false
-require 'test/unit'
-
-# mathn redefines too much. It must be isolated to child processes.
-class TestMathn < Test::Unit::TestCase
-  def test_power
-    stderr = $VERBOSE ? ["lib/mathn.rb is deprecated"] : []
-    assert_in_out_err ['-r', 'mathn', '-e', 'a=1**2;!a'], "", [], stderr, '[ruby-core:25740]'
-    assert_in_out_err ['-r', 'mathn', '-e', 'a=(1 << 126)**2;!a'], "", [], stderr, '[ruby-core:25740]'
-  end
-
-  def test_quo
-    stderr = $VERBOSE ? ["lib/mathn.rb is deprecated"] : []
-    assert_in_out_err ['-r', 'mathn'], <<-EOS, %w(OK), stderr, '[ruby-core:41575]'
-      1.quo(2); puts :OK
-    EOS
-  end
-
-  def test_floor
-    assert_separately(%w[-rmathn], <<-EOS, ignore_stderr: true)
-      assert_equal( 2, ( 13/5).floor)
-      assert_equal( 2, (  5/2).floor)
-      assert_equal( 2, ( 12/5).floor)
-      assert_equal(-3, (-12/5).floor)
-      assert_equal(-3, ( -5/2).floor)
-      assert_equal(-3, (-13/5).floor)
-
-      assert_equal( 2, ( 13/5).floor(0))
-      assert_equal( 2, (  5/2).floor(0))
-      assert_equal( 2, ( 12/5).floor(0))
-      assert_equal(-3, (-12/5).floor(0))
-      assert_equal(-3, ( -5/2).floor(0))
-      assert_equal(-3, (-13/5).floor(0))
-
-      assert_equal(( 13/5), ( 13/5).floor(2))
-      assert_equal((  5/2), (  5/2).floor(2))
-      assert_equal(( 12/5), ( 12/5).floor(2))
-      assert_equal((-12/5), (-12/5).floor(2))
-      assert_equal(( -5/2), ( -5/2).floor(2))
-      assert_equal((-13/5), (-13/5).floor(2))
-    EOS
-  end
-
-  def test_ceil
-    assert_separately(%w[-rmathn], <<-EOS, ignore_stderr: true)
-      assert_equal( 3, ( 13/5).ceil)
-      assert_equal( 3, (  5/2).ceil)
-      assert_equal( 3, ( 12/5).ceil)
-      assert_equal(-2, (-12/5).ceil)
-      assert_equal(-2, ( -5/2).ceil)
-      assert_equal(-2, (-13/5).ceil)
-
-      assert_equal( 3, ( 13/5).ceil(0))
-      assert_equal( 3, (  5/2).ceil(0))
-      assert_equal( 3, ( 12/5).ceil(0))
-      assert_equal(-2, (-12/5).ceil(0))
-      assert_equal(-2, ( -5/2).ceil(0))
-      assert_equal(-2, (-13/5).ceil(0))
-
-      assert_equal(( 13/5), ( 13/5).ceil(2))
-      assert_equal((  5/2), (  5/2).ceil(2))
-      assert_equal(( 12/5), ( 12/5).ceil(2))
-      assert_equal((-12/5), (-12/5).ceil(2))
-      assert_equal(( -5/2), ( -5/2).ceil(2))
-      assert_equal((-13/5), (-13/5).ceil(2))
-    EOS
-  end
-
-  def test_truncate
-    assert_separately(%w[-rmathn], <<-EOS, ignore_stderr: true)
-      assert_equal( 2, ( 13/5).truncate)
-      assert_equal( 2, (  5/2).truncate)
-      assert_equal( 2, ( 12/5).truncate)
-      assert_equal(-2, (-12/5).truncate)
-      assert_equal(-2, ( -5/2).truncate)
-      assert_equal(-2, (-13/5).truncate)
-
-      assert_equal( 2, ( 13/5).truncate(0))
-      assert_equal( 2, (  5/2).truncate(0))
-      assert_equal( 2, ( 12/5).truncate(0))
-      assert_equal(-2, (-12/5).truncate(0))
-      assert_equal(-2, ( -5/2).truncate(0))
-      assert_equal(-2, (-13/5).truncate(0))
-
-      assert_equal(( 13/5), ( 13/5).truncate(2))
-      assert_equal((  5/2), (  5/2).truncate(2))
-      assert_equal(( 12/5), ( 12/5).truncate(2))
-      assert_equal((-12/5), (-12/5).truncate(2))
-      assert_equal(( -5/2), ( -5/2).truncate(2))
-      assert_equal((-13/5), (-13/5).truncate(2))
-    EOS
-  end
-
-  def test_round
-    assert_separately(%w[-rmathn], <<-EOS, ignore_stderr: true)
-      assert_equal( 3, ( 13/5).round)
-      assert_equal( 3, (  5/2).round)
-      assert_equal( 2, ( 12/5).round)
-      assert_equal(-2, (-12/5).round)
-      assert_equal(-3, ( -5/2).round)
-      assert_equal(-3, (-13/5).round)
-
-      assert_equal( 3, ( 13/5).round(0))
-      assert_equal( 3, (  5/2).round(0))
-      assert_equal( 2, ( 12/5).round(0))
-      assert_equal(-2, (-12/5).round(0))
-      assert_equal(-3, ( -5/2).round(0))
-      assert_equal(-3, (-13/5).round(0))
-
-      assert_equal(( 13/5), ( 13/5).round(2))
-      assert_equal((  5/2), (  5/2).round(2))
-      assert_equal(( 12/5), ( 12/5).round(2))
-      assert_equal((-12/5), (-12/5).round(2))
-      assert_equal(( -5/2), ( -5/2).round(2))
-      assert_equal((-13/5), (-13/5).round(2))
-
-      assert_equal( 3, ( 13/5).round(half: :even))
-      assert_equal( 2, (  5/2).round(half: :even))
-      assert_equal( 2, ( 12/5).round(half: :even))
-      assert_equal(-2, (-12/5).round(half: :even))
-      assert_equal(-2, ( -5/2).round(half: :even))
-      assert_equal(-3, (-13/5).round(half: :even))
-
-      assert_equal( 3, ( 13/5).round(0, half: :even))
-      assert_equal( 2, (  5/2).round(0, half: :even))
-      assert_equal( 2, ( 12/5).round(0, half: :even))
-      assert_equal(-2, (-12/5).round(0, half: :even))
-      assert_equal(-2, ( -5/2).round(0, half: :even))
-      assert_equal(-3, (-13/5).round(0, half: :even))
-
-      assert_equal(( 13/5), ( 13/5).round(2, half: :even))
-      assert_equal((  5/2), (  5/2).round(2, half: :even))
-      assert_equal(( 12/5), ( 12/5).round(2, half: :even))
-      assert_equal((-12/5), (-12/5).round(2, half: :even))
-      assert_equal(( -5/2), ( -5/2).round(2, half: :even))
-      assert_equal((-13/5), (-13/5).round(2, half: :even))
-
-      assert_equal( 3, ( 13/5).round(half: :up))
-      assert_equal( 3, (  5/2).round(half: :up))
-      assert_equal( 2, ( 12/5).round(half: :up))
-      assert_equal(-2, (-12/5).round(half: :up))
-      assert_equal(-3, ( -5/2).round(half: :up))
-      assert_equal(-3, (-13/5).round(half: :up))
-
-      assert_equal( 3, ( 13/5).round(0, half: :up))
-      assert_equal( 3, (  5/2).round(0, half: :up))
-      assert_equal( 2, ( 12/5).round(0, half: :up))
-      assert_equal(-2, (-12/5).round(0, half: :up))
-      assert_equal(-3, ( -5/2).round(0, half: :up))
-      assert_equal(-3, (-13/5).round(0, half: :up))
-
-      assert_equal(( 13/5), ( 13/5).round(2, half: :up))
-      assert_equal((  5/2), (  5/2).round(2, half: :up))
-      assert_equal(( 12/5), ( 12/5).round(2, half: :up))
-      assert_equal((-12/5), (-12/5).round(2, half: :up))
-      assert_equal(( -5/2), ( -5/2).round(2, half: :up))
-      assert_equal((-13/5), (-13/5).round(2, half: :up))
-
-      assert_equal( 3, ( 13/5).round(half: :down))
-      assert_equal( 2, (  5/2).round(half: :down))
-      assert_equal( 2, ( 12/5).round(half: :down))
-      assert_equal(-2, (-12/5).round(half: :down))
-      assert_equal(-2, ( -5/2).round(half: :down))
-      assert_equal(-3, (-13/5).round(half: :down))
-
-      assert_equal( 3, ( 13/5).round(0, half: :down))
-      assert_equal( 2, (  5/2).round(0, half: :down))
-      assert_equal( 2, ( 12/5).round(0, half: :down))
-      assert_equal(-2, (-12/5).round(0, half: :down))
-      assert_equal(-2, ( -5/2).round(0, half: :down))
-      assert_equal(-3, (-13/5).round(0, half: :down))
-
-      assert_equal(( 13/5), ( 13/5).round(2, half: :down))
-      assert_equal((  5/2), (  5/2).round(2, half: :down))
-      assert_equal(( 12/5), ( 12/5).round(2, half: :down))
-      assert_equal((-12/5), (-12/5).round(2, half: :down))
-      assert_equal(( -5/2), ( -5/2).round(2, half: :down))
-      assert_equal((-13/5), (-13/5).round(2, half: :down))
-    EOS
-  end
-
-  def test_rational
-    assert_separately(%w[-rmathn], "#{<<-"begin;"}\n#{<<-"end;"}", ignore_stderr: true)
-    begin;
-      assert_equal(-5, "-5".to_r)
-      assert_equal(1, "5/5".to_r)
-      assert_equal(5, "5e0".to_r)
-    end;
-  end
-end

Property changes on: test/test_mathn.rb
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-LF
\ No newline at end of property
Index: NEWS
===================================================================
--- NEWS	(revision 58431)
+++ NEWS	(revision 58432)
@@ -70,6 +70,9 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L70
 
 === Stdlib compatibility issues (excluding feature bug fixes)
 
+* mathn.rb
+  Removed from stdlib. [Feature #10169]
+
 === C API updates
 
 === Supported platform changes
Index: doc/standard_library.rdoc
===================================================================
--- doc/standard_library.rdoc	(revision 58431)
+++ doc/standard_library.rdoc	(revision 58432)
@@ -25,7 +25,6 @@ GetoptLong:: Parse command line options https://github.com/ruby/ruby/blob/trunk/doc/standard_library.rdoc#L25
 IPAddr:: Provides methods to manipulate IPv4 and IPv6 IP addresses
 IRB:: Interactive Ruby command-line tool for REPL (Read Eval Print Loop)
 Logger:: Provides a simple logging utility for outputting messages
-mathn.rb:: Deprecated library that extends math operations
 MakeMakefile:: Module used to generate a Makefile for C extensions
 Matrix:: Represents a mathematical matrix.
 Monitor:: Provides an object or module to use safely by more than one thread
Index: doc/maintainers.rdoc
===================================================================
--- doc/maintainers.rdoc	(revision 58431)
+++ doc/maintainers.rdoc	(revision 58432)
@@ -70,8 +70,6 @@ Zachary Scott (zzak) https://github.com/ruby/ruby/blob/trunk/doc/maintainers.rdoc#L70
   Keiju ISHITSUKA (keiju)
 [lib/logger.rb]
   Naotoshi Seo (sonots)
-[lib/mathn.rb]
-  Keiju ISHITSUKA (keiju)
 [lib/matrix.rb]
   Marc-Andre Lafortune (marcandre)
 [lib/mkmf.rb]
Index: test/bigdecimal/test_bigdecimal.rb
===================================================================
--- test/bigdecimal/test_bigdecimal.rb	(revision 58431)
+++ test/bigdecimal/test_bigdecimal.rb	(revision 58432)
@@ -1765,12 +1765,6 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L1765
     assert_kind_of(c, y)
   end
 
-  def test_to_d
-    bug6093 = '[ruby-core:42969]'
-    code = "exit(BigDecimal.new('10.0') == 10.0.to_d)"
-    assert_ruby_status(%w[-rbigdecimal -rbigdecimal/util -rmathn -], code, bug6093)
-  end
-
   def test_bug6406
     assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], [])
     Thread.current.keys.to_s
Index: test/ruby/test_enum.rb
===================================================================
--- test/ruby/test_enum.rb	(revision 58431)
+++ test/ruby/test_enum.rb	(revision 58432)
@@ -907,10 +907,6 @@ class TestEnumerable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enum.rb#L907
 
     assert_equal("abc", ["a", "b", "c"].each.sum(""))
     assert_equal([1, [2], 3], [[1], [[2]], [3]].each.sum([]))
-
-    assert_separately(%w[-rmathn], <<-EOS, ignore_stderr: true)
-      assert_equal(6, [1r, 2, 3r].each.sum)
-    EOS
   end
 
   def test_hash_sum
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 58431)
+++ test/ruby/test_array.rb	(revision 58432)
@@ -2859,10 +2859,6 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2859
 
     assert_raise(TypeError) {[0].sum("")}
     assert_raise(TypeError) {[1].sum("")}
-
-    assert_separately(%w[-rmathn], <<-EOS, ignore_stderr: true)
-      assert_equal(6, [1r, 2, 3r].sum)
-    EOS
   end
 
   private
Index: test/ruby/test_range.rb
===================================================================
--- test/ruby/test_range.rb	(revision 58431)
+++ test/ruby/test_range.rb	(revision 58432)
@@ -640,17 +640,6 @@ class TestRange < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_range.rb#L640
     assert_raise(TypeError) { ("a".."z").bsearch {} }
   end
 
-  def test_bsearch_with_mathn
-    assert_separately ['-r', 'mathn'], %q{
-      msg = '[ruby-core:25740]'
-      answer = (1..(1 << 100)).bsearch{|x|
-        assert_predicate(x, :integer?, msg)
-        x >= 42
-      }
-      assert_equal(42, answer, msg)
-    }, ignore_stderr: true
-  end
-
   def test_each_no_blockarg
     a = "a"
     def a.upto(x, e, &b)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]