[#47386] [Backport92 - Backport #6958][Open] buggy BigDecimal#integer? — "adrianomitre (Adriano Mitre)" <adriano.mitre@...>
7 messages
2012/09/01
[#47409] [ruby-trunk - Feature #6973][Open] Add an #integral? method to Numeric to test for whole-number values — "regularfry (Alex Young)" <alex@...>
12 messages
2012/09/03
[#47444] [ruby-trunk - Bug #6986][Open] Inconsistent result of BigDecimal#power — "phasis68 (Heesob Park)" <phasis@...>
7 messages
2012/09/06
[#47453] [ruby-trunk - Bug #6994][Open] yield plus splat unwraps too much — "headius (Charles Nutter)" <headius@...>
8 messages
2012/09/07
[#47460] [ruby-trunk - Bug #6997][Open] Improve documentation for OptionParser — "eike.rb (Eike Dierks)" <eike@...>
7 messages
2012/09/08
[#47465] [ruby-trunk - Feature #7003][Assigned] Please decide. MVM to be with 2.0? — "shyouhei (Shyouhei Urabe)" <shyouhei@...>
3 messages
2012/09/10
[#47523] [ruby-trunk - Feature #7022][Open] add event hook for garbage collection — "rogerdpack (Roger Pack)" <rogerpack2005@...>
7 messages
2012/09/14
[#47531] [ruby-trunk - Feature #7022] add event hook for garbage collection
— "rogerdpack (Roger Pack)" <rogerpack2005@...>
2012/09/14
[#47540] autoload & require — Xavier Noria <fxn@...>
Hi,
4 messages
2012/09/15
[#47562] feature request: thread pool class — Roger Pack <rogerdpack2@...>
It has always seemed a bit odd to me that Ruby's sdlib doesn't have some kind of
4 messages
2012/09/17
[#47638] [ruby-trunk - Bug #7046][Open] ERB#run and ERB#result are not safe for concurrent use — "headius (Charles Nutter)" <headius@...>
11 messages
2012/09/21
[#47653] [ruby-trunk - Bug #7050][Open] encoding of String#unpack for 'H', 'h', 'B' and 'b' — "Eregon (Benoit Daloze)" <redmine@...>
6 messages
2012/09/22
[#47655] [ruby-trunk - Feature #7051][Open] Extend caller_locations API to include klass and bindings. Allow caller_locations as a method hanging off Thread. — "sam.saffron (Sam Saffron)" <sam.saffron@...>
13 messages
2012/09/23
[#47709] [ruby-trunk - Bug #7076][Open] TestUnicodeEscape#test_basic failure on Windows — "h.shirosaki (Hiroshi Shirosaki)" <h.shirosaki@...>
4 messages
2012/09/27
[#47719] [ruby-trunk - Bug #7082][Open] Process.kill 0 in windows can return spurious success — "rogerdpack (Roger Pack)" <rogerpack2005@...>
6 messages
2012/09/28
[#47730] [ruby-trunk - Bug #7085][Open] Subversion → GitHub gateway stops. — "shyouhei (Shyouhei Urabe)" <shyouhei@...>
27 messages
2012/09/29
[#47731] [ruby-trunk - Bug #7085] Subversion → GitHub gateway stops.
— "shyouhei (Shyouhei Urabe)" <shyouhei@...>
2012/09/29
[#47743] Re: [ruby-trunk - Bug #7085] Subversion → GitHub gateway stops.
— Evan Phoenix <evan@...>
2012/09/29
Hello shyouhei, =20
[#47746] Re: [ruby-trunk - Bug #7085] Subversion → GitHub gateway stops.
— Urabe Shyouhei <shyouhei@...>
2012/09/30
On 09/30/2012 02:33 AM, Evan Phoenix wrote:
[#48020] [ruby-trunk - Bug #7085] Subversion → GitHub gateway stops.
— "shyouhei (Shyouhei Urabe)" <shyouhei@...>
2012/10/16
[#48953] [ruby-trunk - Bug #7085] Subversion → GitHub gateway stops.
— "shyouhei (Shyouhei Urabe)" <shyouhei@...>
2012/11/05
[#49123] Re: [ruby-trunk - Bug #7085] Subversion → GitHub gateway stops.
— Evan Phoenix <evan@...>
2012/11/08
So sorry for the continual delay. I'm setting this up right now but it ap=
[#47735] [ruby-trunk - Bug #7087][Open] ::ConditionVariable#wait does not work with Monitor because Monitor#sleep does not exist — "rklemme (Robert Klemme)" <shortcutter@...>
10 messages
2012/09/29
[ruby-core:47732] [ruby-trunk - Bug #7083][Third Party's Issue] Why I cannot pass the test?
From:
"nobu (Nobuyoshi Nakada)" <nobu@...>
Date:
2012-09-29 13:04:15 UTC
List:
ruby-core #47732
Issue #7083 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Open to Third Party's Issue
----------------------------------------
Bug #7083: Why I cannot pass the test?
https://bugs.ruby-lang.org/issues/7083#change-29788
Author: mghomn (Justin Peal)
Status: Third Party's Issue
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
=== Program ===
#!/usr/bin/env ruby -w
# encoding: utf-8
require 'test/unit'
class Currency
attr_reader :currency, :decimal_digits
def initialize currency, decimal_digits
@currency, @decimal_digits = currency, decimal_digits
end
end
class Money
attr_reader :hashy
def initialize hashy
@hashy = hashy
clean()
end
def == other
@hashy == other.hashy
end
def -@
@hashy.each_pair do |currency, amount|
@hashy[currency] = -amount
end
clean()
end
def + other
@hashy.merge!(other.hashy) do |currency, old_amount, new_amount|
old_amount.to_f + new_amount.to_f
end
clean()
end
def - other
@hashy.merge!(other.hashy) do |currency, old_amount, new_amount|
old_amount.to_f - new_amount.to_f
end
clean()
end
def * times
@hashy.each_pair do |currency, amount|
@hashy[currency] *= times
end
clean()
end
def / times
@hashy.each_pair do |currency, amount|
@hashy[currency] /= times
end
clean()
end
def clean
@hashy.each_pair do |currency, amount|
amount_new = amount.to_f.round(currency.decimal_digits)
case
when amount_new == 0.0
@hashy.delete(currency)
when amount_new != amount
@hashy[currency] = amount_new
end
end
self
end
end
class MoneyTest < Test::Unit::TestCase
def test_add
usd = Currency.new(:USD, 2)
cny = Currency.new(:CNY, 2)
eur = Currency.new(:EUR, 2)
jpy = Currency.new(:JPY, 0)
gbp = Currency.new(:GBP, 2)
assert_equal(Money.new(eur=>367.85, cny=>-337.19, jpy=>42289), Money.new(eur=>867.02, cny=>-794.75, jpy=>99675) / 2.357)
assert_equal(Money.new(cny=>1576.56, gbp=>752.26, jpy=>64174), Money.new(cny=>861.51, gbp=>411.07, jpy=>35068) * 1.83)
assert_equal(Money.new(usd=>367.04, cny=>418.27, eur=>728.18), Money.new(cny=>418.27, usd=>129.66) + Money.new(usd=>237.38, eur=>728.18))
assert_equal(Money.new(eur=>211.32, cny=>-980.95, jpy=>31647), -Money.new(eur=>-211.32, cny=>980.95, jpy=>-31647))
assert_equal(Money.new(jpy=>19627, usd=>442.39, gbp=>-393.84), Money.new(jpy=>19627, usd=>908.64) - Money.new(usd=>466.25, gbp=>393.84))
end
end
=== Result ===
Run options:
# Running tests:
F
Finished tests in 0.029999s, 33.3344 tests/s, 166.6722 assertions/s.
1) Failure:
test_add(MoneyTest) [C:/R/tst2.rb:87]:
<#<Money:0x1b463f8
@hashy=
{#<Currency:0x1b56148 @currency=:JPY, @decimal_digits=0>=>19627,
#<Currency:0x1b561f0 @currency=:USD, @decimal_digits=2>=>442.39,
#<Currency:0x1b560b8 @currency=:GBP, @decimal_digits=2>=>-393.84}>> expected
but was
<#<Money:0x1b462f0
@hashy=
{#<Currency:0x1b56148 @currency=:JPY, @decimal_digits=0>=>19627,
#<Currency:0x1b561f0 @currency=:USD, @decimal_digits=2>=>442.39,
#<Currency:0x1b560b8 @currency=:GBP, @decimal_digits=2>=>393.84}>>.
1 tests, 5 assertions, 1 failures, 0 errors, 0 skips
--
http://bugs.ruby-lang.org/