itimer 5 → 6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/itimer.rb +1 -1
  3. data/test/itimer.rb +17 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0927c46f3b34be6e9ceada8e734dfba266d0a8bd
4
- data.tar.gz: 31c702637cbfb192eea372550f3031f7776ab21b
3
+ metadata.gz: 9303f43abb6d89f16d982ecd699badd4c2fcda54
4
+ data.tar.gz: 5a68f96c80393c9fe74f0240a051bcaea3a69c9b
5
5
  SHA512:
6
- metadata.gz: 09a998ea7e59e6b62a96f07a01080afdae3ff826e18a0449664f08fe0a7560dd338964dae254881b15f38c5d50e406db24c82d6d6d0e7ce9974f4e2dbef3e6dd
7
- data.tar.gz: 4b3cffe76bb62e01823f95b66b20ce0e90e66480c524646be720164f2a42c99b00357446b1ecdcdb609e9a1cddb0d320a2c3b69a926d8b452c7686a5b562ab1d
6
+ metadata.gz: d03a296115e138ac991c9b23ba4c24fc8bc947253fbd23b337c97e8adddc240634e21fd2973fce8e25c288082cbdb134969c16c2fe2816a2d3ce43f0e0ddc95d
7
+ data.tar.gz: d7f583044bc06894247b146f7bdcb36e1ef2934ee85cf714463fd9ab467952670664a77abc23626b7907a55363519569a38e5624100fe8cfa3d0b63868aa58b4
@@ -20,7 +20,7 @@ module Itimer
20
20
  ret = yield
21
21
  ensure
22
22
  if prev > 0
23
- set(:real, [prev - (Time.now-start), 0].max)
23
+ set(:real, [prev - (Time.now-start), 0.01].max)
24
24
  else
25
25
  set(:real, 0)
26
26
  end
@@ -118,6 +118,23 @@ class ItimerTest < Test::Unit::TestCase
118
118
  end
119
119
  assert( timeouts )
120
120
  assert_in_delta( Time.now-start, 0.25, 0.1 )
121
+
122
+ start = Time.now
123
+ timeouts = false
124
+ assert_raise( Itimer::Timeout ) do
125
+ Itimer.timeout(0.25) do
126
+ begin
127
+ Itimer.timeout(3) do
128
+ sleep 1
129
+ end
130
+ rescue Itimer::Timeout
131
+ timeouts = true
132
+ end
133
+ sleep 1
134
+ end
135
+ end
136
+ assert( timeouts )
137
+ assert_in_delta( Time.now-start, 0.25, 0.1 )
121
138
  end
122
139
 
123
140
  def test_compat
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itimer
3
3
  version: !ruby/object:Gem::Version
4
- version: '5'
4
+ version: '6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-27 00:00:00.000000000 Z
11
+ date: 2013-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler