Created
December 10, 2009 09:58
-
-
Save takai/253251 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From f226a2854ec17a67d140796273750a4e341dd163 Mon Sep 17 00:00:00 2001 | |
From: Naoto Takai <[email protected]> | |
Date: Fri, 11 Dec 2009 09:30:05 +0900 | |
Subject: [PATCH] Added examples for Method#parameters | |
--- | |
core/method/parameters_spec.rb | 44 +++++++++++++++++++++++++++++++++++++++- | |
1 files changed, 43 insertions(+), 1 deletions(-) | |
diff --git a/core/method/parameters_spec.rb b/core/method/parameters_spec.rb | |
index c40bf27..0ddaee6 100644 | |
--- a/core/method/parameters_spec.rb | |
+++ b/core/method/parameters_spec.rb | |
@@ -1,3 +1,45 @@ | |
require File.dirname(__FILE__) + '/../../spec_helper' | |
+require File.dirname(__FILE__) + '/fixtures/classes' | |
-language_version __FILE__, "parameters" | |
+describe "Method#paprameters" do | |
+ ruby_version_is '1.9.2' do | |
+ | |
+ before(:each) do | |
+ @m = MethodSpecs::Methods.new | |
+ end | |
+ | |
+ it "returns the array of information about parameters" do | |
+ @m.method(:zero).parameters.should == [] | |
+ @m.method(:one_req).parameters.should == [[:req, :a]] | |
+ @m.method(:two_req).parameters.should == [[:req, :a], [:req, :b]] | |
+ | |
+ @m.method(:zero_with_block).parameters.should == [[:block, :block]] | |
+ @m.method(:one_req_with_block).parameters.should == [[:req, :a], [:block, :block]] | |
+ @m.method(:two_req_with_block).parameters.should == [[:req, :a], [:req, :b], [:block, :block]] | |
+ | |
+ @m.method(:one_opt).parameters.should == [[:opt, :a]] | |
+ @m.method(:one_req_one_opt).parameters.should == [[:req, :a], [:opt, :b]] | |
+ @m.method(:one_req_two_opt).parameters.should == [[:req, :a], [:opt, :b], [:opt, :c]] | |
+ @m.method(:two_req_one_opt).parameters.should == [[:req, :a], [:req, :b], [:opt, :c]] | |
+ | |
+ @m.method(:one_opt_with_block).parameters.should == [[:opt, :a], [:block, :block]] | |
+ @m.method(:one_req_one_opt_with_block).parameters.should == [[:req, :a], [:opt, :b], [:block, :block]] | |
+ @m.method(:one_req_two_opt_with_block).parameters.should == [[:req, :a], [:opt, :b], [:opt, :c], [:block, :block]] | |
+ @m.method(:two_req_one_opt_with_block).parameters.should == [[:req, :a], [:req, :b], [:opt, :c], [:block, :block]] | |
+ | |
+ @m.method(:zero_with_splat).parameters.should == [[:rest, :a]] | |
+ @m.method(:one_req_with_splat).parameters.should == [[:req, :a], [:rest, :b]] | |
+ @m.method(:two_req_with_splat).parameters.should == [[:req, :a], [:req, :b], [:rest, :c]] | |
+ @m.method(:one_req_one_opt_with_splat).parameters.should == [[:req, :a], [:opt, :b], [:rest, :c]] | |
+ @m.method(:two_req_one_opt_with_splat).parameters.should == [[:req, :a], [:req, :b], [:opt, :c], [:rest, :d]] | |
+ @m.method(:one_req_two_opt_with_splat).parameters.should == [[:req, :a], [:opt, :b], [:opt, :c], [:rest, :d]] | |
+ | |
+ @m.method(:zero_with_splat_and_block).parameters.should == [[:rest, :a], [:block, :block]] | |
+ @m.method(:one_req_with_splat_and_block).parameters.should == [[:req, :a], [:rest, :b], [:block, :block]] | |
+ @m.method(:two_req_with_splat_and_block).parameters.should == [[:req, :a], [:req, :b], [:rest, :c], [:block, :block]] | |
+ @m.method(:one_req_one_opt_with_splat_and_block).parameters.should == [[:req, :a], [:opt, :b], [:rest, :c], [:block, :block]] | |
+ @m.method(:two_req_one_opt_with_splat_and_block).parameters.should == [[:req, :a], [:req, :b], [:opt, :c], [:rest, :d], [:block, :block]] | |
+ @m.method(:one_req_two_opt_with_splat_and_block).parameters.should == [[:req, :a], [:opt, :b], [:opt, :c], [:rest, :d], [:block, :block]] | |
+ end | |
+ end | |
+end | |
-- | |
1.5.6.5 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../../spec_helper' | |
require File.dirname(__FILE__) + '/fixtures/classes' | |
describe "Method#paprameters" do | |
ruby_version_is '1.9.2' do | |
before(:each) do | |
@m = MethodSpecs::Methods.new | |
end | |
it "returns the array of information about parameters" do | |
@m.method(:zero).parameters.should == [] | |
@m.method(:one_req).parameters.should == [[:req, :a]] | |
@m.method(:two_req).parameters.should == [[:req, :a], [:req, :b]] | |
@m.method(:zero_with_block).parameters.should == [[:block, :block]] | |
@m.method(:one_req_with_block).parameters.should == [[:req, :a], [:block, :block]] | |
@m.method(:two_req_with_block).parameters.should == [[:req, :a], [:req, :b], [:block, :block]] | |
@m.method(:one_opt).parameters.should == [[:opt, :a]] | |
@m.method(:one_req_one_opt).parameters.should == [[:req, :a], [:opt, :b]] | |
@m.method(:one_req_two_opt).parameters.should == [[:req, :a], [:opt, :b], [:opt, :c]] | |
@m.method(:two_req_one_opt).parameters.should == [[:req, :a], [:req, :b], [:opt, :c]] | |
@m.method(:one_opt_with_block).parameters.should == [[:opt, :a], [:block, :block]] | |
@m.method(:one_req_one_opt_with_block).parameters.should == [[:req, :a], [:opt, :b], [:block, :block]] | |
@m.method(:one_req_two_opt_with_block).parameters.should == [[:req, :a], [:opt, :b], [:opt, :c], [:block, :block]] | |
@m.method(:two_req_one_opt_with_block).parameters.should == [[:req, :a], [:req, :b], [:opt, :c], [:block, :block]] | |
@m.method(:zero_with_splat).parameters.should == [[:rest, :a]] | |
@m.method(:one_req_with_splat).parameters.should == [[:req, :a], [:rest, :b]] | |
@m.method(:two_req_with_splat).parameters.should == [[:req, :a], [:req, :b], [:rest, :c]] | |
@m.method(:one_req_one_opt_with_splat).parameters.should == [[:req, :a], [:opt, :b], [:rest, :c]] | |
@m.method(:two_req_one_opt_with_splat).parameters.should == [[:req, :a], [:req, :b], [:opt, :c], [:rest, :d]] | |
@m.method(:one_req_two_opt_with_splat).parameters.should == [[:req, :a], [:opt, :b], [:opt, :c], [:rest, :d]] | |
@m.method(:zero_with_splat_and_block).parameters.should == [[:rest, :a], [:block, :block]] | |
@m.method(:one_req_with_splat_and_block).parameters.should == [[:req, :a], [:rest, :b], [:block, :block]] | |
@m.method(:two_req_with_splat_and_block).parameters.should == [[:req, :a], [:req, :b], [:rest, :c], [:block, :block]] | |
@m.method(:one_req_one_opt_with_splat_and_block).parameters.should == [[:req, :a], [:opt, :b], [:rest, :c], [:block, :block]] | |
@m.method(:two_req_one_opt_with_splat_and_block).parameters.should == [[:req, :a], [:req, :b], [:opt, :c], [:rest, :d], [:block, :block]] | |
@m.method(:one_req_two_opt_with_splat_and_block).parameters.should == [[:req, :a], [:opt, :b], [:opt, :c], [:rest, :d], [:block, :block]] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment