[前][次][番号順一覧][スレッド一覧]

ruby-changes:18324

From: ryan <ko1@a...>
Date: Sat, 25 Dec 2010 13:55:21 +0900 (JST)
Subject: [ruby-changes:18324] Ruby:r30347 (trunk): Imported minitest 2.0.2 r6093

ryan	2010-12-25 13:55:15 +0900 (Sat, 25 Dec 2010)

  New Revision: 30347

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30347

  Log:
    Imported minitest 2.0.2 r6093

  Modified files:
    trunk/ChangeLog
    trunk/lib/minitest/benchmark.rb
    trunk/lib/minitest/mock.rb
    trunk/lib/minitest/unit.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30346)
+++ ChangeLog	(revision 30347)
@@ -1,3 +1,7 @@
+Sat Dec 25 13:37:55 2010  Ryan Davis  <ryand-ruby@z...>
+
+	* lib/minitest/*.rb: Imported minitest 2.0.2 r6093.
+
 Sat Dec 25 13:05:59 2010  Tanaka Akira  <akr@f...>
 
 	* random.c: parenthesize macro arguments.
Index: lib/minitest/unit.rb
===================================================================
--- lib/minitest/unit.rb	(revision 30346)
+++ lib/minitest/unit.rb	(revision 30347)
@@ -520,7 +520,7 @@
   end
 
   class Unit
-    VERSION = "2.0.1" # :nodoc:
+    VERSION = "2.0.2" # :nodoc:
 
     attr_accessor :report, :failures, :errors, :skips # :nodoc:
     attr_accessor :test_count, :assertion_count       # :nodoc:
Index: lib/minitest/mock.rb
===================================================================
--- lib/minitest/mock.rb	(revision 30346)
+++ lib/minitest/mock.rb	(revision 30347)
@@ -6,18 +6,40 @@
 
 class MockExpectationError < StandardError; end
 
+##
+# A simple and clean mock object framework.
+
 module MiniTest
+
+  ##
+  # All mock objects are an instance of Mock
+
   class Mock
-    def initialize
+    def initialize # :nodoc:
       @expected_calls = {}
       @actual_calls = Hash.new {|h,k| h[k] = [] }
     end
 
+    ##
+    # Expect that method +name+ is called, optionally with +args+, and
+    # returns +retval+.
+    #
+    #   @mock.expect(:meaning_of_life, 42)
+    #   @mock.meaning_of_life # => 42
+    #
+    #   @mock.expect(:do_something_with, true, [some_obj, true])
+    #   @mock.do_something_with(some_obj, true) # => true
+
     def expect(name, retval, args=[])
       @expected_calls[name] = { :retval => retval, :args => args }
       self
     end
 
+    ##
+    # Verify that all methods were called as expected. Raises
+    # +MockExpectationError+ if the mock object was not called as
+    # expected.
+
     def verify
       @expected_calls.each_key do |name|
         expected = @expected_calls[name]
@@ -28,7 +50,7 @@
       true
     end
 
-    def method_missing(sym, *args)
+    def method_missing(sym, *args) # :nodoc:
       raise NoMethodError unless @expected_calls.has_key?(sym)
       raise ArgumentError unless @expected_calls[sym][:args].size == args.size
       retval = @expected_calls[sym][:retval]
@@ -37,7 +59,7 @@
     end
 
     alias :original_respond_to? :respond_to?
-    def respond_to?(sym)
+    def respond_to?(sym) # :nodoc:
       return true if @expected_calls.has_key?(sym)
       return original_respond_to?(sym)
     end
Index: lib/minitest/benchmark.rb
===================================================================
--- lib/minitest/benchmark.rb	(revision 30346)
+++ lib/minitest/benchmark.rb	(revision 30347)
@@ -10,11 +10,11 @@
 class MiniTest::Unit
   attr_accessor :runner
 
-  def run_benchmarks
+  def run_benchmarks # :nodoc:
     _run_anything :benchmark
   end
 
-  def benchmark_suite_header suite
+  def benchmark_suite_header suite # :nodoc:
     "\n#{suite}\t#{suite.bench_range.join("\t")}"
   end
 
@@ -301,27 +301,63 @@
 end
 
 class MiniTest::Spec
+  ##
+  # This is used to define a new benchmark method. You usually don't
+  # use this directly and is intended for those needing to write new
+  # performance curve fits (eg: you need a specific polynomial fit).
+  #
+  # See ::bench_performance_linear for an example of how to use this.
+
   def self.bench name, &block
     define_method "bench_#{name.gsub(/\W+/, '_')}", &block
   end
 
   def self.bench_range &block
+    return super unless block
+
     meta = (class << self; self; end)
     meta.send :define_method, "bench_range", &block
   end
 
+  ##
+  # Create a benchmark that verifies that the performance is linear.
+  #
+  #   describe "my class" do
+  #     bench_performance_linear "fast_algorithm", 0.9999 do
+  #       @obj.fast_algorithm
+  #     end
+  #   end
+
   def self.bench_performance_linear name, threshold = 0.9, &work
     bench name do
       assert_performance_linear threshold, &work
     end
   end
 
+  ##
+  # Create a benchmark that verifies that the performance is constant.
+  #
+  #   describe "my class" do
+  #     bench_performance_constant "zoom_algorithm!" do
+  #       @obj.zoom_algorithm!
+  #     end
+  #   end
+
   def self.bench_performance_constant name, threshold = 0.99, &work
     bench name do
       assert_performance_constant threshold, &work
     end
   end
 
+  ##
+  # Create a benchmark that verifies that the performance is exponential.
+  #
+  #   describe "my class" do
+  #     bench_performance_exponential "algorithm" do
+  #       @obj.algorithm
+  #     end
+  #   end
+
   def self.bench_performance_exponential name, threshold = 0.99, &work
     bench name do
       assert_performance_exponential threshold, &work

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]