File: monotonic_time_spec.rb

package info (click to toggle)
ruby-concurrent 1.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,152 kB
  • sloc: ruby: 30,953; java: 6,128; ansic: 293; makefile: 26; sh: 19
file content (32 lines) | stat: -rw-r--r-- 865 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'concurrent/utility/monotonic_time'

module Concurrent

  RSpec.describe :monotonic_time do
    context 'behavior' do

      it 'returns seconds as float' do
        expect(Concurrent.monotonic_time).to be_a(Float)
      end

      [:float_second, :float_millisecond, :float_microsecond].each do |unit|
        it "returns a Float when unit = #{unit.inspect}" do
          expect(Concurrent.monotonic_time(unit)).to be_a(Float)
        end
      end

      [:second, :millisecond, :microsecond, :nanosecond].each do |unit|
        it "returns an Integer when unit = #{unit.inspect}" do
          expect(Concurrent.monotonic_time(unit)).to be_an(Integer)
        end
      end

      it 'raises ArgumentError on unknown units' do
        expect {
          Concurrent.monotonic_time(:foo)
        }.to raise_error(ArgumentError)
      end

    end
  end
end