huh 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/huh.rb +17 -19
- metadata +3 -3
data/lib/huh.rb
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
class Huh
|
2
2
|
class Failure < StandardError; end
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Baker
|