forked from rubinius/rubinius
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rubinius#1725 from carlosgaldino/fix-struct
Fix rubinius#1724
- Loading branch information
Showing
10 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,9 +1,12 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
require File.expand_path('../shared/accessor', __FILE__) | ||
|
||
describe "Struct#length" do | ||
it "returns the number of attributes" do | ||
StructClasses::Car.new('Cadillac', 'DeVille').length.should == 3 | ||
StructClasses::Car.new.length.should == 3 | ||
end | ||
|
||
it_behaves_like :struct_accessor, :length | ||
end |
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe :struct_accessor, :shared => true do | ||
it "does not override the instance accessor method" do | ||
struct = Struct.new(@method.to_sym) | ||
instance = struct.new 42 | ||
instance.send(@method).should == 42 | ||
end | ||
end |
This file contains 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,8 +1,11 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
require File.expand_path('../shared/accessor', __FILE__) | ||
|
||
describe "Struct#size" do | ||
it "is a synonym for length" do | ||
StructClasses::Car.new.size.should == StructClasses::Car.new.length | ||
end | ||
|
||
it_behaves_like :struct_accessor, :length | ||
end |
This file contains 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,9 +1,12 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
require File.expand_path('../shared/accessor', __FILE__) | ||
|
||
describe "Struct#to_a" do | ||
it "returns the values for this instance as an array" do | ||
StructClasses::Car.new('Geo', 'Metro', 1995).to_a.should == ['Geo', 'Metro', 1995] | ||
StructClasses::Car.new('Ford').to_a.should == ['Ford', nil, nil] | ||
end | ||
|
||
it_behaves_like :struct_accessor, :length | ||
end |