-
-
Save cheald/c02e07288e76adcdabba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_sized_queue_assign_max | |
q = SizedQueue.new(2) | |
assert_equal(2, q.max) | |
q.max = 1 | |
assert_equal(1, q.max) | |
assert_raise(ArgumentError) { q.max = 0 } | |
assert_equal(1, q.max) | |
assert_raise(ArgumentError) { q.max = -1 } | |
assert_equal(1, q.max) | |
before = q.max | |
q.max.times { q << 1 } | |
t1 = Thread.new { q << 1 } | |
sleep 0.01 until t1.stop? | |
q.max = q.max + 1 | |
assert_equal before + 1, q.max | |
ensure | |
t1.join if t1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment