Sha256: 364668261ad0fc49559f3c21c09929dfa577c5c246be8e2d0aad45deec955ed1
Contents?: true
Size: 788 Bytes
Versions: 2
Compression:
Stored size: 788 Bytes
Contents
require File.expand_path(File.join(File.dirname(__FILE__),'helper.rb')) class TestMultithreading < Test::Unit::TestCase def setup initialize_context end def test_concurrent_precision threads = [] for prec in (5..100) threads << Thread.new(prec) do |p| n = 10000/(p/3) n_fails = 0 Decimal.local_context do Decimal.context.precision = p n.times do t = (Decimal(1)/Decimal(3)).to_s n_fails += 1 if (t.size!=(p+2)) || (Decimal.context.precision!=p) end end Thread.current[:n_fails] = n_fails end end total_fails = 0 threads.each{|thr| thr.join; total_fails += thr[:n_fails]} assert total_fails==0,"Context precision different per thread" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-decimal-1.1.0 | test/test_multithreading.rb |
ruby-decimal-1.0.0 | test/test_multithreading.rb |