Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Enable guard. Require HMS 0.0.3 for correct to_f behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas E. Rabenau committed Aug 9, 2012
1 parent 92d4cc7 commit fa92462
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Guardfile
@@ -0,0 +1,10 @@
guard 'bundler' do
watch('Gemfile')
end

guard 'minitest' do
watch(%r|^test/unit/test_(.*)\.rb|)
watch(%r|^lib/*\.rb|){'test'}
watch(%r{^lib/.*/([^/]+)\.rb$}){|m| "test/unit/test_#{m[1]}.rb"}
watch(%r|^test/helper\.rb|){'test'}
end
6 changes: 6 additions & 0 deletions enumstats.gemspec
Expand Up @@ -18,4 +18,10 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'rake'
gem.add_development_dependency 'open4'
gem.add_development_dependency 'pry'
gem.add_development_dependency 'hms', '~> 0.0.3'

gem.add_development_dependency 'guard-minitest', '~> 0.5'
gem.add_development_dependency 'guard-bundler', '~> 1.0'
gem.add_development_dependency 'coolline', '~> 0.3'
gem.add_development_dependency 'growl'
end
11 changes: 11 additions & 0 deletions test/unit/test_enumerable_stats.rb
@@ -1,4 +1,5 @@
require 'helper'
require 'hms'

class TestEnumerableStats < MiniTest::Unit::TestCase
def test_stats_example1
Expand Down Expand Up @@ -44,4 +45,14 @@ def test_median
samples = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
assert_in_delta(9, samples.median, 0.0001)
end

def test_stats_duration
samples = [5.0, 10.0, 15.0].map{|f| HMS::Duration.new(f)}
assert_in_delta(10.0, samples.mean, 1e-6)
assert_in_delta(25.0, samples.variance, 1e-6)
assert_in_delta(5.0, samples.standard_deviation, 1e-6)
assert_in_delta(30.0, samples.sum, 1e-6)
assert_in_delta(5.0, samples.min, 1e-6)
assert_in_delta(15.0, samples.max, 1e-6)
end
end

0 comments on commit fa92462

Please sign in to comment.