huh 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/huh.rb +17 -19
  2. metadata +3 -3
data/lib/huh.rb CHANGED
@@ -1,25 +1,23 @@
1
1
  class Huh
2
2
  class Failure < StandardError; end
3
- class << self
4
- attr_accessor :a, :t, :f
5
- def test(name, &block)
6
- @t= oz(@t) + 1
7
- begin
8
- yield
9
- rescue Failure => e
10
- print "Testing #{name} [\033[1;49;31mFAILED\033[0m]\n"
11
- else
12
- print "Testing #{name} [\033[1;49;32mPASSED\033[0m]\n"
13
- end
3
+ def self.test(name, &block)
4
+ @t = oz(@t) + 1
5
+ begin
6
+ yield
7
+ rescue Failure => e
8
+ print "Testing #{name} [\033[1;49;31mFAILED\033[0m]\n"
9
+ else
10
+ print "Testing #{name} [\033[1;49;32mPASSED\033[0m]\n"
14
11
  end
15
- def assert(truth)
16
- !!truth ? (@a = oz(@a) + 1) : (@f = oz(@f) + 1; raise Failure)
17
- end
18
- def oz(v); v or 0; end # value or_zero
19
- def flunk; assert(false); end # always fails
20
- def assert_equal(a,b); assert(a == b); end # true == true..yes
21
- def assert_nil(a); assert(a.nil?); end # true == true..yes
22
- def finish!;puts "\n#{oz(@t)} tests, #{oz(@a)} assertions, #{oz(@f)} failures. #{(((oz(@t)-oz(@f)).to_f/@t.to_f)*100).to_i}% passing tests"; end # spit out info
12
+ end
13
+ def self.assert(truth)
14
+ !!truth ? (@a = oz(@a) + 1) : (@f = oz(@f) + 1; raise Failure)
15
+ end
16
+ def self.oz(v); v or 0; end # value or_zero
17
+ def self.flunk; assert(false); end # always fails
18
+ def self.assert_equal(a,b); assert(a == b); end # true == true..yes
19
+ def self.assert_nil(a); assert(a.nil?); end # true == true..yes
20
+ def self.finish!;puts "\n#{oz(@t)} tests, #{oz(@a)} assertions, #{oz(@f)} failures. #{(((oz(@t)-oz(@f)).to_f/@t.to_f)*100).to_i}% passing tests"; end # spit out info
23
21
  end
24
22
  end
25
23
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: huh
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Baker