-
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.
Merge pull request #3518 from rubinius/2.2
WIP: 2.2 compat
- v5.0
- v4.20
- v4.19
- v4.18
- v4.17
- v4.16
- v4.15
- v4.14
- v4.13
- v4.12
- v4.11
- v4.10
- v4.9
- v4.8
- v4.7
- v4.6
- v4.5
- v4.4
- v4.3
- v4.2
- v4.1
- v4.0
- v3.107
- v3.106
- v3.105
- v3.104
- v3.103
- v3.102
- v3.101
- v3.100
- v3.99
- v3.98
- v3.97
- v3.96
- v3.95
- v3.94
- v3.93
- v3.92
- v3.91
- v3.90
- v3.89
- v3.88
- v3.87
- v3.86
- v3.85
- v3.84
- v3.83
- v3.82
- v3.81
- v3.80
- v3.79
- v3.78
- v3.77
- v3.76
- v3.75
- v3.74
- v3.73
- v3.72
- v3.71
- v3.70
- v3.69
- v3.68
- v3.67
- v3.66
- v3.65
- v3.64
- v3.63
- v3.62
- v3.61
- v3.60
- v3.59
- v3.58
- v3.57
- v3.56
- v3.55
- v3.54
- v3.53
- v3.52
- v3.51
- v3.50
- v3.49
- v3.48
- v3.47
- v3.46
- v3.45
- v3.44
- v3.43
- v3.42
- v3.41
- v3.40
- v3.39
- v3.38
- v3.37
- v3.36
- v3.35
- v3.34
- v3.33
- v3.32
- v3.31
- v3.30
- v3.29
- v3.28
- v3.27
- v3.26
- v3.25
- v3.24
- v3.23
- v3.22
- v3.21
- v3.20
- v3.19
- v3.18
- v3.17
- v3.16
- v3.15
- v3.14
- v3.13
- v3.12
- v3.11
- v3.10
- v3.9
- v3.8
- v3.7
- v3.6
- v3.5
- v3.4
- v3.3
- v3.2
- v3.1
Showing
68 changed files
with
1,386 additions
and
332 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 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
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
describe "Binding#local_variables" do | ||
it "returns an Array" do | ||
binding.local_variables.should be_kind_of(Array) | ||
end | ||
|
||
it "includes local variables in the current scope" do | ||
a = 1 | ||
b = nil | ||
binding.local_variables.should == [:a, :b] | ||
end | ||
|
||
it "includes local variables defined after calling binding.local_variables" do | ||
binding.local_variables.should == [:a, :b] | ||
a = 1 | ||
b = 2 | ||
end | ||
|
||
it "includes local variables of inherited scopes and eval'ed context" do | ||
p = proc { |a| b = 1; eval("c = 2; binding.local_variables") } | ||
p.call.should == [:c, :a, :b, :p] | ||
end | ||
|
||
it "includes shadowed local variables only once" do | ||
a = 1 | ||
proc { a = 2; binding.local_variables }.call.should == [:a] | ||
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,11 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
|
||
describe "Binding#receiver" do | ||
it "returns the object to which binding is bound" do | ||
obj = BindingSpecs::Demo.new(1) | ||
obj.get_binding.receiver.should == obj | ||
|
||
binding.receiver.should == self | ||
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
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,53 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
|
||
describe "Enumerable#slice_after" do | ||
before :each do | ||
@enum = EnumerableSpecs::Numerous.new(7, 6, 5, 4, 3, 2, 1) | ||
end | ||
|
||
describe "when given an argument and no block" do | ||
it "calls === on the argument to determine when to yield" do | ||
arg = mock "filter" | ||
arg.should_receive(:===).and_return(false, true, false, false, false, true, false) | ||
e = @enum.slice_after(arg) | ||
e.should be_an_instance_of(enumerator_class) | ||
e.to_a.should == [[7, 6], [5, 4, 3, 2], [1]] | ||
end | ||
|
||
it "doesn't yield an empty array if the filter matches the first entry or the last entry" do | ||
arg = mock "filter" | ||
arg.should_receive(:===).and_return(true).exactly(7) | ||
e = @enum.slice_after(arg) | ||
e.to_a.should == [[7], [6], [5], [4], [3], [2], [1]] | ||
end | ||
|
||
it "uses standard boolean as a test" do | ||
arg = mock "filter" | ||
arg.should_receive(:===).and_return(false, :foo, nil, false, false, 42, false) | ||
e = @enum.slice_after(arg) | ||
e.to_a.should == [[7, 6], [5, 4, 3, 2], [1]] | ||
end | ||
end | ||
|
||
describe "when given a block" do | ||
describe "and no argument" do | ||
it "calls the block to determine when to yield" do | ||
e = @enum.slice_after{ |i| i == 6 || i == 2 } | ||
e.should be_an_instance_of(enumerator_class) | ||
e.to_a.should == [[7, 6], [5, 4, 3, 2], [1]] | ||
end | ||
end | ||
|
||
describe "and an argument" do | ||
it "raises an ArgumentError" do | ||
lambda { @enum.slice_after(42) { |i| i == 6 } }.should raise_error(ArgumentError) | ||
end | ||
end | ||
end | ||
|
||
it "raises an ArgumentError when given an incorrect number of arguments" do | ||
lambda { @enum.slice_after("one", "two") }.should raise_error(ArgumentError) | ||
lambda { @enum.slice_after }.should raise_error(ArgumentError) | ||
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,36 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
|
||
describe "Enumerable#slice_when" do | ||
before :each do | ||
ary = [10, 9, 7, 6, 4, 3, 2, 1] | ||
@enum = EnumerableSpecs::Numerous.new *ary | ||
@result = @enum.slice_when { |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 true" 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.slice_when 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.slice_when }.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,56 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
describe "File.birthtime" do | ||
before :each do | ||
@file = __FILE__ | ||
end | ||
|
||
after :each do | ||
@file = nil | ||
end | ||
|
||
platform_is :darwin do | ||
it "returns the birth time for the named file as a Time object" do | ||
File.birthtime(@file) | ||
File.birthtime(@file).should be_kind_of(Time) | ||
end | ||
|
||
it "accepts an object that has a #to_path method" do | ||
File.birthtime(mock_to_path(@file)) | ||
end | ||
|
||
it "raises an Errno::ENOENT exception if the file is not found" do | ||
lambda { File.birthtime('bogus') }.should raise_error(Errno::ENOENT) | ||
end | ||
end | ||
|
||
platform_is :windows, :linux, :openbsd, :freebsd, :netbsd do | ||
it "raises an NotImplementedError" do | ||
lambda { File.birthtime(@file) }.should raise_error(NotImplementedError) | ||
end | ||
end | ||
end | ||
|
||
describe "File#birthtime" do | ||
before :each do | ||
@file = File.open(__FILE__) | ||
end | ||
|
||
after :each do | ||
@file.close | ||
@file = nil | ||
end | ||
|
||
platform_is :darwin do | ||
it "returns the birth time for self" do | ||
@file.birthtime | ||
@file.birthtime.should be_kind_of(Time) | ||
end | ||
end | ||
|
||
platform_is :windows, :linux, :openbsd, :freebsd, :netbsd do | ||
it "raises an NotImplementedError" do | ||
lambda { @file.birthtime }.should raise_error(NotImplementedError) | ||
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
@file = File.open(__FILE__) | ||
end | ||
|
||
after:each do | ||
after :each do | ||
@file.close | ||
@file = nil | ||
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,18 @@ | ||
require File.expand_path('../../../../spec_helper', __FILE__) | ||
|
||
describe "File::Stat#birthtime" do | ||
before :each do | ||
@file = tmp('i_exist') | ||
touch(@file) { |f| f.write "rubinius" } | ||
end | ||
|
||
after :each do | ||
rm_r @file | ||
end | ||
|
||
it "returns the birthtime of a File::Stat object" do | ||
st = File.stat(@file) | ||
st.birthtime.should be_kind_of(Time) | ||
st.birthtime.should <= Time.now | ||
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,44 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
describe "Float" do | ||
it "returns a float the smallest possible step greater than the receiver" do | ||
barely_positive = 0.0.next_float | ||
barely_positive.should eql 0.0.next_float | ||
|
||
barely_positive.should > 0.0 | ||
barely_positive.should < barely_positive.next_float | ||
|
||
midpoint = barely_positive / 2 | ||
[0.0, barely_positive].should include midpoint | ||
end | ||
|
||
it "steps directly between MAX and INFINITY" do | ||
(-Float::INFINITY).next_float.should eql -Float::MAX | ||
Float::MAX.next_float.should eql Float::INFINITY | ||
end | ||
|
||
it "steps directly between 1.0 and EPSILON + 1.0" do | ||
1.0.next_float.should eql Float::EPSILON + 1.0 | ||
end | ||
|
||
it "steps directly between -1.0 and EPSILON/2 - 1.0" do | ||
(-1.0).next_float.should eql Float::EPSILON/2 - 1.0 | ||
end | ||
|
||
it "reverses the effect of prev_float" do | ||
num = rand | ||
num.prev_float.next_float.should eql num | ||
end | ||
|
||
it "returns negative zero when stepping upward from just below zero" do | ||
x = 0.0.prev_float.next_float | ||
(1/x).should eql -Float::INFINITY | ||
x = (-0.0).prev_float.next_float | ||
(1/x).should eql -Float::INFINITY | ||
x.next_float.should > 0 | ||
end | ||
|
||
it "returns NAN if NAN was the receiver" do | ||
Float::NAN.next_float.nan?.should eql 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,44 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
describe "Float" do | ||
it "returns a float the smallest possible step greater than the receiver" do | ||
barely_negative = 0.0.prev_float | ||
barely_negative.should eql 0.0.prev_float | ||
|
||
barely_negative.should < 0.0 | ||
barely_negative.should > barely_negative.prev_float | ||
|
||
midpoint = barely_negative / 2 | ||
[0.0, barely_negative].should include midpoint | ||
end | ||
|
||
it "steps directly between MAX and INFINITY" do | ||
Float::INFINITY.prev_float.should eql Float::MAX | ||
(-Float::MAX).prev_float.should eql -Float::INFINITY | ||
end | ||
|
||
it "steps directly between 1.0 and -EPSILON/2 + 1.0" do | ||
1.0.prev_float.should eql -Float::EPSILON/2 + 1.0 | ||
end | ||
|
||
it "steps directly between -1.0 and -EPSILON - 1.0" do | ||
(-1.0).prev_float.should eql -Float::EPSILON - 1.0 | ||
end | ||
|
||
it "reverses the effect of next_float" do | ||
num = rand | ||
num.next_float.prev_float.should eql num | ||
end | ||
|
||
it "returns positive zero when stepping downward from just above zero" do | ||
x = 0.0.next_float.prev_float | ||
(1/x).should eql Float::INFINITY | ||
x = (-0.0).next_float.prev_float | ||
(1/x).should eql Float::INFINITY | ||
x.prev_float.should < 0 | ||
end | ||
|
||
it "returns NAN if NAN was the receiver" do | ||
Float::NAN.prev_float.nan?.should eql 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
|
||
describe "Method#curry" do | ||
|
||
it "returns a curried proc" do | ||
x = Object.new | ||
def x.foo(a,b,c); [a,b,c]; end | ||
|
||
c = x.method(:foo).curry | ||
c.should be_kind_of(Proc) | ||
c.(1).(2, 3).should == [1,2,3] | ||
end | ||
|
||
describe "with optional arity argument" do | ||
before(:each) do | ||
@obj = MethodSpecs::Methods.new | ||
end | ||
|
||
it "returns a curried proc when given correct arity" do | ||
@obj.method(:one_req).curry(1).should be_kind_of(Proc) | ||
@obj.method(:zero_with_splat).curry(100).should be_kind_of(Proc) | ||
@obj.method(:two_req_with_splat).curry(2).should be_kind_of(Proc) | ||
end | ||
|
||
it "raises ArgumentError when the method requires less arguments than the given arity" do | ||
lambda { @obj.method(:zero).curry(1) }.should raise_error(ArgumentError) | ||
lambda { @obj.method(:one_req_one_opt).curry(3) }.should raise_error(ArgumentError) | ||
lambda { @obj.method(:two_req_one_opt_with_block).curry(4) }.should raise_error(ArgumentError) | ||
end | ||
|
||
it "raises ArgumentError when the method requires more arguments than the given arity" do | ||
lambda { @obj.method(:two_req_with_splat).curry(1) }.should raise_error(ArgumentError) | ||
lambda { @obj.method(:one_req).curry(0) }.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
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,39 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
|
||
describe "Method#super_method" do | ||
it "returns the method that would be called by super in the method" do | ||
obj = MethodSpecs::C.new | ||
obj.extend MethodSpecs::OverrideAgain | ||
meth = obj.method(:overridden) | ||
|
||
s_meth = meth.super_method | ||
s_meth.owner.should == MethodSpecs::C | ||
s_meth.receiver.should == obj | ||
s_meth.name.should == :overridden | ||
|
||
ss_meth = meth.super_method.super_method | ||
ss_meth.owner.should == MethodSpecs::BetweenBAndC | ||
ss_meth.receiver.should == obj | ||
ss_meth.name.should == :overridden | ||
|
||
sss_meth = meth.super_method.super_method.super_method | ||
sss_meth.owner.should == MethodSpecs::B | ||
sss_meth.receiver.should == obj | ||
sss_meth.name.should == :overridden | ||
end | ||
|
||
it "returns nil when there's no super method in the parent" do | ||
method = Object.new.method(:method) | ||
method.super_method.should == nil | ||
end | ||
|
||
it "returns nil when the parent's method is removed" do | ||
object = MethodSpecs::B.new | ||
method = object.method(:overridden) | ||
|
||
MethodSpecs::A.class_eval { undef :overridden } | ||
|
||
method.super_method.should == nil | ||
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,103 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
# Examples taken from http://www.unicode.org/reports/tr15/#Norm_Forms | ||
|
||
describe "String#unicode_normalize" do | ||
before do | ||
@accented_f = "\u1e9b\u0323" | ||
@angstrom = "\u212b" | ||
@ohm = "\u2126" | ||
end | ||
|
||
it "normalizes code points in the string according to the form that is specified" do | ||
@accented_f.unicode_normalize(:nfc).should == "\u1e9b\u0323" | ||
@accented_f.unicode_normalize(:nfd).should == "\u017f\u0323\u0307" | ||
@accented_f.unicode_normalize(:nfkc).should == "\u1e69" | ||
@accented_f.unicode_normalize(:nfkd).should == "\u0073\u0323\u0307" | ||
end | ||
|
||
it "defaults to the nfc normalization form if no forms are specified" do | ||
@accented_f.unicode_normalize.should == "\u1e9b\u0323" | ||
@angstrom.unicode_normalize.should == "\u00c5" | ||
@ohm.unicode_normalize.should == "\u03a9" | ||
end | ||
|
||
it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do | ||
lambda do | ||
@angstrom.force_encoding("ISO-8859-1").unicode_normalize | ||
end.should raise_error(Encoding::CompatibilityError) | ||
end | ||
|
||
it "raises an ArgumentError if the specified form is invalid" do | ||
lambda { @angstrom.unicode_normalize(:invalid_form) }.should raise_error(ArgumentError) | ||
end | ||
end | ||
|
||
describe "String#unicode_normalize!" do | ||
before do | ||
@ohm = "\u2126" | ||
end | ||
|
||
it "normalizes code points and modifies the receiving string" do | ||
angstrom = "\u212b" | ||
angstrom.unicode_normalize! | ||
angstrom.should == "\u00c5" | ||
angstrom.should_not == "\u212b" | ||
end | ||
|
||
it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do | ||
lambda do | ||
@ohm.force_encoding("ISO-8859-1").unicode_normalize! | ||
end.should raise_error(Encoding::CompatibilityError) | ||
end | ||
|
||
it "raises an ArgumentError if the specified form is invalid" do | ||
lambda { @ohm.unicode_normalize!(:invalid_form) }.should raise_error(ArgumentError) | ||
end | ||
end | ||
|
||
describe "String#unicode_normalized?" do | ||
before do | ||
@nfc_normalized_str = "\u1e9b\u0323" | ||
@nfd_normalized_str = "\u017f\u0323\u0307" | ||
@nfkc_normalized_str = "\u1e69" | ||
@nfkd_normalized_str = "\u0073\u0323\u0307" | ||
end | ||
|
||
it "returns true if string is in the specified normalization form" do | ||
@nfc_normalized_str.unicode_normalized?(:nfc).should == true | ||
@nfd_normalized_str.unicode_normalized?(:nfd).should == true | ||
@nfkc_normalized_str.unicode_normalized?(:nfkc).should == true | ||
@nfkd_normalized_str.unicode_normalized?(:nfkd).should == true | ||
end | ||
|
||
it "returns false if string is not in the supplied normalization form" do | ||
@nfd_normalized_str.unicode_normalized?(:nfc).should == false | ||
@nfc_normalized_str.unicode_normalized?(:nfd).should == false | ||
@nfc_normalized_str.unicode_normalized?(:nfkc).should == false | ||
@nfc_normalized_str.unicode_normalized?(:nfkd).should == false | ||
end | ||
|
||
it "defaults to the nfc normalization form if no forms are specified" do | ||
@nfc_normalized_str.unicode_normalized?.should == true | ||
@nfd_normalized_str.unicode_normalized?.should == false | ||
end | ||
|
||
it "returns true if string is empty" do | ||
"".unicode_normalized?.should == true | ||
end | ||
|
||
it "returns true if string does not contain any unicode codepoints" do | ||
"abc".unicode_normalized?.should == true | ||
end | ||
|
||
it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do | ||
lambda do | ||
@nfc_normalized_str.force_encoding("ISO-8859-1").unicode_normalized? | ||
end.should raise_error(Encoding::CompatibilityError) | ||
end | ||
|
||
it "raises an ArgumentError if the specified form is invalid" do | ||
lambda { @nfc_normalized_str.unicode_normalized?(:invalid_form) }.should raise_error(ArgumentError) | ||
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,26 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require File.expand_path('../fixtures/classes', __FILE__) | ||
|
||
describe "UnboundMethod#super_method" do | ||
it "returns the method that would be called by super in the method" do | ||
meth = UnboundMethodSpecs::C.instance_method(:overridden) | ||
meth = meth.super_method | ||
meth.should == UnboundMethodSpecs::B.instance_method(:overridden) | ||
meth = meth.super_method | ||
meth.should == UnboundMethodSpecs::A.instance_method(:overridden) | ||
end | ||
|
||
it "returns nil when there's no super method in the parent" do | ||
method = Object.instance_method(:method) | ||
method.super_method.should == nil | ||
end | ||
|
||
it "returns nil when the parent's method is removed" do | ||
object = UnboundMethodSpecs::B | ||
method = object.instance_method(:overridden) | ||
|
||
UnboundMethodSpecs::A.class_eval { undef :overridden } | ||
|
||
method.super_method.should == nil | ||
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
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:File::Stat#birthtime returns the birthtime of a File::Stat object |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:Kernel#frozen? on nil returns true | ||
fails:Kernel#frozen? on true returns true | ||
fails:Kernel#frozen? on false returns true |
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:Method#curry with optional arity argument raises ArgumentError when the method requires less arguments than the given arity |
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:raises an ArgumentError if called on a lambda that requires fewer than _arity_ arguments |
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,14 @@ | ||
fails:String#unicode_normalize normalizes code points in the string according to the form that is specified | ||
fails:String#unicode_normalize defaults to the nfc normalization form if no forms are specified | ||
fails:String#unicode_normalize raises an Encoding::CompatibilityError if the string is not in an unicode encoding | ||
fails:String#unicode_normalize raises an ArgumentError if the specified form is invalid | ||
fails:String#unicode_normalize! normalizes code points and modifies the receiving string | ||
fails:String#unicode_normalize! raises an Encoding::CompatibilityError if the string is not in an unicode encoding | ||
fails:String#unicode_normalize! raises an ArgumentError if the specified form is invalid | ||
fails:String#unicode_normalized? returns true if string is in the specified normalization form | ||
fails:String#unicode_normalized? returns false if string is not in the supplied normalization form | ||
fails:String#unicode_normalized? defaults to the nfc normalization form if no forms are specified | ||
fails:String#unicode_normalized? returns true if string is empty | ||
fails:String#unicode_normalized? returns true if string does not contain any unicode codepoints | ||
fails:String#unicode_normalized? raises an Encoding::CompatibilityError if the string is not in an unicode encoding | ||
fails:String#unicode_normalized? raises an ArgumentError if the specified form is invalid |
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,2 @@ | ||
fails:Post-args with optional args with a circular argument reference shadows an existing local with the same name as the argument | ||
fails:Post-args with optional args with a circular argument reference shadows an existing method with the same name as the argument |
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:An instance method with a default argument shadows an existing method with the same name as the local | ||
fails:A singleton method definition raises RuntimeError if frozen | ||
fails:A method definition inside a metaclass scope raises RuntimeError if frozen |
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,4 @@ | ||
fails:Hash literal accepts mixed 'key: value', 'key => value' and '"key"': value' syntax | ||
fails:Hash literal calls #to_hash to convert an '**obj' element | ||
fails:Hash literal expands an '**obj' element into the containing Hash and keeps the latter keys if there are duplicates | ||
fails:Hash literal merges multiple nested '**obj' in Hash literals |
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,2 @@ | ||
fails:A lambda literal -> () { } assigns variables from parameters with circular optional argument reference shadows an existing local with the same name as the argument | ||
fails:A lambda literal -> () { } assigns variables from parameters with circular optional argument reference shadows an existing method with the same name as the argument |
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