-
Notifications
You must be signed in to change notification settings - Fork 1
/
testi.rb
56 lines (42 loc) · 912 Bytes
/
testi.rb
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module Testi
class TestiRunner
#v0.25 Casimir Pohjanraito
#Example use:
#require "testi/testi.rb"
#testi "testing if test works?" { true }
#testi "Is a integer?" { 1.is_a?(Integer) }
#testitulos
@@tests, @@passed, @@failed = 0, 0, 0
def initialize(test_str, test_proc)
@@tests += 1
print "Testi: " + test_str + " "
result = test_proc.call
if result == true
print "- ok."
@@passed += 1
else
print "# FAIL!!! ############"
@@failed += 1
end
print "\n"
end
def self.stats
print "Testi tot: #{@@tests}, ok: #{@@passed}, fail: #{@@failed} at " + Time.now.to_s
end
def self.reset
@@tests, @@passed, @@failed = 0, 0, 0
end
end #Testi class
#convenience
def testi(name_str, &block)
TestiRunner.new(name_str, block)
end
def testitulos
TestiRunner.stats
true
end
def testireset
TestiRunner.reset
end
end
extend Testi