Skip to content

Instantly share code, notes, and snippets.

@rdj
Created November 24, 2012 07:50
Show Gist options
  • Save rdj/4138815 to your computer and use it in GitHub Desktop.
Save rdj/4138815 to your computer and use it in GitHub Desktop.
ryan@osangar ~ $ irb
1.9.3-p327 :001 > (1..10).each do |i|
1.9.3-p327 :002 > passes = true
1.9.3-p327 :003?> begin
1.9.3-p327 :004 > (rp, wp) = IO.pipe
1.9.3-p327 :005?> wp.write_nonblock ("F" * i) while(select [],
[wp], [], 0)
1.9.3-p327 :006?> rescue Errno::EAGAIN
1.9.3-p327 :007?> puts "#{i}: FAIL"
1.9.3-p327 :008?> passes = false
1.9.3-p327 :009?> ensure
1.9.3-p327 :010 > rp.close
1.9.3-p327 :011?> wp.close
1.9.3-p327 :012?> end
1.9.3-p327 :013?> puts "#{i}: PASS" if passes
1.9.3-p327 :014?> end
1: PASS
2: PASS
3: FAIL
4: PASS
5: FAIL
6: FAIL
7: FAIL
8: PASS
9: FAIL
10: FAIL
=> 1..10
1.9.3-p327 :015 > ^D
ryan@osangar ~ $ uname -a
Darwin osangar.local 12.2.1 Darwin Kernel Version 12.2.1: Thu Oct 18 1
6:32:48 PDT 2012; root:xnu-2050.20.9~2/RELEASE_X86_64 x86_64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment