Skip to content

Instantly share code, notes, and snippets.

@headius
Created March 11, 2015 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/bff45c460ebe0893f07f to your computer and use it in GitHub Desktop.
Save headius/bff45c460ebe0893f07f to your computer and use it in GitHub Desktop.
def test_switch_while_busy_loop
bug1402 = "[ruby-dev:38319] [Bug #1402]"
flag = true
th = Thread.current
waiter = Thread.start {
sleep 0.1
flag = false
sleep 1
th.raise(bug1402)
}
assert_nothing_raised(RuntimeError, bug1402) do
nil while flag
end
assert(!flag, bug1402)
ensure
waiter.kill.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment