-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a conflict in io.rb with #write_nonblock and a conflict in spec/ruby/core/io/read_nonblock_spec.rb.
Showing
59 changed files
with
848 additions
and
209 deletions.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../shared/read', __FILE__) | ||
|
||
describe "ARGF.readpartial" do | ||
it_behaves_like :argf_read, :readpartial | ||
|
||
before :each do | ||
@file1_name = fixture __FILE__, "file1.txt" | ||
@file2_name = fixture __FILE__, "file2.txt" | ||
@stdin_name = fixture __FILE__, "stdin.txt" | ||
|
||
@file1 = File.read @file1_name | ||
@file2 = File.read @file2_name | ||
@stdin = File.read @stdin_name | ||
end | ||
|
||
it "raises an ArgumentError if called without a maximum read length" do | ||
argv [@file1_name] do | ||
lambda { ARGF.readpartial }.should raise_error(ArgumentError) | ||
end | ||
end | ||
|
||
it "reads maximum number of bytes from one file at a time" do | ||
argv [@file1_name, @file2_name] do | ||
len = @file1.size + @file2.size | ||
ARGF.readpartial(len).should == @file1 | ||
end | ||
end | ||
|
||
it "clears output buffer even if EOFError is raised because ARGF is at end" do | ||
begin | ||
output = "to be cleared" | ||
|
||
argv [@file1_name] do | ||
ARGF.read | ||
ARGF.readpartial(1, output) | ||
end | ||
rescue EOFError | ||
output.should == "" | ||
end | ||
end | ||
|
||
it "reads maximum number of bytes from one file at a time" do | ||
argv [@file1_name, @file2_name] do | ||
len = @file1.size + @file2.size | ||
ARGF.readpartial(len).should == @file1 | ||
end | ||
end | ||
|
||
it "returns an empty string if EOFError is raised while reading any but the last file" do | ||
argv [@file1_name, @file2_name] do | ||
ARGF.readpartial(@file1.size) | ||
ARGF.readpartial(1).should == "" | ||
end | ||
end | ||
|
||
it "raises an EOFError if the exception was raised while reading the last file" do | ||
argv [@file1_name, @file2_name] do | ||
ARGF.readpartial(@file1.size) | ||
ARGF.readpartial(1) | ||
ARGF.readpartial(@file2.size) | ||
lambda { ARGF.readpartial(1) }.should raise_error(EOFError) | ||
lambda { ARGF.readpartial(1) }.should raise_error(EOFError) | ||
end | ||
end | ||
|
||
it "raises an EOFError if the exception was raised while reading STDIN" do | ||
ruby_str = <<-STR | ||
print ARGF.readpartial(#{@stdin.size}) | ||
ARGF.readpartial(1) rescue print $!.class | ||
STR | ||
stdin = ruby_exe(ruby_str, args: "< #{@stdin_name}", escape: true) | ||
stdin.should == @stdin + "EOFError" | ||
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
describe :argf_read, shared: true do | ||
before :each do | ||
@file1_name = fixture __FILE__, "file1.txt" | ||
@stdin_name = fixture __FILE__, "stdin.txt" | ||
|
||
@file1 = File.read @file1_name | ||
@stdin = File.read @stdin_name | ||
end | ||
|
||
after :each do | ||
ARGF.close unless ARGF.closed? | ||
end | ||
|
||
it "treats second nil argument as no output buffer" do | ||
argv [@file1_name] do | ||
ARGF.send(@method, @file1.size, nil).should == @file1 | ||
end | ||
end | ||
|
||
it "treats second argument as an output buffer" do | ||
argv [@file1_name] do | ||
buffer = "" | ||
ARGF.send(@method, @file1.size, buffer) | ||
buffer.should == @file1 | ||
end | ||
end | ||
|
||
it "clears output buffer before appending to it" do | ||
argv [@file1_name] do | ||
buffer = "to be cleared" | ||
ARGF.send(@method, @file1.size, buffer) | ||
buffer.should == @file1 | ||
end | ||
end | ||
|
||
it "reads a number of bytes from the first file" do | ||
argv [@file1_name] do | ||
ARGF.send(@method, 5).should == @file1[0, 5] | ||
end | ||
end | ||
|
||
it "reads from a single file consecutively" do | ||
argv [@file1_name] do | ||
ARGF.send(@method, 1).should == @file1[0, 1] | ||
ARGF.send(@method, 2).should == @file1[1, 2] | ||
ARGF.send(@method, 3).should == @file1[3, 3] | ||
end | ||
end | ||
|
||
it "reads a number of bytes from stdin" do | ||
stdin = ruby_exe("print ARGF.#{@method}(10)", :args => "< #{@stdin_name}") | ||
stdin.should == @stdin[0, 10] | ||
end | ||
|
||
platform_is_not :windows do | ||
it "reads the contents of a special device file" do | ||
argv ['/dev/zero'] do | ||
ARGF.send(@method, 100).should == "\000" * 100 | ||
end | ||
end | ||
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
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,36 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
|
||
describe "Enumerable#chunk_while" do | ||
before :each do | ||
ary = [10, 9, 7, 6, 4, 3, 2, 1] | ||
@enum = EnumerableSpecs::Numerous.new *ary | ||
@result = @enum.chunk_while { |i, j| i - 1 == j } | ||
@enum_length = ary.length | ||
end | ||
|
||
context "when given a block" do | ||
it "returns an enumerator" do | ||
@result.should be_an_instance_of(enumerator_class) | ||
end | ||
|
||
it "splits chunks between adjacent elements i and j where the block returns false" do | ||
@result.to_a.should == [[10, 9], [7, 6], [4, 3, 2, 1]] | ||
end | ||
|
||
it "calls the block for length of the receiver enumerable minus one times" do | ||
times_called = 0 | ||
@enum.chunk_while do |i, j| | ||
times_called += 1 | ||
i - 1 != j | ||
end.to_a | ||
times_called.should == (@enum_length - 1) | ||
end | ||
end | ||
|
||
context "when not given a block" do | ||
it "raises an ArgumentError" do | ||
lambda { @enum.chunk_while }.should raise_error(ArgumentError) | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
|
||
describe "Enumerable#grep_v" do | ||
it "returns an array of all elements not equal to the pattern when called without a block" do | ||
pattern_cls = Class.new do | ||
def ===(obj) | ||
obj == '2' | ||
end | ||
end | ||
enum = EnumerableSpecs::Numerous.new('2', 'a', 'nil', '3', false) | ||
|
||
enum.grep_v(pattern_cls.new).should == ['a', 'nil', '3', false] | ||
end | ||
|
||
it "returns an array of all elements not equal to the pattern passed through the block" do | ||
pattern_cls = Class.new do | ||
def ===(obj) | ||
/^ca/ =~ obj | ||
end | ||
end | ||
enum = EnumerableSpecs::Numerous.new("cat", "coat", "car", "cadr", "cost") | ||
|
||
enum.grep_v(pattern_cls.new) { |i| i.upcase }.should == ["COAT", "COST"] | ||
end | ||
|
||
it "calls the block with an array when yielded with multiple arguments" do | ||
yields = [] | ||
EnumerableSpecs::YieldsMixed.new.grep_v(nil) { |v| yields << v } | ||
|
||
yields.should == [1, [2], [3, 4], [5, 6, 7], [8, 9], []] | ||
EnumerableSpecs::YieldsMixed.new.grep_v(nil).should == yields | ||
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
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
require File.expand_path('../../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
|
||
describe "Enumerator::Lazy#grep_v" do | ||
before(:each) do | ||
@yieldsmixed = EnumeratorLazySpecs::YieldsMixed.new.to_enum.lazy | ||
@eventsmixed = EnumeratorLazySpecs::EventsMixed.new.to_enum.lazy | ||
ScratchPad.record [] | ||
end | ||
|
||
after(:each) do | ||
ScratchPad.clear | ||
end | ||
|
||
it "requires an argument" do | ||
enumerator_class::Lazy.instance_method(:grep_v).arity.should == 1 | ||
end | ||
|
||
it "returns a new instance of Enumerator::Lazy" do | ||
ret = @yieldsmixed.grep_v(Object) {} | ||
ret.should be_an_instance_of(enumerator_class::Lazy) | ||
ret.should_not equal(@yieldsmixed) | ||
|
||
ret = @yieldsmixed.grep_v(Object) | ||
ret.should be_an_instance_of(enumerator_class::Lazy) | ||
ret.should_not equal(@yieldsmixed) | ||
end | ||
|
||
it "sets #size to nil" do | ||
enumerator_class::Lazy.new(Object.new, 100) {}.grep_v(Object) {}.size.should == nil | ||
enumerator_class::Lazy.new(Object.new, 100) {}.grep_v(Object).size.should == nil | ||
end | ||
|
||
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do | ||
it "stops after specified times when not given a block" do | ||
(0..Float::INFINITY).lazy.grep_v(3..5).first(3).should == [0, 1, 2] | ||
|
||
@eventsmixed.grep_v(Symbol).first(1) | ||
ScratchPad.recorded.should == [:before_yield] | ||
end | ||
|
||
it "stops after specified times when given a block" do | ||
(0..Float::INFINITY).lazy.grep_v(4..8, &:succ).first(3).should == [1, 2, 3] | ||
|
||
@eventsmixed.grep_v(Symbol) {}.first(1) | ||
ScratchPad.recorded.should == [:before_yield] | ||
end | ||
end | ||
|
||
it "calls the block with a gathered array when yield with multiple arguments" do | ||
yields = [] | ||
@yieldsmixed.grep_v(Array) { |v| yields << v }.force | ||
yields.should == EnumeratorLazySpecs::YieldsMixed.gathered_non_array_yields | ||
|
||
@yieldsmixed.grep_v(Array).force.should == yields | ||
end | ||
|
||
describe "on a nested Lazy" do | ||
it "sets #size to nil" do | ||
enumerator_class::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object) {}.size.should == nil | ||
enumerator_class::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object).size.should == nil | ||
end | ||
|
||
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do | ||
it "stops after specified times when not given a block" do | ||
(0..Float::INFINITY).lazy.grep_v(3..5).grep_v(6..10).first(3).should == [0, 1, 2] | ||
|
||
@eventsmixed.grep_v(Symbol).grep_v(String).first(1) | ||
ScratchPad.recorded.should == [:before_yield] | ||
end | ||
|
||
it "stops after specified times when given a block" do | ||
(0..Float::INFINITY).lazy | ||
.grep_v(1..2) { |n| n > 3 ? n : false } | ||
.grep_v(false) { |n| n.even? ? n : false } | ||
.first(3) | ||
.should == [4, false, 6] | ||
|
||
@eventsmixed.grep_v(Symbol) {}.grep_v(String) {}.first(1) | ||
ScratchPad.recorded.should == [:before_yield] | ||
end | ||
end | ||
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
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
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,10 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
describe "NameError#receiver" do | ||
it "returns the receiver of the method call where the error occurred" do | ||
receiver = 'receiver' | ||
exception = receiver.doesnt_exist rescue $! | ||
|
||
exception.receiver.should equal(receiver) | ||
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
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,51 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
describe "File.mkfifo" do | ||
platform_is_not os: [:windows] do | ||
before do | ||
@path = tmp('fifo') | ||
end | ||
|
||
after do | ||
rm_r(@path) | ||
end | ||
|
||
context "when path passed responds to :to_path" do | ||
it "creates a FIFO file at the path specified" do | ||
File.mkfifo(@path) | ||
File.ftype(@path).should == "fifo" | ||
end | ||
end | ||
|
||
context "when path passed is not a String value" do | ||
it "raises a TypeError" do | ||
lambda { File.mkfifo(:"/tmp/fifo") }.should raise_error(TypeError) | ||
end | ||
end | ||
|
||
context "when path does not exist" do | ||
it "raises an Errno::ENOENT exception" do | ||
lambda { File.mkfifo("/bogus/path") }.should raise_error(Errno::ENOENT) | ||
end | ||
end | ||
|
||
it "creates a FIFO file at the passed path" do | ||
File.mkfifo(@path.to_s) | ||
File.ftype(@path).should == "fifo" | ||
end | ||
|
||
it "creates a FIFO file with passed mode & ~umask" do | ||
File.mkfifo(@path, 0755) | ||
File.stat(@path).mode.should == 010755 & ~File.umask | ||
end | ||
|
||
it "creates a FIFO file with a default mode of 0666 & ~umask" do | ||
File.mkfifo(@path) | ||
File.stat(@path).mode.should == 010666 & ~File.umask | ||
end | ||
|
||
it "returns 0 after creating the FIFO file" do | ||
File.mkfifo(@path).should == 0 | ||
end | ||
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
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,31 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
describe "Hash#fetch_values" do | ||
before do | ||
@h = new_hash(foo: 1, bar: 2, baz: 3) | ||
end | ||
|
||
it "returns an array containing the values associated with the given keys" do | ||
@h.fetch_values(:foo, :baz).should == [1, 3] | ||
end | ||
|
||
context "when one of the given keys does not exist" do | ||
context "when no block is given" do | ||
it "raises a KeyError" do | ||
lambda { @h.fetch_values(:foo, :foobar) }.should raise_error(KeyError) | ||
end | ||
end | ||
|
||
context "when a block is given" do | ||
it "returns the value of the block for the missing key" do | ||
@h.fetch_values(:foo, :foobar) { |k| k.length }.should == [1, 6] | ||
end | ||
end | ||
end | ||
|
||
context "when called with no arguments" do | ||
it "returns an empty array" do | ||
@h.fetch_values.should == [] | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../shared/comparison', __FILE__) | ||
require File.expand_path('../shared/greater_than', __FILE__) | ||
|
||
describe "Hash#>=" do | ||
it_behaves_like :hash_comparison, :>= | ||
it_behaves_like :hash_greater_than, :>= | ||
|
||
it "returns true if both hashes are identical" do | ||
h = new_hash(a: 1, b: 2) | ||
(h >= h).should be_true | ||
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../shared/comparison', __FILE__) | ||
require File.expand_path('../shared/greater_than', __FILE__) | ||
|
||
describe "Hash#>" do | ||
it_behaves_like :hash_comparison, :> | ||
it_behaves_like :hash_greater_than, :> | ||
|
||
it "returns false if both hashes are identical" do | ||
h = new_hash(a: 1, b: 2) | ||
(h > h).should be_false | ||
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../shared/comparison', __FILE__) | ||
require File.expand_path('../shared/less_than', __FILE__) | ||
|
||
describe "Hash#<=" do | ||
it_behaves_like :hash_comparison, :<= | ||
it_behaves_like :hash_less_than, :<= | ||
|
||
it "returns true if both hashes are identical" do | ||
h = new_hash(a: 1, b: 2) | ||
(h <= h).should be_true | ||
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../shared/comparison', __FILE__) | ||
require File.expand_path('../shared/less_than', __FILE__) | ||
|
||
describe "Hash#<" do | ||
it_behaves_like :hash_comparison, :< | ||
it_behaves_like :hash_less_than, :< | ||
|
||
it "returns false if both hashes are identical" do | ||
h = new_hash(a: 1, b: 2) | ||
(h < h).should be_false | ||
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
describe :hash_comparison, shared: true do | ||
it "raises a TypeError if the right operand is not a hash" do | ||
lambda { new_hash(a: 1).send(@method, 1) }.should raise_error(TypeError) | ||
lambda { new_hash(a: 1).send(@method, nil) }.should raise_error(TypeError) | ||
lambda { new_hash(a: 1).send(@method, []) }.should raise_error(TypeError) | ||
end | ||
|
||
it "returns false if both hashes have the same keys but different values" do | ||
h1 = new_hash(a: 1) | ||
h2 = new_hash(a: 2) | ||
|
||
h1.send(@method, h2).should be_false | ||
h2.send(@method, h1).should be_false | ||
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
describe :hash_greater_than, shared: true do | ||
before do | ||
@h1 = new_hash(a: 1, b: 2, c: 3) | ||
@h2 = new_hash(a: 1, b: 2) | ||
end | ||
|
||
it "returns true if the other hash is a subset of self" do | ||
@h1.send(@method, @h2).should be_true | ||
end | ||
|
||
it "returns false if the other hash is not a subset of self" do | ||
@h2.send(@method, @h1).should be_false | ||
end | ||
|
||
it "converts the right operand to a hash before comparing" do | ||
o = Object.new | ||
def o.to_hash | ||
new_hash(a: 1, b: 2) | ||
end | ||
|
||
@h1.send(@method, o).should be_true | ||
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
describe :hash_less_than, shared: true do | ||
before do | ||
@h1 = new_hash(a: 1, b: 2) | ||
@h2 = new_hash(a: 1, b: 2, c: 3) | ||
end | ||
|
||
it "returns true if self is a subset of the other hash" do | ||
@h1.send(@method, @h2).should be_true | ||
end | ||
|
||
it "returns false if self is not a subset of the other hash" do | ||
@h2.send(@method, @h1).should be_false | ||
end | ||
|
||
it "converts the right operand to a hash before comparing" do | ||
o = Object.new | ||
def o.to_hash | ||
new_hash(a: 1, b: 2, c: 3) | ||
end | ||
|
||
@h1.send(@method, o).should be_true | ||
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
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
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 @@ | ||
fails:NameError#receiver returns the receiver of the method call where the error occurred |
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,2 +1,3 @@ | ||
fails:The super keyword raises a RuntimeError when called with implicit arguments from a method defined with define_method | ||
fails:The super keyword invokes methods from a chain of anonymous modules | ||
fails:The super keyword when using keyword arguments does not pass any keyword arguments to the parent when none are given |
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