minitest 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +10 -0
- data/lib/minitest/benchmark.rb +38 -2
- data/lib/minitest/mock.rb +25 -3
- data/lib/minitest/unit.rb +1 -1
- metadata +3 -3
- metadata.gz.sig +3 -2
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/lib/minitest/benchmark.rb
CHANGED
@@ -4,11 +4,11 @@ require 'minitest/spec'
|
|
4
4
|
class MiniTest::Unit
|
5
5
|
attr_accessor :runner
|
6
6
|
|
7
|
-
def run_benchmarks
|
7
|
+
def run_benchmarks # :nodoc:
|
8
8
|
_run_anything :benchmark
|
9
9
|
end
|
10
10
|
|
11
|
-
def benchmark_suite_header suite
|
11
|
+
def benchmark_suite_header suite # :nodoc:
|
12
12
|
"\n#{suite}\t#{suite.bench_range.join("\t")}"
|
13
13
|
end
|
14
14
|
|
@@ -295,27 +295,63 @@ class MiniTest::Unit
|
|
295
295
|
end
|
296
296
|
|
297
297
|
class MiniTest::Spec
|
298
|
+
##
|
299
|
+
# This is used to define a new benchmark method. You usually don't
|
300
|
+
# use this directly and is intended for those needing to write new
|
301
|
+
# performance curve fits (eg: you need a specific polynomial fit).
|
302
|
+
#
|
303
|
+
# See ::bench_performance_linear for an example of how to use this.
|
304
|
+
|
298
305
|
def self.bench name, &block
|
299
306
|
define_method "bench_#{name.gsub(/\W+/, '_')}", &block
|
300
307
|
end
|
301
308
|
|
302
309
|
def self.bench_range &block
|
310
|
+
return super unless block
|
311
|
+
|
303
312
|
meta = (class << self; self; end)
|
304
313
|
meta.send :define_method, "bench_range", &block
|
305
314
|
end
|
306
315
|
|
316
|
+
##
|
317
|
+
# Create a benchmark that verifies that the performance is linear.
|
318
|
+
#
|
319
|
+
# describe "my class" do
|
320
|
+
# bench_performance_linear "fast_algorithm", 0.9999 do
|
321
|
+
# @obj.fast_algorithm
|
322
|
+
# end
|
323
|
+
# end
|
324
|
+
|
307
325
|
def self.bench_performance_linear name, threshold = 0.9, &work
|
308
326
|
bench name do
|
309
327
|
assert_performance_linear threshold, &work
|
310
328
|
end
|
311
329
|
end
|
312
330
|
|
331
|
+
##
|
332
|
+
# Create a benchmark that verifies that the performance is constant.
|
333
|
+
#
|
334
|
+
# describe "my class" do
|
335
|
+
# bench_performance_constant "zoom_algorithm!" do
|
336
|
+
# @obj.zoom_algorithm!
|
337
|
+
# end
|
338
|
+
# end
|
339
|
+
|
313
340
|
def self.bench_performance_constant name, threshold = 0.99, &work
|
314
341
|
bench name do
|
315
342
|
assert_performance_constant threshold, &work
|
316
343
|
end
|
317
344
|
end
|
318
345
|
|
346
|
+
##
|
347
|
+
# Create a benchmark that verifies that the performance is exponential.
|
348
|
+
#
|
349
|
+
# describe "my class" do
|
350
|
+
# bench_performance_exponential "algorithm" do
|
351
|
+
# @obj.algorithm
|
352
|
+
# end
|
353
|
+
# end
|
354
|
+
|
319
355
|
def self.bench_performance_exponential name, threshold = 0.99, &work
|
320
356
|
bench name do
|
321
357
|
assert_performance_exponential threshold, &work
|
data/lib/minitest/mock.rb
CHANGED
@@ -1,17 +1,39 @@
|
|
1
1
|
class MockExpectationError < StandardError; end
|
2
2
|
|
3
|
+
##
|
4
|
+
# A simple and clean mock object framework.
|
5
|
+
|
3
6
|
module MiniTest
|
7
|
+
|
8
|
+
##
|
9
|
+
# All mock objects are an instance of Mock
|
10
|
+
|
4
11
|
class Mock
|
5
|
-
def initialize
|
12
|
+
def initialize # :nodoc:
|
6
13
|
@expected_calls = {}
|
7
14
|
@actual_calls = Hash.new {|h,k| h[k] = [] }
|
8
15
|
end
|
9
16
|
|
17
|
+
##
|
18
|
+
# Expect that method +name+ is called, optionally with +args+, and
|
19
|
+
# returns +retval+.
|
20
|
+
#
|
21
|
+
# @mock.expect(:meaning_of_life, 42)
|
22
|
+
# @mock.meaning_of_life # => 42
|
23
|
+
#
|
24
|
+
# @mock.expect(:do_something_with, true, [some_obj, true])
|
25
|
+
# @mock.do_something_with(some_obj, true) # => true
|
26
|
+
|
10
27
|
def expect(name, retval, args=[])
|
11
28
|
@expected_calls[name] = { :retval => retval, :args => args }
|
12
29
|
self
|
13
30
|
end
|
14
31
|
|
32
|
+
##
|
33
|
+
# Verify that all methods were called as expected. Raises
|
34
|
+
# +MockExpectationError+ if the mock object was not called as
|
35
|
+
# expected.
|
36
|
+
|
15
37
|
def verify
|
16
38
|
@expected_calls.each_key do |name|
|
17
39
|
expected = @expected_calls[name]
|
@@ -22,7 +44,7 @@ module MiniTest
|
|
22
44
|
true
|
23
45
|
end
|
24
46
|
|
25
|
-
def method_missing(sym, *args)
|
47
|
+
def method_missing(sym, *args) # :nodoc:
|
26
48
|
raise NoMethodError unless @expected_calls.has_key?(sym)
|
27
49
|
raise ArgumentError unless @expected_calls[sym][:args].size == args.size
|
28
50
|
retval = @expected_calls[sym][:retval]
|
@@ -31,7 +53,7 @@ module MiniTest
|
|
31
53
|
end
|
32
54
|
|
33
55
|
alias :original_respond_to? :respond_to?
|
34
|
-
def respond_to?(sym)
|
56
|
+
def respond_to?(sym) # :nodoc:
|
35
57
|
return true if @expected_calls.has_key?(sym)
|
36
58
|
return original_respond_to?(sym)
|
37
59
|
end
|
data/lib/minitest/unit.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 2.0.
|
8
|
+
- 2
|
9
|
+
version: 2.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ryan Davis
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
FBHgymkyj/AOSqKRIpXPhjC6
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2010-12-
|
38
|
+
date: 2010-12-24 00:00:00 -08:00
|
39
39
|
default_executable:
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
aJ�s�{t����Ä�[���%�R�Ɲ?B�MEE 骍R5m>c�i�^����ƨP��hd�f� ΤΫ�>��v��1�(�#hă
|
2
|
+
Mf�z�%8�3l��`)Og���ћ��+ɐ��p.���$�cg�![3��φ������cd��-�g$_��h@N|��۱�~�8g��N�_�O�V�_/ 9��p
|
3
|
+
6#�ĥ�O��*�{RG ���@x�.�{ej2���x����v�nXHc,�F�c
|