-
-
Notifications
You must be signed in to change notification settings - Fork 397
Move remaining core specs to use fewer shared examples - Part 2 #1370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,293
−2,581
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
022c15a
Move UnboundMethod to rely less on shared examples
Earlopain 1ba1d00
Move Time to rely less on shared examples
Earlopain f57e2b5
Move Thread to rely less on shared examples
Earlopain bd37499
Move Symbol to rely less on shared examples
Earlopain c50a2c5
Move Struct to rely less on shared examples
Earlopain 362ce82
Move String to rely less on shared examples
Earlopain 0f964d5
Move Set to rely less on shared examples
Earlopain 5a505fe
Move Regexp to rely less on shared examples
Earlopain 575c856
Move Refinement to rely less on shared examples
Earlopain 77806dc
Move Rational to rely less on shared examples
Earlopain 55e8aa2
Move Range to rely less on shared examples
Earlopain 8444d31
Move Proc to rely less on shared examples
Earlopain 2a5483a
Move Numeric to rely less on shared examples
Earlopain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,19 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/abs' | ||
| require_relative 'fixtures/classes' | ||
|
|
||
| describe "Numeric#abs" do | ||
| it_behaves_like :numeric_abs, :abs | ||
| before :each do | ||
| @obj = NumericSpecs::Subclass.new | ||
| end | ||
|
|
||
| it "returns self when self is greater than 0" do | ||
| @obj.should_receive(:<).with(0).and_return(false) | ||
| @obj.abs.should == @obj | ||
| end | ||
|
|
||
| it "returns self\#@- when self is less than 0" do | ||
| @obj.should_receive(:<).with(0).and_return(true) | ||
| @obj.should_receive(:-@).and_return(:absolute_value) | ||
| @obj.abs.should == :absolute_value | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/arg' | ||
|
|
||
| describe "Numeric#angle" do | ||
| it_behaves_like :numeric_arg, :angle | ||
| it "is an alias of Numeric#arg" do | ||
| Numeric.instance_method(:angle).should == Numeric.instance_method(:arg) | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,38 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/arg' | ||
|
|
||
| describe "Numeric#arg" do | ||
| it_behaves_like :numeric_arg, :arg | ||
| before :each do | ||
| @numbers = [ | ||
| 20, | ||
| Rational(3, 4), | ||
| bignum_value, | ||
| infinity_value | ||
| ] | ||
| end | ||
|
|
||
| it "returns 0 if positive" do | ||
| @numbers.each do |number| | ||
| number.arg.should == 0 | ||
| end | ||
| end | ||
|
|
||
| it "returns Pi if negative" do | ||
| @numbers.each do |number| | ||
| (0-number).arg.should == Math::PI | ||
| end | ||
| end | ||
|
|
||
| describe "with a Numeric subclass" do | ||
| it "returns 0 if self#<(0) returns false" do | ||
| numeric = mock_numeric('positive') | ||
| numeric.should_receive(:<).with(0).and_return(false) | ||
| numeric.arg.should == 0 | ||
| end | ||
|
|
||
| it "returns Pi if self#<(0) returns true" do | ||
| numeric = mock_numeric('positive') | ||
| numeric.should_receive(:<).with(0).and_return(true) | ||
| numeric.arg.should == Math::PI | ||
| end | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/conj' | ||
|
|
||
| describe "Numeric#conj" do | ||
| it_behaves_like :numeric_conj, :conj | ||
| it "is an alias of Numeric#conjugate" do | ||
| Numeric.instance_method(:conj).should == Numeric.instance_method(:conjugate) | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,20 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/conj' | ||
|
|
||
| describe "Numeric#conjugate" do | ||
| it_behaves_like :numeric_conj, :conjugate | ||
| before :each do | ||
| @numbers = [ | ||
| 20, # Integer | ||
| 398.72, # Float | ||
| Rational(3, 4), # Rational | ||
| bignum_value, | ||
| infinity_value, | ||
| nan_value | ||
| ] | ||
| end | ||
|
|
||
| it "returns self" do | ||
| @numbers.each do |number| | ||
| number.conjugate.should.equal?(number) | ||
| end | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/imag' | ||
|
|
||
| describe "Numeric#imag" do | ||
| it_behaves_like :numeric_imag, :imag | ||
| it "is an alias of Numeric#imaginary" do | ||
| Numeric.instance_method(:imag).should == Numeric.instance_method(:imaginary) | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,26 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/imag' | ||
|
|
||
| describe "Numeric#imaginary" do | ||
| it_behaves_like :numeric_imag, :imaginary | ||
| before :each do | ||
| @numbers = [ | ||
| 20, # Integer | ||
| 398.72, # Float | ||
| Rational(3, 4), # Rational | ||
| bignum_value, # Bignum | ||
| infinity_value, | ||
| nan_value | ||
| ].map{|n| [n,-n]}.flatten | ||
| end | ||
|
|
||
| it "returns 0" do | ||
| @numbers.each do |number| | ||
| number.imaginary.should == 0 | ||
| end | ||
| end | ||
|
|
||
| it "raises an ArgumentError if given any arguments" do | ||
| @numbers.each do |number| | ||
| -> { number.imaginary(number) }.should.raise(ArgumentError) | ||
| end | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| require_relative "../../spec_helper" | ||
| require_relative 'shared/abs' | ||
|
|
||
| describe "Numeric#magnitude" do | ||
| it_behaves_like :numeric_abs, :magnitude | ||
| it "is an alias of Numeric#abs" do | ||
| Numeric.instance_method(:magnitude).should == Numeric.instance_method(:abs) | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/arg' | ||
|
|
||
| describe "Numeric#phase" do | ||
| it_behaves_like :numeric_arg, :phase | ||
| it "is an alias of Numeric#arg" do | ||
| Numeric.instance_method(:phase).should == Numeric.instance_method(:arg) | ||
| end | ||
|
Earlopain marked this conversation as resolved.
|
||
| end | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/rect' | ||
|
|
||
| describe "Numeric#rect" do | ||
| it_behaves_like :numeric_rect, :rect | ||
| it "is an alias of Numeric#rectangular" do | ||
| Numeric.instance_method(:rect).should == Numeric.instance_method(:rectangular) | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,48 @@ | ||
| require_relative '../../spec_helper' | ||
| require_relative 'shared/rect' | ||
|
|
||
| describe "Numeric#rectangular" do | ||
| it_behaves_like :numeric_rect, :rectangular | ||
| before :each do | ||
| @numbers = [ | ||
| 20, # Integer | ||
| 398.72, # Float | ||
| Rational(3, 4), # Rational | ||
| 99999999**99, # Bignum | ||
| infinity_value, | ||
| nan_value | ||
| ] | ||
| end | ||
|
|
||
| it "returns an Array" do | ||
| @numbers.each do |number| | ||
| number.rectangular.should.instance_of?(Array) | ||
| end | ||
| end | ||
|
|
||
| it "returns a two-element Array" do | ||
| @numbers.each do |number| | ||
| number.rectangular.size.should == 2 | ||
| end | ||
| end | ||
|
|
||
| it "returns self as the first element" do | ||
| @numbers.each do |number| | ||
| if Float === number and number.nan? | ||
| number.rectangular.first.nan?.should == true | ||
| else | ||
| number.rectangular.first.should == number | ||
| end | ||
| end | ||
| end | ||
|
|
||
| it "returns 0 as the last element" do | ||
| @numbers.each do |number| | ||
| number.rectangular.last.should == 0 | ||
| end | ||
| end | ||
|
|
||
| it "raises an ArgumentError if given any arguments" do | ||
| @numbers.each do |number| | ||
| -> { number.rectangular(number) }.should.raise(ArgumentError) | ||
| end | ||
| end | ||
| end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.