Sha256: cc54ce69d1dc2883fd176b7f2602ac31dd7a2cc28882016562edc3a3bdb99740
Contents?: true
Size: 954 Bytes
Versions: 1
Compression:
Stored size: 954 Bytes
Contents
# frozen_string_literal: true require_relative 'helper' class ThrottlerTest < MiniTest::Test def test_throttler_with_rate t = Polyphony::Throttler.new(10) buffer = [] t0 = Time.now f = spin { loop { t.process { buffer << 1 } } } sleep 0.2 f.stop assert_in_range 1..4, buffer.size if IS_LINUX end def test_throttler_with_hash_of_rate t = Polyphony::Throttler.new(rate: 20) buffer = [] f = spin do loop { t.process { buffer << 1 } } end sleep 0.25 f.stop assert_in_range 4..6, buffer.size if IS_LINUX end def test_throttler_with_hash_of_interval t = Polyphony::Throttler.new(interval: 0.01) buffer = [] f = spin { loop { t.process { buffer << 1 } } } sleep 0.02 f.stop assert_in_range 1..4, buffer.size if IS_LINUX end def test_throttler_with_invalid_argument assert_raises RuntimeError do Polyphony::Throttler.new(:foobar) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polyphony-1.6 | test/test_throttler.rb |