mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix duplicable? for Ratiional and Complex on ruby master, since they are now duplicable
This commit is contained in:
parent
eb85100426
commit
7045e03dee
2 changed files with 26 additions and 13 deletions
|
@ -124,7 +124,11 @@ class Method
|
||||||
end
|
end
|
||||||
|
|
||||||
class Complex
|
class Complex
|
||||||
# Complexes are not duplicable:
|
begin
|
||||||
|
Complex(1).dup
|
||||||
|
rescue TypeError
|
||||||
|
|
||||||
|
# Complexes are not duplicable for RUBY_VERSION < 2.5.0:
|
||||||
#
|
#
|
||||||
# Complex(1).duplicable? # => false
|
# Complex(1).duplicable? # => false
|
||||||
# Complex(1).dup # => TypeError: can't copy Complex
|
# Complex(1).dup # => TypeError: can't copy Complex
|
||||||
|
@ -132,9 +136,14 @@ class Complex
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Rational
|
class Rational
|
||||||
# Rationals are not duplicable:
|
begin
|
||||||
|
Rational(1).dup
|
||||||
|
rescue TypeError
|
||||||
|
|
||||||
|
# Rationals are not duplicable for RUBY_VERSION < 2.5.0:
|
||||||
#
|
#
|
||||||
# Rational(1).duplicable? # => false
|
# Rational(1).duplicable? # => false
|
||||||
# Rational(1).dup # => TypeError: can't copy Rational
|
# Rational(1).dup # => TypeError: can't copy Rational
|
||||||
|
@ -142,3 +151,4 @@ class Rational
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -4,7 +4,10 @@ require "active_support/core_ext/object/duplicable"
|
||||||
require "active_support/core_ext/numeric/time"
|
require "active_support/core_ext/numeric/time"
|
||||||
|
|
||||||
class DuplicableTest < ActiveSupport::TestCase
|
class DuplicableTest < ActiveSupport::TestCase
|
||||||
if RUBY_VERSION >= "2.4.1"
|
if RUBY_VERSION >= "2.5.0"
|
||||||
|
RAISE_DUP = [method(:puts)]
|
||||||
|
ALLOW_DUP = ["1", "symbol_from_string".to_sym, Object.new, /foo/, [], {}, Time.now, Class.new, Module.new, BigDecimal.new("4.56"), nil, false, true, 1, 2.3, Complex(1), Rational(1)]
|
||||||
|
elsif RUBY_VERSION >= "2.4.1"
|
||||||
RAISE_DUP = [method(:puts), Complex(1), Rational(1)]
|
RAISE_DUP = [method(:puts), Complex(1), Rational(1)]
|
||||||
ALLOW_DUP = ["1", "symbol_from_string".to_sym, Object.new, /foo/, [], {}, Time.now, Class.new, Module.new, BigDecimal.new("4.56"), nil, false, true, 1, 2.3]
|
ALLOW_DUP = ["1", "symbol_from_string".to_sym, Object.new, /foo/, [], {}, Time.now, Class.new, Module.new, BigDecimal.new("4.56"), nil, false, true, 1, 2.3]
|
||||||
elsif RUBY_VERSION >= "2.4.0" # Due to 2.4.0 bug. This elsif cannot be removed unless we drop 2.4.0 support...
|
elsif RUBY_VERSION >= "2.4.0" # Due to 2.4.0 bug. This elsif cannot be removed unless we drop 2.4.0 support...
|
||||||
|
|
Loading…
Reference in a new issue