Class: ProgressBarTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- ProgressBarTest
- Defined in:
- lib/vendor/ruby-progressbar-0.9/lib/test.rb
Direct Known Subclasses
Constant Summary collapse
- SleepUnit =
0.01
Instance Method Summary collapse
- #do_make_progress_bar(title, total) ⇒ Object
- #test_bytes ⇒ Object
- #test_clear ⇒ Object
- #test_halt ⇒ Object
- #test_inc ⇒ Object
- #test_inc_x ⇒ Object
- #test_invalid_set ⇒ Object
- #test_set ⇒ Object
- #test_slow ⇒ Object
- #test_total_zero ⇒ Object
Instance Method Details
#do_make_progress_bar(title, total) ⇒ Object
7 8 9 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 7 def (title, total) ProgressBar.new(title, total) end |
#test_bytes ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 11 def test_bytes total = 1024 * 1024 = ("test(bytes)", total) .file_transfer_mode 0.step(total, 2**14) {|x| .set(x) sleep(SleepUnit) } .finish end |
#test_clear ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 22 def test_clear total = 100 = ("test(clear)", total) total.times { sleep(SleepUnit) .inc } .clear puts end |
#test_halt ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 33 def test_halt total = 100 = ("test(halt)", total) (total / 2).times { sleep(SleepUnit) .inc } .halt end |
#test_inc ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 43 def test_inc total = 100 = ("test(inc)", total) total.times { sleep(SleepUnit) .inc } .finish end |
#test_inc_x ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 53 def test_inc_x total = File.size("progressbar.rb") = ("test(inc(x))", total) File.new("progressbar.rb").each {|line| sleep(SleepUnit) .inc(line.length) } .finish end |
#test_invalid_set ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 63 def test_invalid_set total = 100 = ("test(invalid set)", total) begin .set(200) rescue RuntimeError => e puts e. end end |
#test_set ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 73 def test_set total = 1000 = ("test(set)", total) (1..total).find_all {|x| x % 10 == 0}.each {|x| sleep(SleepUnit) .set(x) } .finish end |
#test_slow ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 83 def test_slow total = 100000 = ("test(slow)", total) 0.step(500, 1) {|x| .set(x) sleep(SleepUnit) } .halt end |
#test_total_zero ⇒ Object
93 94 95 96 97 |
# File 'lib/vendor/ruby-progressbar-0.9/lib/test.rb', line 93 def test_total_zero total = 0 = ("test(total=0)", total) .finish end |