mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@cbe855c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ecf03376ec
commit
37ef87c12b
38 changed files with 185 additions and 177 deletions
|
@ -158,6 +158,8 @@ guard -> { max_uint <= fixnum_max } do
|
|||
end
|
||||
```
|
||||
|
||||
Custom guards are better than a simple `if` as they allow [mspec commands](https://github.com/ruby/mspec/issues/30#issuecomment-312487779) to work properly.
|
||||
|
||||
In general, the usage of guards should be minimized as possible.
|
||||
|
||||
There are no guards to define implementation-specific behavior because
|
||||
|
|
|
@ -24,9 +24,9 @@ The language specs are grouped by keyword while the core and standard library sp
|
|||
|
||||
ruby/spec is known to be tested in these implementations for every commit:
|
||||
* [MRI](http://rubyci.org/) on 30 platforms and 4 versions
|
||||
* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) on Travis for both 1.7 and 9.x
|
||||
* [TruffleRuby](https://github.com/graalvm/truffleruby) on Travis
|
||||
* [Opal](https://github.com/opal/opal/tree/master/spec) on Travis
|
||||
* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) for both 1.7 and 9.x
|
||||
* [TruffleRuby](https://github.com/oracle/truffleruby)
|
||||
* [Opal](https://github.com/opal/opal/tree/master/spec)
|
||||
|
||||
ruby/spec describes the behavior of Ruby 2.2 and more recent Ruby versions.
|
||||
More precisely, every latest stable MRI release [passes](https://rubyci.org/) all specs of ruby/spec
|
||||
|
|
|
@ -1,4 +1,29 @@
|
|||
describe "ruby -E" do
|
||||
it "sets the external encoding with '-E external'" do
|
||||
result = ruby_exe("print Encoding.default_external", options: '-E euc-jp')
|
||||
result.should == "EUC-JP"
|
||||
end
|
||||
|
||||
it "also sets the filesystem encoding with '-E external'" do
|
||||
result = ruby_exe("print Encoding.find('filesystem')", options: '-E euc-jp')
|
||||
result.should == "EUC-JP"
|
||||
end
|
||||
|
||||
it "sets the external encoding with '-E external:'" do
|
||||
result = ruby_exe("print Encoding.default_external", options: '-E Shift_JIS:')
|
||||
result.should == "Shift_JIS"
|
||||
end
|
||||
|
||||
it "sets the internal encoding with '-E :internal'" do
|
||||
ruby_exe("print Encoding.default_internal", options: '-E :SHIFT_JIS').
|
||||
should == 'Shift_JIS'
|
||||
end
|
||||
|
||||
it "sets the external and internal encodings with '-E external:internal'" do
|
||||
ruby_exe("puts Encoding.default_external, Encoding.default_internal", options: '-E euc-jp:SHIFT_JIS').
|
||||
should == "EUC-JP\nShift_JIS\n"
|
||||
end
|
||||
|
||||
it "raises a RuntimeError if used with -U" do
|
||||
ruby_exe("p 1",
|
||||
options: '-Eascii:ascii -U',
|
||||
|
|
|
@ -10,8 +10,7 @@ describe "Array#clear" do
|
|||
|
||||
it "returns self" do
|
||||
a = [1]
|
||||
oid = a.object_id
|
||||
a.clear.object_id.should == oid
|
||||
a.should equal a.clear
|
||||
end
|
||||
|
||||
it "leaves the Array empty" do
|
||||
|
|
|
@ -50,7 +50,7 @@ describe "Array#compact!" do
|
|||
|
||||
it "returns self if some nil elements are removed" do
|
||||
a = ['a', nil, 'b', false, 'c']
|
||||
a.compact!.object_id.should == a.object_id
|
||||
a.compact!.should equal a
|
||||
end
|
||||
|
||||
it "returns nil if there are no nil elements to remove" do
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/select', __FILE__)
|
||||
|
||||
describe "Array#filter" do
|
||||
it_behaves_like :array_select, :filter
|
||||
end
|
||||
|
||||
describe "Array#filter!" do
|
||||
it "returns nil if no changes were made in the array" do
|
||||
[1, 2, 3].filter! { true }.should be_nil
|
||||
ruby_version_is "2.6" do
|
||||
describe "Array#filter" do
|
||||
it_behaves_like :array_select, :filter
|
||||
end
|
||||
|
||||
it_behaves_like :keep_if, :filter!
|
||||
describe "Array#filter!" do
|
||||
it "returns nil if no changes were made in the array" do
|
||||
[1, 2, 3].filter! { true }.should be_nil
|
||||
end
|
||||
|
||||
it_behaves_like :keep_if, :filter!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,9 +9,9 @@ describe "Array#reject" do
|
|||
ary = [1, 2, 3, 4, 5]
|
||||
ary.reject { true }.should == []
|
||||
ary.reject { false }.should == ary
|
||||
ary.reject { false }.object_id.should_not == ary.object_id
|
||||
ary.reject { false }.should_not equal ary
|
||||
ary.reject { nil }.should == ary
|
||||
ary.reject { nil }.object_id.should_not == ary.object_id
|
||||
ary.reject { nil }.should_not equal ary
|
||||
ary.reject { 5 }.should == []
|
||||
ary.reject { |i| i < 3 }.should == [3, 4, 5]
|
||||
ary.reject { |i| i % 2 == 0 }.should == [1, 3, 5]
|
||||
|
|
|
@ -7,8 +7,8 @@ describe :array_clone, shared: true do
|
|||
it "produces a shallow copy where the references are directly copied" do
|
||||
a = [mock('1'), mock('2')]
|
||||
b = a.send @method
|
||||
b.first.object_id.should == a.first.object_id
|
||||
b.last.object_id.should == a.last.object_id
|
||||
b.first.should equal a.first
|
||||
b.last.should equal a.last
|
||||
end
|
||||
|
||||
it "creates a new array containing all elements or the original" do
|
||||
|
|
|
@ -5,7 +5,7 @@ describe :array_collect, shared: true do
|
|||
a = ['a', 'b', 'c', 'd']
|
||||
b = a.send(@method) { |i| i + '!' }
|
||||
b.should == ["a!", "b!", "c!", "d!"]
|
||||
b.object_id.should_not == a.object_id
|
||||
b.should_not equal a
|
||||
end
|
||||
|
||||
it "does not return subclass instance" do
|
||||
|
@ -70,7 +70,7 @@ describe :array_collect_b, shared: true do
|
|||
it "returns self" do
|
||||
a = [1, 2, 3, 4, 5]
|
||||
b = a.send(@method) {|i| i+1 }
|
||||
a.object_id.should == b.object_id
|
||||
a.should equal b
|
||||
end
|
||||
|
||||
it "returns the evaluated value of block but its contents is partially modified, if it broke in the block" do
|
||||
|
|
|
@ -55,14 +55,11 @@ with_feature :encoding do
|
|||
it "returns an Encoding::InvalidByteSequenceError when the last call to #convert produced one" do
|
||||
ec = Encoding::Converter.new("utf-8", "iso-8859-1")
|
||||
exception = nil
|
||||
lambda do
|
||||
begin
|
||||
ec.convert("\xf1abcd")
|
||||
rescue Encoding::InvalidByteSequenceError => e
|
||||
exception = e
|
||||
raise e
|
||||
end
|
||||
end.should raise_error(Encoding::InvalidByteSequenceError)
|
||||
-> {
|
||||
ec.convert("\xf1abcd")
|
||||
}.should raise_error(Encoding::InvalidByteSequenceError) { |e|
|
||||
exception = e
|
||||
}
|
||||
ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError)
|
||||
ec.last_error.message.should == exception.message
|
||||
end
|
||||
|
@ -70,16 +67,27 @@ with_feature :encoding do
|
|||
it "returns an Encoding::UndefinedConversionError when the last call to #convert produced one" do
|
||||
ec = Encoding::Converter.new("utf-8", "iso-8859-1")
|
||||
exception = nil
|
||||
lambda do
|
||||
begin
|
||||
ec.convert("\u{9899}")
|
||||
rescue Encoding::UndefinedConversionError => e
|
||||
exception = e
|
||||
raise e
|
||||
end
|
||||
end.should raise_error(Encoding::UndefinedConversionError)
|
||||
-> {
|
||||
ec.convert("\u{9899}")
|
||||
}.should raise_error(Encoding::UndefinedConversionError) { |e|
|
||||
exception = e
|
||||
}
|
||||
ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError)
|
||||
ec.last_error.message.should == exception.message
|
||||
ec.last_error.message.should include "from UTF-8 to ISO-8859-1"
|
||||
end
|
||||
|
||||
it "returns the last error of #convert with a message showing the transcoding path" do
|
||||
ec = Encoding::Converter.new("iso-8859-1", "Big5")
|
||||
exception = nil
|
||||
-> {
|
||||
ec.convert("\xE9") # é in ISO-8859-1
|
||||
}.should raise_error(Encoding::UndefinedConversionError) { |e|
|
||||
exception = e
|
||||
}
|
||||
ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError)
|
||||
ec.last_error.message.should == exception.message
|
||||
ec.last_error.message.should include "from ISO-8859-1 to UTF-8 to Big5"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,25 +15,8 @@ with_feature :encoding do
|
|||
end
|
||||
|
||||
it "returns the default external encoding" do
|
||||
Encoding.default_external = Encoding::UTF_8
|
||||
Encoding.default_external.should == Encoding::UTF_8
|
||||
end
|
||||
|
||||
describe "with command line options" do
|
||||
it "is not changed by the -U option" do
|
||||
result = ruby_exe("print Encoding.default_external", options: '-U')
|
||||
result.should == Encoding.default_external.name
|
||||
end
|
||||
|
||||
it "returns the encoding specified by '-E external'" do
|
||||
result = ruby_exe("print Encoding.default_external", options: '-E euc-jp')
|
||||
result.should == "EUC-JP"
|
||||
end
|
||||
|
||||
it "returns the encoding specified by '-E external:'" do
|
||||
result = ruby_exe("print Encoding.default_external", options: '-E Shift_JIS:')
|
||||
result.should == "Shift_JIS"
|
||||
end
|
||||
Encoding.default_external = Encoding::SHIFT_JIS
|
||||
Encoding.default_external.should == Encoding::SHIFT_JIS
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -47,8 +30,14 @@ with_feature :encoding do
|
|||
end
|
||||
|
||||
it "sets the default external encoding" do
|
||||
Encoding.default_external = Encoding::UTF_8
|
||||
Encoding.default_external.should == Encoding::UTF_8
|
||||
Encoding.default_external = Encoding::SHIFT_JIS
|
||||
Encoding.default_external.should == Encoding::SHIFT_JIS
|
||||
Encoding.find('external').should == Encoding::SHIFT_JIS
|
||||
end
|
||||
|
||||
it "also sets the filesystem encoding" do
|
||||
Encoding.default_external = Encoding::SHIFT_JIS
|
||||
Encoding.find('filesystem').should == Encoding::SHIFT_JIS
|
||||
end
|
||||
|
||||
it "can accept a name of an encoding as a String" do
|
||||
|
|
|
@ -28,23 +28,6 @@ with_feature :encoding do
|
|||
Encoding.default_internal = Encoding::ASCII_8BIT
|
||||
Encoding.default_internal.should == Encoding::ASCII_8BIT
|
||||
end
|
||||
|
||||
describe "with command line options" do
|
||||
it "returns Encoding::UTF_8 if ruby was invoked with -U" do
|
||||
ruby_exe("print Encoding.default_internal", options: '-U').
|
||||
should == 'UTF-8'
|
||||
end
|
||||
|
||||
it "uses the encoding specified when ruby is invoked with an '-E :internal' argument" do
|
||||
ruby_exe("print Encoding.default_internal", options: '-E :SHIFT_JIS').
|
||||
should == 'Shift_JIS'
|
||||
end
|
||||
|
||||
it "uses the encoding specified when ruby is invoked with an '-E external:internal' argument" do
|
||||
ruby_exe("print Encoding.default_internal", options: '-E UTF-8:SHIFT_JIS').
|
||||
should == 'Shift_JIS'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Encoding.default_internal=" do
|
||||
|
|
|
@ -2,6 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
require File.expand_path('../shared/find_all', __FILE__)
|
||||
|
||||
describe "Enumerable#filter" do
|
||||
it_behaves_like(:enumerable_find_all , :filter)
|
||||
ruby_version_is "2.6" do
|
||||
describe "Enumerable#filter" do
|
||||
it_behaves_like(:enumerable_find_all , :filter)
|
||||
end
|
||||
end
|
||||
|
|
2
spec/ruby/core/env/shared/to_hash.rb
vendored
2
spec/ruby/core/env/shared/to_hash.rb
vendored
|
@ -17,6 +17,6 @@ describe :env_to_hash, shared: true do
|
|||
|
||||
it "duplicates the ENV when converting to a Hash" do
|
||||
h = ENV.send(@method)
|
||||
h.object_id.should_not == ENV.object_id
|
||||
h.should_not equal ENV
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ describe "NoMethodError#args" do
|
|||
NoMethodErrorSpecs::NoMethodErrorB.new.foo(1,a)
|
||||
rescue Exception => e
|
||||
e.args.should == [1,a]
|
||||
e.args[1].object_id.should == a.object_id
|
||||
e.args[1].should equal a
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ describe "Hash#clone" do
|
|||
clone = hash.clone
|
||||
|
||||
clone.should == hash
|
||||
clone.object_id.should_not == hash.object_id
|
||||
clone.should_not equal hash
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ describe "Hash#compare_by_identity" do
|
|||
@idh[foo] = true
|
||||
@idh[foo] = true
|
||||
@idh.size.should == 1
|
||||
@idh.keys.first.object_id.should == foo.object_id
|
||||
@idh.keys.first.should equal foo
|
||||
end
|
||||
|
||||
ruby_bug "#12855", "2.2.0"..."2.4.1" do
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/select', __FILE__)
|
||||
|
||||
describe "Hash#filter" do
|
||||
it_behaves_like :hash_select, :filter
|
||||
end
|
||||
ruby_version_is "2.6" do
|
||||
describe "Hash#filter" do
|
||||
it_behaves_like :hash_select, :filter
|
||||
end
|
||||
|
||||
describe "Hash#filter!" do
|
||||
it_behaves_like :hash_select!, :filter!
|
||||
describe "Hash#filter!" do
|
||||
it_behaves_like :hash_select!, :filter!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -257,7 +257,7 @@ describe "IO#read" do
|
|||
it "returns the given buffer" do
|
||||
buf = ""
|
||||
|
||||
@io.read(nil, buf).object_id.should == buf.object_id
|
||||
@io.read(nil, buf).should equal buf
|
||||
end
|
||||
|
||||
it "coerces the second argument to string and uses it as a buffer" do
|
||||
|
@ -265,7 +265,7 @@ describe "IO#read" do
|
|||
obj = mock("buff")
|
||||
obj.should_receive(:to_str).any_number_of_times.and_return(buf)
|
||||
|
||||
@io.read(15, obj).object_id.should_not == obj.object_id
|
||||
@io.read(15, obj).should_not equal obj
|
||||
buf.should == @contents
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ describe :kernel_float, shared: true do
|
|||
float = 1.12
|
||||
float2 = @object.send(:Float, float)
|
||||
float2.should == float
|
||||
float2.object_id.should == float.object_id
|
||||
float2.should equal float
|
||||
end
|
||||
|
||||
it "returns a Float for Fixnums" do
|
||||
|
|
|
@ -10,18 +10,29 @@ describe :kernel_integer, shared: true do
|
|||
Integer(100).should == 100
|
||||
end
|
||||
|
||||
it "raises a TypeError when to_int returns not-an-Integer object and to_i returns nil" do
|
||||
obj = mock("object")
|
||||
obj.should_receive(:to_int).and_return("1")
|
||||
obj.should_receive(:to_i).and_return(nil)
|
||||
lambda { Integer(obj) }.should raise_error(TypeError)
|
||||
ruby_version_is ""..."2.6" do
|
||||
it "uncritically return the value of to_int even if it is not an Integer" do
|
||||
obj = mock("object")
|
||||
obj.should_receive(:to_int).and_return("1")
|
||||
obj.should_not_receive(:to_i)
|
||||
Integer(obj).should == "1"
|
||||
end
|
||||
end
|
||||
|
||||
it "return a result of to_i when to_int does not return an Integer" do
|
||||
obj = mock("object")
|
||||
obj.should_receive(:to_int).and_return("1")
|
||||
obj.should_receive(:to_i).and_return(42)
|
||||
Integer(obj).should == 42
|
||||
ruby_version_is "2.6" do
|
||||
it "raises a TypeError when to_int returns not-an-Integer object and to_i returns nil" do
|
||||
obj = mock("object")
|
||||
obj.should_receive(:to_int).and_return("1")
|
||||
obj.should_receive(:to_i).and_return(nil)
|
||||
lambda { Integer(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "return a result of to_i when to_int does not return an Integer" do
|
||||
obj = mock("object")
|
||||
obj.should_receive(:to_int).and_return("1")
|
||||
obj.should_receive(:to_i).and_return(42)
|
||||
Integer(obj).should == 42
|
||||
end
|
||||
end
|
||||
|
||||
it "raises a TypeError when passed nil" do
|
||||
|
|
|
@ -14,4 +14,10 @@ describe "MatchData#inspect" do
|
|||
# it makes perfect sense. See JRUBY-4558 for example.
|
||||
@match_data.inspect.should == '#<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">'
|
||||
end
|
||||
|
||||
it "returns a human readable representation of named captures" do
|
||||
match_data = "abc def ghi".match(/(?<first>\w+)\s+(?<last>\w+)\s+(\w+)/)
|
||||
|
||||
match_data.inspect.should == '#<MatchData "abc def ghi" first:"abc" last:"def">'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,14 +8,14 @@ describe "Proc as a block pass argument" do
|
|||
it "remains the same object if re-vivified by the target method" do
|
||||
p = Proc.new {}
|
||||
p2 = revivify(&p)
|
||||
p.object_id.should == p2.object_id
|
||||
p.should equal p2
|
||||
p.should == p2
|
||||
end
|
||||
|
||||
it "remains the same object if reconstructed with Proc.new" do
|
||||
p = Proc.new {}
|
||||
p2 = Proc.new(&p)
|
||||
p.object_id.should == p2.object_id
|
||||
p.should equal p2
|
||||
p.should == p2
|
||||
end
|
||||
end
|
||||
|
@ -28,14 +28,14 @@ describe "Proc as an implicit block pass argument" do
|
|||
it "remains the same object if re-vivified by the target method" do
|
||||
p = Proc.new {}
|
||||
p2 = revivify(&p)
|
||||
p.object_id.should == p2.object_id
|
||||
p.should equal p2
|
||||
p.should == p2
|
||||
end
|
||||
|
||||
it "remains the same object if reconstructed with Proc.new" do
|
||||
p = Proc.new {}
|
||||
p2 = Proc.new(&p)
|
||||
p.object_id.should == p2.object_id
|
||||
p.should equal p2
|
||||
p.should == p2
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ with_feature :encoding do
|
|||
describe "String#chr" do
|
||||
it "returns a copy of self" do
|
||||
s = 'e'
|
||||
s.object_id.should_not == s.chr.object_id
|
||||
s.should_not equal s.chr
|
||||
end
|
||||
|
||||
it "returns a String" do
|
||||
|
|
|
@ -14,7 +14,7 @@ with_feature :encoding do
|
|||
it "returns self after emptying it" do
|
||||
cleared = @s.clear
|
||||
cleared.should == ""
|
||||
cleared.object_id.should == @s.object_id
|
||||
cleared.should equal @s
|
||||
end
|
||||
|
||||
it "preserves its encoding" do
|
||||
|
|
|
@ -3,12 +3,11 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
describe "String#freeze" do
|
||||
|
||||
it "produces the same object whenever called on an instance of a literal in the source" do
|
||||
ids = Array.new(2) { "abc".freeze.object_id }
|
||||
ids.first.should == ids.last
|
||||
"abc".freeze.should equal "abc".freeze
|
||||
end
|
||||
|
||||
it "doesn't produce the same object for different instances of literals in the source" do
|
||||
"abc".object_id.should_not == "abc".object_id
|
||||
"abc".should_not equal "abc"
|
||||
end
|
||||
|
||||
it "being a special form doesn't change the value of defined?" do
|
||||
|
|
|
@ -48,7 +48,7 @@ describe "Time.at" do
|
|||
it "creates a dup time object with the value given by time" do
|
||||
t1 = Time.new
|
||||
t2 = Time.at(t1)
|
||||
t1.object_id.should_not == t2.object_id
|
||||
t1.should_not equal t2
|
||||
end
|
||||
|
||||
it "returns a UTC time if the argument is UTC" do
|
||||
|
|
|
@ -14,6 +14,6 @@ describe "Time#succ" do
|
|||
-> {
|
||||
t2 = t1.succ
|
||||
}.should complain(/Time#succ is obsolete/)
|
||||
t1.object_id.should_not == t2.object_id
|
||||
t1.should_not equal t2
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,11 +44,11 @@ describe "Predefined global $~" do
|
|||
it "is set to contain the MatchData object of the last match if successful" do
|
||||
md = /foo/.match 'foo'
|
||||
$~.should be_kind_of(MatchData)
|
||||
$~.object_id.should == md.object_id
|
||||
$~.should equal md
|
||||
|
||||
/bar/ =~ 'bar'
|
||||
$~.should be_kind_of(MatchData)
|
||||
$~.object_id.should_not == md.object_id
|
||||
$~.should_not equal md
|
||||
end
|
||||
|
||||
it "is set to nil if the last match was unsuccessful" do
|
||||
|
@ -828,7 +828,7 @@ end
|
|||
|
||||
describe "Global variable $\"" do
|
||||
it "is an alias for $LOADED_FEATURES" do
|
||||
$".object_id.should == $LOADED_FEATURES.object_id
|
||||
$".should equal $LOADED_FEATURES
|
||||
end
|
||||
|
||||
it "is read-only" do
|
||||
|
|
|
@ -42,6 +42,15 @@ describe "Ruby character strings" do
|
|||
"#@ip#@ip".should == 'xxxxxx'
|
||||
end
|
||||
|
||||
it "don't get confused by partial interpolation character sequences" do
|
||||
"#@".should == '#@'
|
||||
"#@ ".should == '#@ '
|
||||
"#@@".should == '#@@'
|
||||
"#@@ ".should == '#@@ '
|
||||
"#$ ".should == '#$ '
|
||||
"#\$".should == '#$'
|
||||
end
|
||||
|
||||
it "taints the result of interpolation when an interpolated value is tainted" do
|
||||
"#{"".taint}".tainted?.should be_true
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ describe "CSV.generate" do
|
|||
csv.add_row [1, 2, 3]
|
||||
csv << [4, 5, 6]
|
||||
end
|
||||
csv_str.object_id.should == str.object_id
|
||||
csv_str.should equal str
|
||||
str.should == "1,2,3\n4,5,6\n"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
require 'erb'
|
||||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../../fixtures/classes', __FILE__)
|
||||
|
||||
describe "ERB::DefMethod.def_erb_method" do
|
||||
|
||||
|
@ -50,11 +51,7 @@ END
|
|||
MY_INPUT4_FOR_ERB = input
|
||||
class MyClass4ForErb
|
||||
extend ERB::DefMethod
|
||||
if RUBY_VERSION >= '2.6'
|
||||
erb = ERB.new(MY_INPUT4_FOR_ERB, trim_mode: '<>')
|
||||
else
|
||||
erb = ERB.new(MY_INPUT4_FOR_ERB, nil, '<>')
|
||||
end
|
||||
erb = ERBSpecs.new_erb(MY_INPUT4_FOR_ERB, trim_mode: '<>')
|
||||
def_erb_method('render()', erb)
|
||||
def initialize(items)
|
||||
@items = items
|
||||
|
|
9
spec/ruby/library/erb/fixtures/classes.rb
Normal file
9
spec/ruby/library/erb/fixtures/classes.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module ERBSpecs
|
||||
def self.new_erb(input, trim_mode: nil)
|
||||
if ruby_version_is "2.6"
|
||||
ERB.new(input, trim_mode: trim_mode)
|
||||
else
|
||||
ERB.new(input, nil, trim_mode)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
require 'erb'
|
||||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
|
||||
describe "ERB.new" do
|
||||
before :all do
|
||||
|
@ -31,33 +32,21 @@ END
|
|||
it "compiles eRuby script into ruby code when trim mode is 0 or not specified" do
|
||||
expected = "<ul>\n\n\n\n<li>1</li>\n\n\n\n<li>2</li>\n\n\n\n<li>3</li>\n\n\n</ul>\n"
|
||||
[0, '', nil].each do |trim_mode|
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(@eruby_str, trim_mode: trim_mode).result.should == expected
|
||||
else
|
||||
ERB.new(@eruby_str, nil, trim_mode).result.should == expected
|
||||
end
|
||||
ERBSpecs.new_erb(@eruby_str, trim_mode: trim_mode).result.should == expected
|
||||
end
|
||||
end
|
||||
|
||||
it "removes '\n' when trim_mode is 1 or '>'" do
|
||||
expected = "<ul>\n<li>1</li>\n<li>2</li>\n<li>3</li>\n</ul>\n"
|
||||
[1, '>'].each do |trim_mode|
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(@eruby_str, trim_mode: trim_mode).result.should == expected
|
||||
else
|
||||
ERB.new(@eruby_str, nil, trim_mode).result.should == expected
|
||||
end
|
||||
ERBSpecs.new_erb(@eruby_str, trim_mode: trim_mode).result.should == expected
|
||||
end
|
||||
end
|
||||
|
||||
it "removes spaces at beginning of line and '\n' when trim_mode is 2 or '<>'" do
|
||||
expected = "<ul>\n<li>1</li>\n<li>2</li>\n<li>3</li>\n</ul>\n"
|
||||
[2, '<>'].each do |trim_mode|
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(@eruby_str, trim_mode: trim_mode).result.should == expected
|
||||
else
|
||||
ERB.new(@eruby_str, nil, trim_mode).result.should == expected
|
||||
end
|
||||
ERBSpecs.new_erb(@eruby_str, trim_mode: trim_mode).result.should == expected
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -73,11 +62,7 @@ END
|
|||
</ul>
|
||||
END
|
||||
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(input, trim_mode: '-').result.should == expected
|
||||
else
|
||||
ERB.new(input, nil, '-').result.should == expected
|
||||
end
|
||||
ERBSpecs.new_erb(input, trim_mode: '-').result.should == expected
|
||||
end
|
||||
|
||||
|
||||
|
@ -91,39 +76,23 @@ END
|
|||
END
|
||||
|
||||
lambda {
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(input, trim_mode: '-').result
|
||||
else
|
||||
ERB.new(input, nil, '-').result
|
||||
end
|
||||
ERBSpecs.new_erb(input, trim_mode: '-').result
|
||||
}.should raise_error(SyntaxError)
|
||||
end
|
||||
|
||||
it "regards lines starting with '%' as '<% ... %>' when trim_mode is '%'" do
|
||||
expected = "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n"
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(@eruby_str2, trim_mode: "%").result.should == expected
|
||||
else
|
||||
ERB.new(@eruby_str2, nil, "%").result.should == expected
|
||||
end
|
||||
ERBSpecs.new_erb(@eruby_str2, trim_mode: "%").result.should == expected
|
||||
end
|
||||
it "regards lines starting with '%' as '<% ... %>' and remove \"\\n\" when trim_mode is '%>'" do
|
||||
expected = "<ul>\n <li>1 <li>2 <li>3 </ul>\n%%\n"
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(@eruby_str2, trim_mode: '%>').result.should == expected
|
||||
else
|
||||
ERB.new(@eruby_str2, nil, '%>').result.should == expected
|
||||
end
|
||||
ERBSpecs.new_erb(@eruby_str2, trim_mode: '%>').result.should == expected
|
||||
end
|
||||
|
||||
|
||||
it "regard lines starting with '%' as '<% ... %>' and remove \"\\n\" when trim_mode is '%<>'" do
|
||||
expected = "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n</ul>\n%%\n"
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(@eruby_str2, trim_mode: '%<>').result.should == expected
|
||||
else
|
||||
ERB.new(@eruby_str2, nil, '%<>').result.should == expected
|
||||
end
|
||||
ERBSpecs.new_erb(@eruby_str2, trim_mode: '%<>').result.should == expected
|
||||
end
|
||||
|
||||
|
||||
|
@ -138,11 +107,7 @@ END
|
|||
%%%
|
||||
END
|
||||
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(input, trim_mode: '%-').result.should == expected
|
||||
else
|
||||
ERB.new(input, nil, '%-').result.should == expected
|
||||
end
|
||||
ERBSpecs.new_erb(input, trim_mode: '%-').result.should == expected
|
||||
end
|
||||
|
||||
it "changes '_erbout' variable name in the produced source" do
|
||||
|
@ -164,12 +129,8 @@ END
|
|||
<b><%#= item %></b>
|
||||
<%# end %>
|
||||
END
|
||||
ERB.new(input).result.should == "\n<b></b>\n\n"
|
||||
if RUBY_VERSION >= '2.6'
|
||||
ERB.new(input, trim_mode: '<>').result.should == "<b></b>\n"
|
||||
else
|
||||
ERB.new(input, nil, '<>').result.should == "<b></b>\n"
|
||||
end
|
||||
ERBSpecs.new_erb(input).result.should == "\n<b></b>\n\n"
|
||||
ERBSpecs.new_erb(input, trim_mode: '<>').result.should == "<b></b>\n"
|
||||
end
|
||||
|
||||
it "forget local variables defined previous one" do
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/select', __FILE__)
|
||||
|
||||
describe "Set#filter!" do
|
||||
it_behaves_like :set_select_bang, :filter!
|
||||
ruby_version_is "2.6" do
|
||||
describe "Set#filter!" do
|
||||
it_behaves_like :set_select_bang, :filter!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@ require File.expand_path('../../../../spec_helper', __FILE__)
|
|||
require File.expand_path('../shared/select', __FILE__)
|
||||
require 'set'
|
||||
|
||||
describe "SortedSet#filter!" do
|
||||
it_behaves_like :sorted_set_select_bang, :filter!
|
||||
ruby_version_is "2.6" do
|
||||
describe "SortedSet#filter!" do
|
||||
it_behaves_like :sorted_set_select_bang, :filter!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,9 +9,9 @@ describe "CApiGCSpecs" do
|
|||
|
||||
it "correctly gets the value from a registered address" do
|
||||
@f.registered_tagged_address.should == 10
|
||||
@f.registered_tagged_address.object_id.should == @f.registered_tagged_address.object_id
|
||||
@f.registered_tagged_address.should equal(@f.registered_tagged_address)
|
||||
@f.registered_reference_address.should == "Globally registered data"
|
||||
@f.registered_reference_address.object_id.should == @f.registered_reference_address.object_id
|
||||
@f.registered_reference_address.should equal(@f.registered_reference_address)
|
||||
end
|
||||
|
||||
describe "rb_gc_enable" do
|
||||
|
|
|
@ -188,7 +188,7 @@ describe "C-API String function" do
|
|||
str1 = "hi"
|
||||
str2 = @s.rb_str_new3 str1
|
||||
str1.should == str2
|
||||
str1.object_id.should_not == str2.object_id
|
||||
str1.should_not equal str2
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -217,7 +217,7 @@ describe "C-API String function" do
|
|||
str1 = "hi"
|
||||
str2 = @s.rb_str_dup str1
|
||||
str1.should == str2
|
||||
str1.object_id.should_not == str2.object_id
|
||||
str1.should_not equal str2
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue