1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2019-02-07 16:35:33 +00:00
parent 5c7c6763f6
commit 75334db3c6
111 changed files with 1031 additions and 231 deletions

View file

@ -58,7 +58,7 @@ describe "Array#combination" do
@array.combination(-1).size.should == 0
[].combination(-2).size.should == 0
end
it "returns the binomial coeficient between the array size the number of combinations" do
it "returns the binomial coefficient between the array size the number of combinations" do
@array.combination(5).size.should == 0
@array.combination(4).size.should == 1
@array.combination(3).size.should == 4

View file

@ -81,7 +81,7 @@ module ArraySpecs
end
end
class ArrayConvertable
class ArrayConvertible
attr_accessor :called
def initialize(*values, &block)
@values = values;
@ -426,7 +426,7 @@ module ArraySpecs
"assert_no_queries",
"test_change_column_quotes_column_names",
"assert_match",
"test_keeping_default_and_notnull_constaint_on_change",
"test_keeping_default_and_notnull_constraint_on_change",
"methods",
"connection_allow_concurrency_setup",
"connection_allow_concurrency_teardown",
@ -476,7 +476,7 @@ module ArraySpecs
"test_create_table_without_id",
"test_finds_migrations",
"test_finds_pending_migrations",
"test_keeping_default_and_notnull_constaint_on_change",
"test_keeping_default_and_notnull_constraint_on_change",
"test_migrator",
"test_migrator_db_has_no_schema_migrations_table",
"test_migrator_double_down",

View file

@ -53,7 +53,7 @@ describe "Array#last" do
array.last.should equal(array)
end
it "tries to convert the passed argument to an Integer usinig #to_int" do
it "tries to convert the passed argument to an Integer using #to_int" do
obj = mock('to_int')
obj.should_receive(:to_int).and_return(2)
[1, 2, 3, 4, 5].last(obj).should == [4, 5]

View file

@ -41,16 +41,9 @@ describe :array_pack_float_le, shared: true do
[-infinity_value].pack(pack_format).should == "\x00\x00\x80\xff"
end
platform_is "86" do # x86 / x86_64
it "encodes NaN" do
[nan_value].pack(pack_format).should == "\x00\x00\xc0\xff"
end
end
platform_is "powerpc64" do
it "encodes NaN" do
[nan_value].pack(pack_format).should == "\x00\x00\xc0\x7f"
end
it "encodes NaN" do
nans = ["\x00\x00\xc0\xff", "\x00\x00\xc0\x7f"]
nans.should include([nan_value].pack(pack_format))
end
it "encodes a positive Float outside the range of a single precision float" do
@ -103,16 +96,9 @@ describe :array_pack_float_be, shared: true do
[-infinity_value].pack(pack_format).should == "\xff\x80\x00\x00"
end
platform_is "86" do # x86 / x86_64
it "encodes NaN" do
[nan_value].pack(pack_format).should == "\xff\xc0\x00\x00"
end
end
platform_is "powerpc64" do
it "encodes NaN" do
[nan_value].pack(pack_format).should == "\x7f\xc0\x00\x00"
end
it "encodes NaN" do
nans = ["\xff\xc0\x00\x00", "\x7f\xc0\x00\x00"]
nans.should include([nan_value].pack(pack_format))
end
it "encodes a positive Float outside the range of a single precision float" do
@ -165,16 +151,9 @@ describe :array_pack_double_le, shared: true do
[-infinity_value].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\xf0\xff"
end
platform_is "86" do # x86 / x86_64
it "encodes NaN" do
[nan_value].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\xf8\xff"
end
end
platform_is "powerpc64" do
it "encodes NaN" do
[nan_value].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\xf8\x7f"
end
it "encodes NaN" do
nans = ["\x00\x00\x00\x00\x00\x00\xf8\xff", "\x00\x00\x00\x00\x00\x00\xf8\x7f"]
nans.should include([nan_value].pack(pack_format))
end
it "encodes a positive Float outside the range of a single precision float" do
@ -227,16 +206,9 @@ describe :array_pack_double_be, shared: true do
[-infinity_value].pack(pack_format).should == "\xff\xf0\x00\x00\x00\x00\x00\x00"
end
platform_is "86" do # x86 / x86_64
it "encodes NaN" do
[nan_value].pack(pack_format).should == "\xff\xf8\x00\x00\x00\x00\x00\x00"
end
end
platform_is "powerpc64" do
it "encodes NaN" do
[nan_value].pack(pack_format).should == "\x7f\xf8\x00\x00\x00\x00\x00\x00"
end
it "encodes NaN" do
nans = ["\xff\xf8\x00\x00\x00\x00\x00\x00", "\x7f\xf8\x00\x00\x00\x00\x00\x00"]
nans.should include([nan_value].pack(pack_format))
end
it "encodes a positive Float outside the range of a single precision float" do

View file

@ -4,7 +4,7 @@ require_relative 'fixtures/classes'
describe "Array#product" do
it "returns converted arguments using :to_ary" do
lambda{ [1].product(2..3) }.should raise_error(TypeError)
ar = ArraySpecs::ArrayConvertable.new(2,3)
ar = ArraySpecs::ArrayConvertible.new(2,3)
[1].product(ar).should == [[1,2],[1,3]]
ar.called.should == :to_ary
end

View file

@ -28,7 +28,7 @@ describe "Array#rassoc" do
[[1, :foobar], [2, o], [3, mock('foo')]].rassoc(key).should == [2, o]
end
it "does not check the last element in each contained but speficically the second" do
it "does not check the last element in each contained but specifically the second" do
key = 'foobar'
o = mock('foobar')
def o.==(other); other == 'foobar'; end

View file

@ -68,7 +68,7 @@ describe "Array#repeated_combination" do
[].repeated_combination(0).size.should == 1
end
it "returns the binomial coeficient between combination_size and array size + combination_size -1" do
it "returns the binomial coefficient between combination_size and array size + combination_size -1" do
@array.repeated_combination(5).size.should == 21
@array.repeated_combination(4).size.should == 15
@array.repeated_combination(3).size.should == 10

View file

@ -18,7 +18,7 @@ ruby_version_is '2.4' do
[].sum.should == 0
end
it "adds init value to the sum of elemens" do
it "adds init value to the sum of elements" do
[1, 2, 3].sum(10).should == 16
end

View file

@ -42,7 +42,7 @@ describe "Array#zip" do
[1, 2].zip(10.upto(Float::INFINITY)).should == [[1, 10], [2, 11]]
end
it "fills nil when the given enumereator is shorter than self" do
it "fills nil when the given enumerator is shorter than self" do
obj = Object.new
def obj.each
yield 10

View file

@ -65,7 +65,7 @@ ruby_version_is "2.5" do
children.first.encoding.should equal(Encoding::EUC_KR)
end
it "raises a SystemCallError if called with a nonexistent diretory" do
it "raises a SystemCallError if called with a nonexistent directory" do
lambda { Dir.children DirSpecs.nonexistent }.should raise_error(SystemCallError)
end
end

View file

@ -64,7 +64,7 @@ describe "Dir.entries" do
entries.first.encoding.should equal(Encoding::EUC_KR)
end
it "raises a SystemCallError if called with a nonexistent diretory" do
it "raises a SystemCallError if called with a nonexistent directory" do
lambda { Dir.entries DirSpecs.nonexistent }.should raise_error(SystemCallError)
end
end

View file

@ -273,11 +273,11 @@ describe :dir_glob, shared: true do
subdir_two/nondotfile.ext]
end
it "ignores matching through directories that doen't exist" do
it "ignores matching through directories that doesn't exist" do
Dir.send(@method, "deeply/notthere/blah*/whatever").should == []
end
it "ignores matching only directories under an nonexistant path" do
it "ignores matching only directories under an nonexistent path" do
Dir.send(@method, "deeply/notthere/blah/").should == []
end
@ -312,7 +312,7 @@ describe :dir_glob, shared: true do
Dir.send(@method, "*", base: path).sort.should == %w( d y )
end
it "accepts both relative and absolute pathes" do
it "accepts both relative and absolute paths" do
require 'pathname'
path_abs = File.join(@mock_dir, "a/b/c")
@ -339,7 +339,7 @@ describe :dir_glob, shared: true do
Dir.send(@method, "*", base: path).should == []
end
it "raises TypeError whene cannot convert value to string" do
it "raises TypeError when cannot convert value to string" do
-> {
Dir.send(@method, "*", base: [])
}.should raise_error(TypeError)

View file

@ -32,7 +32,7 @@ with_feature :encoding do
Encoding.aliases['external'].should == Encoding.default_external.name
end
it "has a 'locale' key and its value equals to the name of the encoding finded by the locale charmap" do
it "has a 'locale' key and its value equals the name of the encoding found by the locale charmap" do
Encoding.aliases['locale'].should == Encoding.find(Encoding.locale_charmap).name
end

View file

@ -118,7 +118,7 @@ module EnumerableSpecs
end
end
class ArrayConvertable
class ArrayConvertible
attr_accessor :called
def initialize(*values)
@values = values
@ -135,7 +135,7 @@ module EnumerableSpecs
end
end
class EnumConvertable
class EnumConvertible
attr_accessor :called
attr_accessor :sym
def initialize(delegate)

View file

@ -21,16 +21,16 @@ describe "Enumerable#zip" do
end
it "converts arguments to arrays using #to_ary" do
convertable = EnumerableSpecs::ArrayConvertable.new(4,5,6)
EnumerableSpecs::Numerous.new(1,2,3).zip(convertable).should == [[1,4],[2,5],[3,6]]
convertable.called.should == :to_ary
convertible = EnumerableSpecs::ArrayConvertible.new(4,5,6)
EnumerableSpecs::Numerous.new(1,2,3).zip(convertible).should == [[1,4],[2,5],[3,6]]
convertible.called.should == :to_ary
end
it "converts arguments to enums using #to_enum" do
convertable = EnumerableSpecs::EnumConvertable.new(4..6)
EnumerableSpecs::Numerous.new(1,2,3).zip(convertable).should == [[1,4],[2,5],[3,6]]
convertable.called.should == :to_enum
convertable.sym.should == :each
convertible = EnumerableSpecs::EnumConvertible.new(4..6)
EnumerableSpecs::Numerous.new(1,2,3).zip(convertible).should == [[1,4],[2,5],[3,6]]
convertible.called.should == :to_enum
convertible.sym.should == :each
end
it "gathers whole arrays as elements when each yields multiple" do

View file

@ -3,7 +3,7 @@ require_relative '../../enumerable/fixtures/classes'
ruby_version_is "2.6" do
describe "Enumerator::Chain#each" do
it "calls each on its consistuents as needed" do
it "calls each on its constituents as needed" do
a = EnumerableSpecs::EachCounter.new(:a, :b)
b = EnumerableSpecs::EachCounter.new(:c, :d)

View file

@ -27,7 +27,7 @@ describe "SignalException.new" do
end
it "raises an exception with an invalid signal name" do
lambda { SignalException.new("NONEXISTANT") }.should raise_error(ArgumentError)
lambda { SignalException.new("NONEXISTENT") }.should raise_error(ArgumentError)
end
it "takes a signal symbol without SIG prefix as the first argument" do
@ -45,7 +45,7 @@ describe "SignalException.new" do
end
it "raises an exception with an invalid signal name" do
lambda { SignalException.new(:NONEXISTANT) }.should raise_error(ArgumentError)
lambda { SignalException.new(:NONEXISTENT) }.should raise_error(ArgumentError)
end
it "takes an optional message argument with a signal number" do

View file

@ -71,7 +71,7 @@ describe "File.expand_path" do
File.expand_path("../bin", "x/../tmp").should == File.join(@base, 'bin')
end
it "expand_path for commoms unix path give a full path" do
it "expand_path for common unix path gives a full path" do
File.expand_path('/tmp/').should =='/tmp'
File.expand_path('/tmp/../../../tmp').should == '/tmp'
File.expand_path('').should == Dir.pwd

View file

@ -38,7 +38,7 @@ describe "File.new" do
end
it "creates the file and returns writable descriptor when called with 'w' mode and r-o permissions" do
# it should be possible to write to such a file via returned descriptior,
# it should be possible to write to such a file via returned descriptor,
# even though the file permissions are r-r-r.
rm_r @file

View file

@ -128,7 +128,7 @@ describe "File.open" do
end
it "creates the file and returns writable descriptor when called with 'w' mode and r-o permissions" do
# it should be possible to write to such a file via returned descriptior,
# it should be possible to write to such a file via returned descriptor,
# even though the file permissions are r-r-r.
File.open(@file, "w", 0444) { |f| f.write("test") }
@ -236,7 +236,7 @@ describe "File.open" do
File.exist?(@file).should == true
end
# Check the grants associated to the differents open modes combinations.
# Check the grants associated to the different open modes combinations.
it "raises an ArgumentError exception when call with an unknown mode" do
lambda { File.open(@file, "q") }.should raise_error(ArgumentError)
end

View file

@ -87,7 +87,7 @@ describe :file_fnmatch, shared: true do
File.send(@method, '[a-z]', 'D', File::FNM_CASEFOLD).should == true
end
it "does not match characters outside of the range of the bracket expresion" do
it "does not match characters outside of the range of the bracket expression" do
File.send(@method, 'ca[x-z]', 'cat').should == false
File.send(@method, '/ca[s][s-t]/rul[a-b]/[z]he/[x-Z]orld', '/cats/rule/the/World').should == false
end

View file

@ -9,9 +9,11 @@ describe "File::Stat#dev_major" do
rm_r @name
end
platform_is_not :windows do
it "returns the major part of File::Stat#dev" do
File.stat(@name).dev_major.should be_kind_of(Integer)
ruby_version_is "2.4" do
platform_is_not :windows do
it "returns the major part of File::Stat#dev" do
File.stat(@name).dev_major.should be_kind_of(Integer)
end
end
end

View file

@ -9,9 +9,11 @@ describe "File::Stat#dev_minor" do
rm_r @name
end
platform_is_not :windows do
it "returns the minor part of File::Stat#dev" do
File.stat(@name).dev_minor.should be_kind_of(Integer)
ruby_version_is "2.4" do
platform_is_not :windows do
it "returns the minor part of File::Stat#dev" do
File.stat(@name).dev_minor.should be_kind_of(Integer)
end
end
end

View file

@ -17,9 +17,11 @@ describe "File::Stat#rdev_major" do
end
end
platform_is_not :windows do
it "returns the major part of File::Stat#rdev" do
File.stat(@name).rdev_major.should be_kind_of(Integer)
ruby_version_is "2.4" do
platform_is_not :windows do
it "returns the major part of File::Stat#rdev" do
File.stat(@name).rdev_major.should be_kind_of(Integer)
end
end
end

View file

@ -17,9 +17,11 @@ describe "File::Stat#rdev_minor" do
end
end
platform_is_not :windows do
it "returns the minor part of File::Stat#rdev" do
File.stat(@name).rdev_minor.should be_kind_of(Integer)
ruby_version_is "2.4" do
platform_is_not :windows do
it "returns the minor part of File::Stat#rdev" do
File.stat(@name).rdev_minor.should be_kind_of(Integer)
end
end
end

View file

@ -35,7 +35,7 @@ describe "File.sticky?" do
end
platform_is :bsd do
# FreeBSD and NetBSD can't set stiky bit to a normal file
# FreeBSD and NetBSD can't set sticky bit to a normal file
it "cannot set sticky bit to a normal file" do
filename = tmp("i_exist")
touch(filename)

View file

@ -22,7 +22,7 @@ describe "Float#<=>" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end
it "returns -1 when self is negative and other is Infinty" do
it "returns -1 when self is negative and other is Infinity" do
(-Float::MAX.to_i*2 <=> infinity_value).should == -1
end

View file

@ -30,7 +30,7 @@ describe "Float#round" do
12.345678.round(3.999).should == 12.346
end
it "returns zero when passed a negative argument with magitude greater the magitude of the whole number portion of the Float" do
it "returns zero when passed a negative argument with magnitude greater than magnitude of the whole number portion of the Float" do
0.8346268.round(-1).should eql(0)
end

View file

@ -63,7 +63,7 @@ describe "Hash#shift" do
end
it "works when the hash is at capacity" do
# We try a wide range of sizes in hopes that this will cover all implementationss base Hash size.
# We try a wide range of sizes in hopes that this will cover all implementations' base Hash size.
results = []
1.upto(100) do |n|
h = {}

View file

@ -497,7 +497,7 @@ with_feature :encoding do
buf.encoding.should equal(Encoding::ISO_8859_1)
end
it "trucates the buffer but does not change the buffer's encoding when no data remains" do
it "truncates the buffer but does not change the buffer's encoding when no data remains" do
buf = "abc".force_encoding Encoding::ISO_8859_1
@io.read

View file

@ -6,13 +6,13 @@ require_relative 'shared/readlines'
describe "IO#readlines" do
before :each do
@io = IOSpecs.io_fixture "lines.txt"
@orig_exteenc = Encoding.default_external
@orig_extenc = Encoding.default_external
Encoding.default_external = Encoding::UTF_8
end
after :each do
@io.close unless @io.closed?
Encoding.default_external = @orig_exteenc
Encoding.default_external = @orig_extenc
end
it "raises an IOError if the stream is closed" do

View file

@ -156,7 +156,7 @@ with_feature :encoding do
@io.internal_encoding.should be_nil
end
it "ignores the internal encoding if the same as external when passed encoding names separanted by ':'" do
it "ignores the internal encoding if the same as external when passed encoding names separated by ':'" do
@io.set_encoding("utf-8:utf-8")
@io.external_encoding.should == Encoding::UTF_8
@io.internal_encoding.should be_nil

View file

@ -72,7 +72,7 @@ describe "Kernel#autoload" do
KernelSpecs::AutoloadMethod.autoload?(:AutoloadFromIncludedModule).should == @path
end
it "the autoload is reacheable from the class too" do
it "the autoload is reachable from the class too" do
KernelSpecs::AutoloadMethodIncluder.autoload?(:AutoloadFromIncludedModule).should == @path
end
@ -138,7 +138,7 @@ describe "Kernel.autoload" do
KernelSpecs::AutoloadMethod2.autoload?(:AutoloadFromIncludedModule2).should == @path
end
it "the autoload is reacheable from the class too" do
it "the autoload is reachable from the class too" do
KernelSpecs::AutoloadMethodIncluder2.autoload?(:AutoloadFromIncludedModule2).should == @path
end

View file

@ -24,7 +24,7 @@ describe "Kernel#eval" do
EvalSpecs::A::B.name.should == "EvalSpecs::A::B"
end
it "evaluates such that consts are scoped to the class of the eval" do
it "evaluates such that constants are scoped to the class of the eval" do
EvalSpecs::A::C.name.should == "EvalSpecs::A::C"
end

View file

@ -10,7 +10,7 @@ describe "Kernel.throw" do
end.should be_nil
end
it "transfers control to the innermost catch block waiting for the same sympol" do
it "transfers control to the innermost catch block waiting for the same symbol" do
one = two = three = 0
catch :duplicate do
catch :duplicate do

View file

@ -13,7 +13,7 @@ describe "Math.tan" do
Math.tan(-9.65).should be_close(-0.229109052606441, TOLERANCE)
end
it "returns NaN if called with +-Infinitty" do
it "returns NaN if called with +-Infinity" do
Math.tan(infinity_value).nan?.should == true
Math.tan(-infinity_value).nan?.should == true
end

View file

@ -54,7 +54,7 @@ describe "Module#attr" do
o.attr3 = "test3 updated"
end
it "creates a getter and setter for the given attribute name if called with and without writeable is true" do
it "creates a getter and setter for the given attribute name if called with and without writable is true" do
c = Class.new do
attr :attr, true
attr :attr

View file

@ -636,7 +636,7 @@ describe "Module#autoload" do
end.should raise_error(TypeError)
end
it "raises a TypeError if not passed a String or object respodning to #to_path for the filename" do
it "raises a TypeError if not passed a String or object responding to #to_path for the filename" do
name = mock("autoload_name.rb")
lambda { ModuleSpecs::Autoload.autoload :Str, name }.should raise_error(TypeError)

View file

@ -16,7 +16,7 @@ describe "Module#<=>" do
(ModuleSpecs::Super <=> ModuleSpecs::Super).should == 0
end
it "returns +1 if self is a superclas of or included by the given module" do
it "returns +1 if self is a superclass of or included by the given module" do
(ModuleSpecs::Parent <=> ModuleSpecs::Child).should == +1
(ModuleSpecs::Basic <=> ModuleSpecs::Child).should == +1
(ModuleSpecs::Super <=> ModuleSpecs::Child).should == +1

View file

@ -66,7 +66,7 @@ describe "Module#const_get" do
end.should raise_error(NameError)
end
it "raises a NameError if the constant is defined in the receiver's supperclass and the inherit flag is false" do
it "raises a NameError if the constant is defined in the receiver's superclass and the inherit flag is false" do
lambda do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST4, false)
end.should raise_error(NameError)

View file

@ -84,20 +84,18 @@ describe "Module#refine" do
end
end
quarantine! do # https://bugs.ruby-lang.org/issues/14070
ruby_version_is "2.4" do
it "accepts a module as argument" do
inner_self = nil
Module.new do
refine(Enumerable) do
def blah
end
inner_self = self
ruby_version_is "2.4" do
it "accepts a module as argument" do
inner_self = nil
Module.new do
refine(Enumerable) do
def blah
end
inner_self = self
end
inner_self.public_instance_methods.should include(:blah)
end
inner_self.public_instance_methods.should include(:blah)
end
end

View file

@ -114,7 +114,7 @@ describe "Numeric#step" do
1.step(to: Float::INFINITY, by: 42).size.should == infinity_value
end
it "should return infinity_value when decending towards a limit of -Float::INFINITY" do
it "should return infinity_value when descending towards a limit of -Float::INFINITY" do
1.step(to: -Float::INFINITY, by: -42).size.should == infinity_value
end

View file

@ -2,7 +2,7 @@ require_relative '../../spec_helper'
platform_is :aix do
# In AIX, if getrlimit(2) is called multiple times with RLIMIT_DATA,
# the first call and the subequent calls return slightly different
# the first call and the subsequent calls return slightly different
# values of rlim_cur, even if the process does nothing between
# the calls. This behavior causes some of the tests in this spec
# to fail, so call Process.getrlimit(:DATA) once and discard the result.

View file

@ -451,7 +451,7 @@ describe "Process.spawn" do
# redirection
it "redirects STDOUT to the given file descriptior if out: Fixnum" do
it "redirects STDOUT to the given file descriptor if out: Fixnum" do
File.open(@name, 'w') do |file|
lambda do
Process.wait Process.spawn("echo glark", out: file.fileno)
@ -477,7 +477,7 @@ describe "Process.spawn" do
File.read(@name).should == "glark\n"
end
it "redirects STDERR to the given file descriptior if err: Fixnum" do
it "redirects STDERR to the given file descriptor if err: Fixnum" do
File.open(@name, 'w') do |file|
lambda do
Process.wait Process.spawn("echo glark>&2", err: file.fileno)
@ -506,7 +506,7 @@ describe "Process.spawn" do
end
end
it "redirects both STDERR and STDOUT to the given file descriptior" do
it "redirects both STDERR and STDOUT to the given file descriptor" do
File.open(@name, 'w') do |file|
lambda do
Process.wait Process.spawn(ruby_cmd("print(:glark); STDOUT.flush; STDERR.print(:bang)"),

View file

@ -21,7 +21,7 @@ describe "Process.wait" do
end
platform_is_not :windows do
it "returns its childs pid" do
it "returns its child pid" do
pid = Process.spawn(ruby_cmd('exit'))
Process.wait.should == pid
end

View file

@ -100,7 +100,7 @@ describe "Regexp#match" do
$~.should be_nil
end
it "raises TypeError when the given argument cannot be coarce to String" do
it "raises TypeError when the given argument cannot be coerced to String" do
f = 1
lambda { /foo/.match(f)[0] }.should raise_error(TypeError)
end

View file

@ -14,7 +14,7 @@ describe "Signal.signame" do
end
platform_is_not :windows do
it "the original should take precendence over alias when looked up by number" do
it "the original should take precedence over alias when looked up by number" do
Signal.signame(Signal.list["ABRT"]).should == "ABRT"
Signal.signame(Signal.list["CHLD"]).should == "CHLD"
end

View file

@ -78,7 +78,7 @@ platform_is_not :windows do
Signal.trap("SIGHUP", @saved_trap).should equal(@proc)
end
it "acceps short names as Strings" do
it "accepts short names as Strings" do
Signal.trap "HUP", @proc
Signal.trap("HUP", @saved_trap).should equal(@proc)
end

View file

@ -30,7 +30,7 @@ describe "String#chomp" do
"abc\r\r".chomp.should == "abc\r"
end
it "removes one trailing carrige return, newline pair" do
it "removes one trailing carriage return, newline pair" do
"abc\r\n\r\n".chomp.should == "abc\r\n"
end
@ -111,7 +111,7 @@ describe "String#chomp" do
"abc\r\r".chomp("\n").should == "abc\r"
end
it "removes one trailing carrige return, newline pair" do
it "removes one trailing carriage return, newline pair" do
"abc\r\n\r\n".chomp("\n").should == "abc\r\n"
end
@ -193,7 +193,7 @@ describe "String#chomp!" do
"abc\r\r".chomp!.should == "abc\r"
end
it "removes one trailing carrige return, newline pair" do
it "removes one trailing carriage return, newline pair" do
"abc\r\n\r\n".chomp!.should == "abc\r\n"
end
@ -265,7 +265,7 @@ describe "String#chomp!" do
"abc\r\r".chomp!("\n").should == "abc\r"
end
it "removes one trailing carrige return, newline pair" do
it "removes one trailing carriage return, newline pair" do
"abc\r\n\r\n".chomp!("\n").should == "abc\r\n"
end

View file

@ -19,7 +19,7 @@ describe "String#chop" do
"abc\r\n".chop.should == "abc"
end
it "removes the carrige return, newline if they are the only characters" do
it "removes the carriage return, newline if they are the only characters" do
"\r\n".chop.should == ""
end
@ -83,7 +83,7 @@ describe "String#chop!" do
"abc\r\n".chop!.should == "abc"
end
it "removes the carrige return, newline if they are the only characters" do
it "removes the carriage return, newline if they are the only characters" do
"\r\n".chop!.should == ""
end

View file

@ -36,7 +36,7 @@ describe "String#[]= with Fixnum index" do
lambda { ""[-1] = "bam" }.should raise_error(IndexError)
end
# Behaviour verfieid correct by matz in
# Behaviour is verified by matz in
# http://redmine.ruby-lang.org/issues/show/1750
it "allows assignment to the zero'th element of an empty String" do
str = ""

View file

@ -54,7 +54,7 @@ describe "String#setbyte" do
lambda { "?".setbyte(1, 97) }.should raise_error(IndexError)
end
it "raises an IndexError if the nexgative index is greater magnitude than the String bytesize" do
it "raises an IndexError if the negative index is greater magnitude than the String bytesize" do
lambda { "???".setbyte(-5, 97) }.should raise_error(IndexError)
end

View file

@ -48,7 +48,7 @@ describe :string_codepoints, shared: true do
s.should == s2
end
it "is synonymous with #bytes for Strings which are single-byte optimisable" do
it "is synonymous with #bytes for Strings which are single-byte optimizable" do
s = "(){}".encode('ascii')
s.ascii_only?.should be_true
s.send(@method).to_a.should == s.bytes.to_a

View file

@ -50,7 +50,7 @@ describe :string_concat, shared: true do
end
describe "with Integer" do
it "concatencates the argument interpreted as a codepoint" do
it "concatenates the argument interpreted as a codepoint" do
b = "".send(@method, 33)
b.should == "!"

View file

@ -17,7 +17,7 @@ describe :string_equal_value, shared: true do
# not call it.
obj.stub!(:to_str)
# Don't use @method for :== in `obj.should_recerive(:==)`
# Don't use @method for :== in `obj.should_receive(:==)`
obj.should_receive(:==).and_return(true)
'hello'.send(@method, obj).should be_true

View file

@ -29,7 +29,7 @@ describe "String#to_r" do
"a1765, ".to_r.should_not == Rational(1765, 1)
end
it "treats leading hypens as minus signs" do
it "treats leading hyphen as minus signs" do
"-20".to_r.should == Rational(-20, 1)
end

View file

@ -20,7 +20,7 @@ describe :string_unpack_8bit, shared: true do
"abc".unpack(unpack_format('*')).should == [97, 98, 99]
end
it "decodes the remaining bytes when passed the '*' modifer after another directive" do
it "decodes the remaining bytes when passed the '*' modifier after another directive" do
"abc".unpack(unpack_format()+unpack_format('*')).should == [97, 98, 99]
end

View file

@ -8,7 +8,7 @@ describe "String#upto" do
a.should == ["*+", "*,", "*-", "*.", "*/", "*0", "*1", "*2", "*3"]
end
it "calls the block once even when start eqals stop" do
it "calls the block once even when start equals stop" do
a = []
"abc".upto("abc") { |s| a << s }
a.should == ["abc"]

View file

@ -1,4 +1,5 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
describe "Time.at" do
describe "passed Numeric" do
@ -198,4 +199,56 @@ describe "Time.at" do
end
end
end
ruby_version_is "2.6" do
describe ":in keyword argument" do
before do
@epoch_time = Time.now.to_i
end
it "could be UTC offset as a String in '+HH:MM or '-HH:MM' format" do
time = Time.at(@epoch_time, in: "+05:00")
time.utc_offset.should == 5*60*60
time.zone.should == nil
time.to_i.should == @epoch_time
time = Time.at(@epoch_time, in: "-09:00")
time.utc_offset.should == -9*60*60
time.zone.should == nil
time.to_i.should == @epoch_time
end
it "could be UTC offset as a number of seconds" do
time = Time.at(@epoch_time, in: 5*60*60)
time.utc_offset.should == 5*60*60
time.zone.should == nil
time.to_i.should == @epoch_time
time = Time.at(@epoch_time, in: -9*60*60)
time.utc_offset.should == -9*60*60
time.zone.should == nil
time.to_i.should == @epoch_time
end
it "could be a timezone object" do
zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo", offset: (5*3600+30*60))
time = Time.at(@epoch_time, in: zone)
time.utc_offset.should == 5*3600+30*60
time.zone.should == zone
time.to_i.should == @epoch_time
zone = TimeSpecs::TimezoneWithName.new(name: "PST", offset: (-9*60*60))
time = Time.at(@epoch_time, in: zone)
time.utc_offset.should == -9*60*60
time.zone.should == zone
time.to_i.should == @epoch_time
end
end
end
end

View file

@ -9,18 +9,77 @@ module TimeSpecs
end
end
Timezone = Struct.new(:name, :abbr, :offset)
class Timezone
def utc_offset(t = nil)
offset
def initialize(options)
@offset = options[:offset]
end
def local_to_utc(t)
t - utc_offset(t)
t - @offset
end
def utc_to_local(t)
t + utc_offset(t)
t + @offset
end
end
class TimezoneMethodCallRecorder < Timezone
def initialize(options, &blk)
super(options)
@blk = blk
end
def local_to_utc(t)
@blk.call(t)
super
end
def utc_to_local(t)
@blk.call(t)
super
end
end
class TimeLikeArgumentRecorder
def self.result
arguments = []
zone = TimeSpecs::TimezoneMethodCallRecorder.new(offset: 0) do |obj|
arguments << obj
end
# ensure timezone's methods are called at least once
Time.new(2000, 1, 1, 12, 0, 0, zone)
return arguments[0]
end
end
class TimezoneWithAbbr < Timezone
def initialize(options)
super
@abbr = options[:abbr]
end
def abbr(time)
@abbr
end
end
class TimezoneWithName < Timezone
def initialize(options)
super
@name = options[:name]
end
def name
@name
end
end
class TimeWithFindTimezone < Time
def self.find_timezone(name)
TimezoneWithName.new(name: name.to_s, offset: -10*60*60)
end
end
end

View file

@ -1,4 +1,5 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
describe "Time#getlocal" do
it "returns a new time which is the local representation of time" do
@ -99,15 +100,69 @@ describe "Time#getlocal" do
ruby_version_is "2.6" do
describe "with a timezone argument" do
it "returns a Time in the timezone" do
zone = mock('timezone')
zone.should_receive(:utc_to_local).and_return(Time.utc(2000, 1, 1, 17, 30, 0))
t = Time.utc(2000, 1, 1, 12, 0, 0)
tv = t.to_i
t = t.getlocal(zone)
t.to_a[0, 6].should == [0, 30, 17, 1, 1, 2000]
t.utc_offset.should == 19800
t.to_i.should == tv
t.zone.should == zone
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone)
time.zone.should == zone
time.utc_offset.should == 5*3600+30*60
end
it "accepts timezone argument that must have #local_to_utc and #utc_to_local methods" do
zone = Object.new
def zone.utc_to_local(time)
time
end
def zone.local_to_utc(time)
time
end
lambda {
Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should be_kind_of(Time)
}.should_not raise_error
end
it "raises TypeError if timezone does not implement #utc_to_local method" do
zone = Object.new
def zone.local_to_utc(time)
time
end
lambda {
Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone)
}.should raise_error(TypeError, /can't convert \w+ into an exact number/)
end
it "does not raise exception if timezone does not implement #local_to_utc method" do
zone = Object.new
def zone.utc_to_local(time)
time
end
lambda {
Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should be_kind_of(Time)
}.should_not raise_error
end
context "subject's class implements .find_timezone method" do
it "calls .find_timezone to build a time object if passed zone name as a timezone argument" do
time = TimeSpecs::TimeWithFindTimezone.utc(2000, 1, 1, 12, 0, 0).getlocal("Asia/Colombo")
time.zone.should be_kind_of TimeSpecs::TimezoneWithName
time.zone.name.should == "Asia/Colombo"
time = TimeSpecs::TimeWithFindTimezone.utc(2000, 1, 1, 12, 0, 0).getlocal("some invalid zone name")
time.zone.should be_kind_of TimeSpecs::TimezoneWithName
time.zone.name.should == "some invalid zone name"
end
it "does not call .find_timezone if passed any not string/numeric/timezone timezone argument" do
[Object.new, [], {}, :"some zone"].each do |zone|
time = TimeSpecs::TimeWithFindTimezone.utc(2000, 1, 1, 12, 0, 0)
lambda {
time.getlocal(zone)
}.should raise_error(TypeError, /can't convert \w+ into an exact number/)
end
end
end
end
end

View file

@ -1,4 +1,5 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
describe "Time#-" do
it "decrements the time by the specified amount" do
@ -89,6 +90,25 @@ describe "Time#-" do
(Time.new(2012, 1, 1, 0, 0, 0, 3600) - 10).utc_offset.should == 3600
end
it "preserves time zone" do
time_with_zone = Time.now.utc
time_with_zone.zone.should == (time_with_zone - 60*60).zone
time_with_zone = Time.now
time_with_zone.zone.should == (time_with_zone - 60*60).zone
end
ruby_version_is "2.6" do
context "zone is a timezone object" do
it "preserves time zone" do
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 60*60
time.zone.should == zone
end
end
end
it "does not return a subclass instance" do
c = Class.new(Time)
x = c.now + 1

View file

@ -1,4 +1,5 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
require_relative 'shared/now'
require_relative 'shared/local'
require_relative 'shared/time_params'
@ -116,12 +117,211 @@ end
ruby_version_is "2.6" do
describe "Time.new with a timezone argument" do
it "returns a Time correspoinding to UTC time returned by local_to_utc" do
zone = TimeSpecs::Timezone.new("Asia/Colombo", "MMT", (5*3600+30*60))
t = Time.new(2000, 1, 1, 12, 0, 0, zone)
t.to_a[0, 6].should == [0, 0, 12, 1, 1, 2000]
t.utc_offset.should == 19800
t.zone.should == zone
it "returns a Time in the timezone" do
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.new(2000, 1, 1, 12, 0, 0, zone)
time.zone.should == zone
time.utc_offset.should == 5*3600+30*60
end
it "accepts timezone argument that must have #local_to_utc and #utc_to_local methods" do
zone = Object.new
def zone.utc_to_local(time)
time
end
def zone.local_to_utc(time)
time
end
lambda {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
}.should_not raise_error
end
it "raises TypeError if timezone does not implement #local_to_utc method" do
zone = Object.new
def zone.utc_to_local(time)
time
end
lambda {
Time.new(2000, 1, 1, 12, 0, 0, zone)
}.should raise_error(TypeError, /can't convert \w+ into an exact number/)
end
it "does not raise exception if timezone does not implement #utc_to_local method" do
zone = Object.new
def zone.local_to_utc(time)
time
end
lambda {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
}.should_not raise_error
end
# The result also should be a Time or Time-like object (not necessary to be the same class)
# The zone of the result is just ignored
describe "returned value by #utc_to_local and #local_to_utc methods" do
it "could be Time instance" do
zone = Object.new
def zone.local_to_utc(t)
Time.utc(t.year, t.mon, t.day, t.hour - 1, t.min, t.sec)
end
lambda {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60
}.should_not raise_error
end
it "could be Time subclass instance" do
zone = Object.new
def zone.local_to_utc(t)
Class.new(Time).utc(t.year, t.mon, t.day, t.hour - 1, t.min, t.sec)
end
lambda {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60
}.should_not raise_error
end
it "could be any object with #to_i method" do
zone = Object.new
def zone.local_to_utc(time)
Struct.new(:to_i).new(time.to_i - 60*60)
end
lambda {
Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60
}.should_not raise_error
end
it "could have any #zone and #utc_offset because they are ignored" do
zone = Object.new
def zone.local_to_utc(time)
Struct.new(:to_i, :zone, :utc_offset).new(time.to_i, 'America/New_York', -5*60*60)
end
Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 0
zone = Object.new
def zone.local_to_utc(time)
Struct.new(:to_i, :zone, :utc_offset).new(time.to_i, 'Asia/Tokyo', 9*60*60)
end
Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 0
end
it "leads to raising Argument error if difference between argument and result is too large" do
zone = Object.new
def zone.local_to_utc(t)
Time.utc(t.year, t.mon, t.day + 1, t.hour, t.min, t.sec)
end
lambda {
Time.new(2000, 1, 1, 12, 0, 0, zone)
}.should raise_error(ArgumentError, "utc_offset out of range")
end
end
# https://github.com/ruby/ruby/blob/v2_6_0/time.c#L5330
#
# Time-like argument to these methods is similar to a Time object in UTC without sub-second;
# it has attribute readers for the parts, e.g. year, month, and so on, and epoch time readers, to_i
#
# The sub-second attributes are fixed as 0, and utc_offset, zone, isdst, and their aliases are same as a Time object in UTC
describe "Time-like argument of #utc_to_local and #local_to_utc methods" do
before do
@obj = TimeSpecs::TimeLikeArgumentRecorder.result
@obj.should_not == nil
end
it "implements subset of Time methods" do
[
:year, :mon, :month, :mday, :hour, :min, :sec,
:tv_sec, :tv_usec, :usec, :tv_nsec, :nsec, :subsec,
:to_i, :to_f, :to_r, :+, :-,
:isdst, :dst?, :zone, :gmtoff, :gmt_offset, :utc_offset, :utc?, :gmt?,
:to_s, :inspect, :to_a, :to_time,
].each do |name|
@obj.respond_to?(name).should == true
end
end
it "has attribute values the same as a Time object in UTC" do
@obj.usec.should == 0
@obj.nsec.should == 0
@obj.subsec.should == 0
@obj.tv_usec.should == 0
@obj.tv_nsec.should == 0
@obj.utc_offset.should == 0
@obj.zone.should == "UTC"
@obj.isdst.should == Time.new.utc.isdst
end
end
context "#name method" do
it "uses the optional #name method for marshaling" do
zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo", offset: (5*3600+30*60))
time = Time.new(2000, 1, 1, 12, 0, 0, zone)
time_loaded = Marshal.load(Marshal.dump(time))
time_loaded.zone.should == "Asia/Colombo"
time_loaded.utc_offset.should == 5*3600+30*60
end
it "cannot marshal Time if #name method isn't implemented" do
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.new(2000, 1, 1, 12, 0, 0, zone)
lambda {
Marshal.dump(time)
}.should raise_error(NoMethodError, /undefined method `name' for/)
end
end
it "the #abbr method is used by '%Z' in #strftime" do
zone = TimeSpecs::TimezoneWithAbbr.new(abbr: "MMT", offset: (5*3600+30*60))
time = Time.new(2000, 1, 1, 12, 0, 0, zone)
time.strftime("%Z").should == "MMT"
end
# At loading marshaled data, a timezone name will be converted to a timezone object
# by find_timezone class method, if the method is defined.
# Similary, that class method will be called when a timezone argument does not have
# the necessary methods mentioned above.
context "subject's class implements .find_timezone method" do
it "calls .find_timezone to build a time object at loading marshaled data" do
zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo", offset: (5*3600+30*60))
time = TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, zone)
time_loaded = Marshal.load(Marshal.dump(time))
time_loaded.zone.should be_kind_of TimeSpecs::TimezoneWithName
time_loaded.zone.name.should == "Asia/Colombo"
time_loaded.utc_offset.should == 5*3600+30*60
end
it "calls .find_timezone to build a time object if passed zone name as a timezone argument" do
time = TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, "Asia/Colombo")
time.zone.should be_kind_of TimeSpecs::TimezoneWithName
time.zone.name.should == "Asia/Colombo"
time = TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, "some invalid zone name")
time.zone.should be_kind_of TimeSpecs::TimezoneWithName
time.zone.name.should == "some invalid zone name"
end
it "does not call .find_timezone if passed any not string/numeric/timezone timezone argument" do
[Object.new, [], {}, :"some zone"].each do |zone|
lambda {
TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, zone)
}.should raise_error(TypeError, /can't convert \w+ into an exact number/)
end
end
end
end
end

View file

@ -1,4 +1,5 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
describe "Time#+" do
it "increments the time by the specified amount" do
@ -47,16 +48,22 @@ describe "Time#+" do
(Time.new(2012, 1, 1, 0, 0, 0, 3600) + 10).utc_offset.should == 3600
end
it "preserves time zone" do
time_with_zone = Time.now.utc
time_with_zone.zone.should == (time_with_zone + 60*60).zone
time_with_zone = Time.now
time_with_zone.zone.should == (time_with_zone + 60*60).zone
end
ruby_version_is "2.6" do
it "returns a time with the same timezone as self" do
zone = mock("timezone")
zone.should_receive(:local_to_utc).and_return(Time.utc(2012, 1, 1, 6, 30, 0))
zone.should_receive(:utc_to_local).and_return(Time.utc(2012, 1, 1, 12, 0, 10))
t = Time.new(2012, 1, 1, 12, 0, 0, zone) + 10
t.zone.should == zone
t.utc_offset.should == 19800
t.to_a[0, 6].should == [10, 0, 12, 1, 1, 2012]
t.should == Time.utc(2012, 1, 1, 6, 30, 10)
context "zone is a timezone object" do
it "preserves time zone" do
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.new(2012, 1, 1, 12, 0, 0, zone) + 60*60
time.zone.should == zone
end
end
end

View file

@ -1,19 +1,39 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
describe "Time#succ" do
it "returns a new time one second later than time" do
-> {
suppress_warning {
@result = Time.at(100).succ
}.should complain(/Time#succ is obsolete/)
}
@result.should == Time.at(101)
end
it "returns a new instance" do
t1 = Time.at(100)
t2 = nil
-> {
t2 = t1.succ
time = Time.at(100)
suppress_warning {
@result = time.succ
}
@result.should_not equal time
end
it "is obsolete" do
lambda {
Time.at(100).succ
}.should complain(/Time#succ is obsolete/)
t1.should_not equal t2
end
ruby_version_is "2.6" do
context "zone is a timezone object" do
it "preserves time zone" do
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 60*60
time.zone.should == zone
end
end
end
end

View file

@ -99,4 +99,416 @@ describe 'TracePoint#enable' do
trace.enabled?.should be_false
end
end
ruby_version_is "2.6" do
describe 'target: option' do
before :each do
ScratchPad.record []
end
it 'enables trace point for specific location' do
trace = TracePoint.new(:call) do |tp|
ScratchPad << tp.method_id
end
obj = Object.new
def obj.foo; end
def obj.bar; end
trace.enable(target: obj.method(:foo)) do
obj.foo
obj.bar
end
ScratchPad.recorded.should == [:foo]
end
it 'traces all the events triggered in specified location' do
trace = TracePoint.new(:line, :call, :return, :b_call, :b_return) do |tp|
ScratchPad << tp.event
end
obj = Object.new
def obj.foo
bar
-> {}.call
end
def obj.bar; end
trace.enable(target: obj.method(:foo)) do
obj.foo
end
ScratchPad.recorded.uniq.sort.should == [:call, :return, :b_call, :b_return, :line].sort
end
it 'does not trace events in nested locations' do
trace = TracePoint.new(:call) do |tp|
ScratchPad << tp.method_id
end
obj = Object.new
def obj.foo
bar
end
def obj.bar
baz
end
def obj.baz
end
trace.enable(target: obj.method(:foo)) do
obj.foo
end
ScratchPad.recorded.should == [:foo]
end
it "traces some events in nested blocks" do
klass = Class.new do
def foo
1.times do
1.times do
bar do
end
end
end
end
def bar(&blk)
blk.call
end
end
trace = TracePoint.new(:b_call) do |tp|
ScratchPad << tp.lineno
end
obj = klass.new
_, lineno = obj.method(:foo).source_location
trace.enable(target: obj.method(:foo)) do
obj.foo
end
ScratchPad.recorded.should == (lineno+1..lineno+3).to_a
end
describe 'option value' do
it 'excepts Method' do
trace = TracePoint.new(:call) do |tp|
ScratchPad << tp.method_id
end
obj = Object.new
def obj.foo; end
trace.enable(target: obj.method(:foo)) do
obj.foo
end
ScratchPad.recorded.should == [:foo]
end
it 'excepts UnboundMethod' do
trace = TracePoint.new(:call) do |tp|
ScratchPad << tp.method_id
end
klass = Class.new do
def foo; end
end
unbound_method = klass.instance_method(:foo)
trace.enable(target: unbound_method) do
klass.new.foo
end
ScratchPad.recorded.should == [:foo]
end
it 'excepts Proc' do
trace = TracePoint.new(:b_call) do |tp|
ScratchPad << tp.lineno
end
block = proc {}
_, lineno = block.source_location
trace.enable(target: block) do
block.call
end
ScratchPad.recorded.should == [lineno]
lineno.should be_kind_of(Integer)
end
it 'excepts RubyVM::InstructionSequence' do
trace = TracePoint.new(:call) do |tp|
ScratchPad << tp.method_id
end
obj = Object.new
def obj.foo; end
iseq = RubyVM::InstructionSequence.of(obj.method(:foo))
trace.enable(target: iseq) do
obj.foo
end
ScratchPad.recorded.should == [:foo]
end
end
it "raises ArgumentError when passed object isn't consisted of InstructionSequence (iseq)" do
trace = TracePoint.new(:call) do |tp|
ScratchPad << tp.method_id
end
core_method = 'foo bar'.method(:bytes)
RubyVM::InstructionSequence.of(core_method).should == nil
lambda {
trace.enable(target: core_method) do
end
}.should raise_error(ArgumentError, /specified target is not supported/)
end
it "raises ArgumentError if target object cannot trigger specified event" do
trace = TracePoint.new(:call) do |tp|
ScratchPad << tp.method_id
end
block = proc {}
lambda {
trace.enable(target: block) do
block.call # triggers :b_call and :b_return events
end
}.should raise_error(ArgumentError, /can not enable any hooks/)
end
it "raises ArgumentError if passed not Method/UnboundMethod/Proc/RubyVM::InstructionSequence" do
trace = TracePoint.new(:call) do |tp|
end
lambda {
trace.enable(target: Object.new) do
end
}.should raise_error(ArgumentError, /specified target is not supported/)
end
context "nested enabling and disabling" do
it "raises ArgumentError if trace point already enabled with target is re-enabled with target" do
trace = TracePoint.new(:b_call) do
end
lambda {
trace.enable(target: -> {}) do
trace.enable(target: -> {}) do
end
end
}.should raise_error(ArgumentError, /can't nest-enable a targetting TracePoint/)
end
it "raises ArgumentError if trace point already enabled without target is re-enabled with target" do
trace = TracePoint.new(:b_call) do
end
lambda {
trace.enable do
trace.enable(target: -> {}) do
end
end
}.should raise_error(ArgumentError, /can't nest-enable a targetting TracePoint/)
end
it "raises ArgumentError if trace point already enabled with target is re-enabled without target" do
trace = TracePoint.new(:b_call) do
end
lambda {
trace.enable(target: -> {}) do
trace.enable do
end
end
}.should raise_error(ArgumentError, /can't nest-enable a targetting TracePoint/)
end
it "raises ArgumentError if trace point already enabled with target is disabled with block" do
trace = TracePoint.new(:b_call) do
end
lambda {
trace.enable(target: -> {}) do
trace.disable do
end
end
}.should raise_error(ArgumentError, /can't disable a targetting TracePoint in a block/)
end
it "traces events when trace point with target is enabled in another trace point enabled without target" do
trace_outer = TracePoint.new(:b_call) do |tp|
ScratchPad << :outer
end
trace_inner = TracePoint.new(:b_call) do |tp|
ScratchPad << :inner
end
target = -> {}
trace_outer.enable do
trace_inner.enable(target: target) do
target.call
end
end
ScratchPad.recorded.should == [:outer, :outer, :outer, :inner]
end
it "traces events when trace point with target is enabled in another trace point enabled with target" do
trace_outer = TracePoint.new(:b_call) do |tp|
ScratchPad << :outer
end
trace_inner = TracePoint.new(:b_call) do |tp|
ScratchPad << :inner
end
target = -> {}
trace_outer.enable(target: target) do
trace_inner.enable(target: target) do
target.call
end
end
ScratchPad.recorded.should == [:inner, :outer]
end
it "traces events when trace point without target is enabled in another trace point enabled with target" do
trace_outer = TracePoint.new(:b_call) do |tp|
ScratchPad << :outer
end
trace_inner = TracePoint.new(:b_call) do |tp|
ScratchPad << :inner
end
target = -> {}
trace_outer.enable(target: target) do
trace_inner.enable do
target.call
end
end
ScratchPad.recorded.should == [:inner, :inner, :outer]
end
end
end
describe 'target_line: option' do
before :each do
ScratchPad.record []
end
it "traces :line events only on specified line of code" do
trace = TracePoint.new(:line) do |tp|
ScratchPad << tp.lineno
end
target = -> {
x = 1
y = 2 # <= this line is target
z = x + y
}
_, lineno = target.source_location
target_line = lineno + 2
trace.enable(target_line: target_line, target: target) do
target.call
end
ScratchPad.recorded.should == [target_line]
end
it "raises ArgumentError if :target option isn't specified" do
trace = TracePoint.new(:line) do |tp|
end
lambda {
trace.enable(target_line: 67) do
end
}.should raise_error(ArgumentError, /only target_line is specified/)
end
it "raises ArgumentError if :line event isn't registered" do
trace = TracePoint.new(:call) do |tp|
end
target = -> {
x = 1
y = 2 # <= this line is target
z = x + y
}
_, lineno = target.source_location
target_line = lineno + 2
lambda {
trace.enable(target_line: target_line, target: target) do
end
}.should raise_error(ArgumentError, /target_line is specified, but line event is not specified/)
end
it "raises ArgumentError if :target_line value is out of target code lines range" do
trace = TracePoint.new(:line) do |tp|
end
lambda {
trace.enable(target_line: 1, target: -> { }) do
end
}.should raise_error(ArgumentError, /can not enable any hooks/)
end
it "raises TypeError if :target_line value couldn't be coerced to Integer" do
trace = TracePoint.new(:line) do |tp|
end
lambda {
trace.enable(target_line: Object.new, target: -> { }) do
end
}.should raise_error(TypeError, /no implicit conversion of \w+? into Integer/)
end
it "raises ArgumentError if :target_line value is negative" do
trace = TracePoint.new(:line) do |tp|
end
lambda {
trace.enable(target_line: -2, target: -> { }) do
end
}.should raise_error(ArgumentError, /can not enable any hooks/)
end
it "excepts value that could be coerced to Integer" do
trace = TracePoint.new(:line) do |tp|
ScratchPad << tp.lineno
end
target = -> {
x = 1 # <= this line is target
}
_, lineno = target.source_location
target_line = lineno + 1
trace.enable(target_line: target_line.to_r, target: target) do
target.call
end
ScratchPad.recorded.should == [target_line]
end
end
end
end

View file

@ -36,7 +36,7 @@ describe "A block yielded a single" do
m([1, 2]) { |a=5, b=4, c=3| [a, b, c] }.should == [1, 2, 3]
end
it "assgins elements to post arguments" do
it "assigns elements to post arguments" do
m([1, 2]) { |a=5, b, c, d| [a, b, c, d] }.should == [5, 1, 2, nil]
end
@ -250,7 +250,7 @@ describe "A block" do
end
describe "taking |a, b| arguments" do
it "assgins nil to the arguments when no values are yielded" do
it "assigns nil to the arguments when no values are yielded" do
@y.z { |a, b| [a, b] }.should == [nil, nil]
end
@ -454,7 +454,7 @@ describe "A block" do
@y.z { |a, | a }.should be_nil
end
it "assgins the argument a single value yielded" do
it "assigns the argument a single value yielded" do
@y.s(1) { |a, | a }.should == 1
end

View file

@ -30,12 +30,12 @@ describe "The defined? keyword for literals" do
end
it "returns nil if one element is not defined" do
ret = defined?([NonExistantConstant, Array])
ret = defined?([NonExistentConstant, Array])
ret.should == nil
end
it "returns nil if all elements are not defined" do
ret = defined?([NonExistantConstant, AnotherNonExistantConstant])
ret = defined?([NonExistentConstant, AnotherNonExistentConstant])
ret.should == nil
end

View file

@ -251,7 +251,7 @@ describe 'Optional variable assignments' do
end
end
describe 'using compunded constants' do
describe 'using compounded constants' do
before :each do
Object.send(:remove_const, :A) if defined? Object::A
end

View file

@ -45,7 +45,7 @@ describe "The private keyword" do
lambda { f.foo }.should raise_error(NoMethodError)
end
it "changes visiblity of previously called methods with same send/call site" do
it "changes visibility of previously called methods with same send/call site" do
g = ::Private::G.new
lambda {
2.times do

View file

@ -21,7 +21,7 @@ describe "A Proc" do
@l.call.should == 1
end
it "raises an ArgumentErro if a value is passed" do
it "raises an ArgumentError if a value is passed" do
lambda { @l.call(0) }.should raise_error(ArgumentError)
end
end

View file

@ -67,7 +67,7 @@ describe "Regexps with escape characters" do
/\cJ/.match("\r").should be_nil
# Parsing precedence
/\cJ+/.match("\n\n").to_a.should == ["\n\n"] # Quantifers apply to entire escape sequence
/\cJ+/.match("\n\n").to_a.should == ["\n\n"] # Quantifiers apply to entire escape sequence
/\\cJ/.match("\\cJ").to_a.should == ["\\cJ"]
lambda { eval('/[abc\x]/') }.should raise_error(SyntaxError) # \x is treated as a escape sequence even inside a character class
# Syntax error

View file

@ -1,7 +1,7 @@
require_relative '../../spec_helper'
require_relative '../fixtures/classes'
describe "Regexps with modifers" do
describe "Regexps with modifiers" do
it "supports /i (case-insensitive)" do
/foo/i.match("FOO").to_a.should == ["FOO"]
end

View file

@ -45,7 +45,7 @@ describe "Regexps with repetition" do
it "does not treat {m,n}+ as possessive" do
-> {
@regexp = eval "/foo(A{0,1}+)Abar/"
}.should complain(/nested repeat operato/)
}.should complain(/nested repeat operator/)
@regexp.match("fooAAAbar").to_a.should == ["fooAAAbar", "AA"]
end
end

View file

@ -97,7 +97,7 @@ describe "Literal Regexps" do
it "supports (?> ) (embedded subexpression)" do
/(?>foo)(?>bar)/.match("foobar").to_a.should == ["foobar"]
/(?>foo*)obar/.match("foooooooobar").should be_nil # it is possesive
/(?>foo*)obar/.match("foooooooobar").should be_nil # it is possessive
end
it "supports (?# )" do

View file

@ -6,10 +6,10 @@ require_relative 'fixtures/send'
# will verify special and generic arity code paths for all impls.
#
# Method naming conventions:
# M - Manditory Args
# M - Mandatory Args
# O - Optional Arg
# R - Rest Arg
# Q - Post Manditory Args
# Q - Post Mandatory Args
specs = LangSendSpecs

View file

@ -220,7 +220,7 @@ describe "The until modifier with begin .. end block" do
a.should == [0, 1, 2, 4]
end
it "restart the current iteration without reevaluting condition with redo" do
it "restart the current iteration without reevaluating condition with redo" do
a = []
i = 0
j = 0

View file

@ -330,7 +330,7 @@ describe "The while modifier with begin .. end block" do
a.should == [0, 1, 2, 4]
end
it "restarts the current iteration without reevaluting condition with redo" do
it "restarts the current iteration without reevaluating condition with redo" do
a = []
i = 0
j = 0

View file

@ -163,7 +163,7 @@ describe "BigDecimal#divmod" do
end
end
it "returns an array of two zero if the diviend is zero" do
it "returns an array of two zero if the dividend is zero" do
@zeroes.each do |zero|
@regular_vals.each do |val|
zero.divmod(val).should == [@zero, @zero]

View file

@ -87,7 +87,7 @@ describe "BigDecimal#sqrt" do
}.should raise_error(FloatDomainError)
end
it "returns positive infitinity for infinity" do
it "returns positive infinity for infinity" do
@infinity.sqrt(1).should == @infinity
end

View file

@ -1,7 +1,7 @@
require_relative '../../spec_helper'
require 'cgi'
describe "CGI.rfc1123_date when passsed Time" do
describe "CGI.rfc1123_date when passed Time" do
it "returns the passed Time formatted in RFC1123 ('Sat, 01 Dec 2007 15:56:42 GMT')" do
input = Time.at(1196524602)
expected = 'Sat, 01 Dec 2007 15:56:42 GMT'

View file

@ -30,7 +30,7 @@ describe "DateTime#to_date" do
it "maintains the same julian day regardless of local time or zone" do
dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00')
with_timezone("Pactific/Pago_Pago", -11) do
with_timezone("Pacific/Pago_Pago", -11) do
dt.to_date.jd.should == dt.jd
end
end

View file

@ -10,7 +10,7 @@ describe "DateTime#to_s" do
it "maintains timezone regardless of local time" do
dt = DateTime.new(2012, 12, 24, 1, 2, 3, "+03:00")
with_timezone("Pactific/Pago_Pago", -11) do
with_timezone("Pacific/Pago_Pago", -11) do
dt.to_s.should == "2012-12-24T01:02:03+03:00"
end
end

View file

@ -22,7 +22,7 @@ describe "DateTime#to_time" do
it "preserves the same time regardless of local time or zone" do
date = DateTime.new(2012, 12, 24, 12, 23, 00, '+03:00')
with_timezone("Pactific/Pago_Pago", -11) do
with_timezone("Pacific/Pago_Pago", -11) do
time = date.to_time
time.utc_offset.should == 3 * 3600

View file

@ -17,7 +17,7 @@ describe "Delegator when frozen" do
@delegate.frozen?.should be_true
end
it "is not writeable" do
it "is not writable" do
lambda{ @delegate[0] += 2 }.should raise_error( RuntimeError )
end

View file

@ -19,7 +19,7 @@ describe "GetoptLong#terminate" do
end
end
it "returns self when option processsing is terminated" do
it "returns self when option processing is terminated" do
@opts.terminate.should == @opts
end

View file

@ -37,7 +37,7 @@ describe "Logger#new" do
lambda { Logger.new(@log_file, 1).close }.should_not raise_error
end
it "receivs a maximum logfile size as third argument" do
it "receives a maximum logfile size as third argument" do
# This should create 2 small log files, logfile_test and logfile_test.0
# in /tmp, each one with a different message.
path = tmp("logfile_test.log")

View file

@ -8,7 +8,7 @@ describe "Matrix::EigenvalueDecomposition#eigenvalues" do
[ Complex(1, -1), Complex(1, 1)]
end
it "returns an array of real eigenvalues for a symetric matrix" do
it "returns an array of real eigenvalues for a symmetric matrix" do
Matrix[[1, 2],
[2, 1]].eigensystem.eigenvalues.sort.map!{|x| x.round(10)}.should ==
[ -1, 3 ]

View file

@ -10,7 +10,7 @@ describe "Matrix::EigenvalueDecomposition#eigenvector_matrix" do
[Complex(0, 1), Complex(0, -1)]]
end
it "returns an real eigenvector matrix for a symetric matrix" do
it "returns an real eigenvector matrix for a symmetric matrix" do
# Fix me: should test for linearity, not for equality
Matrix[[1, 2],
[2, 1]].eigensystem.eigenvector_matrix.should ==

View file

@ -11,7 +11,7 @@ describe "Matrix::EigenvalueDecomposition#eigenvectors" do
]
end
it "returns an array of real eigenvectors for a symetric matrix" do
it "returns an array of real eigenvectors for a symmetric matrix" do
# Fix me: should test for linearity, not for equality
Matrix[[1, 2],
[2, 1]].eigensystem.eigenvectors.should ==

View file

@ -22,7 +22,7 @@ describe "Net::FTP#quit" do
@ftp.last_response.should == "221 OK, bye\n"
end
it "does not close the socket automagically" do
it "does not close the socket automatically" do
@ftp.quit
@ftp.closed?.should be_false
end

View file

@ -2,7 +2,7 @@ require_relative '../../../../spec_helper'
require 'net/http'
describe "Net::HTTP.proxy_class?" do
it "returns true if sels is a class created with Net::HTTP.Proxy" do
it "returns true if self is a class created with Net::HTTP.Proxy" do
Net::HTTP.proxy_class?.should be_false
Net::HTTP.Proxy("localhost").proxy_class?.should be_true
end

View file

@ -76,7 +76,7 @@ describe "Net::HTTPResponse#read_body" do
end
describe "when passed buffer and block" do
it "rauses an ArgumentError" do
it "raises an ArgumentError" do
@res.reading_body(@socket, true) do
lambda { @res.read_body("") {} }.should raise_error(ArgumentError)
end

View file

@ -14,7 +14,7 @@ describe "OpenStruct.new when frozen" do
@os.name.should == "John Smith"
end
it "is not writeable" do
it "is not writable" do
lambda{ @os.age = 42 }.should raise_error( RuntimeError )
end

View file

@ -19,7 +19,7 @@ describe "REXML::Attribute#initialize" do
copy.should == @name
end
it "recives a parent node" do
it "receives a parent node" do
last_name = REXML::Attribute.new("last_name", "McBrain", @e)
last_name.element.should == @e

View file

@ -3,7 +3,7 @@ require_relative '../../spec_helper'
require 'securerandom'
describe "SecureRandom.hex" do
it "generates a random hex string of length twice the specified argement" do
it "generates a random hex string of length twice the specified argument" do
(1..64).each do |idx|
hex = SecureRandom.hex(idx)
hex.should be_kind_of(String)

View file

@ -1,7 +1,7 @@
require_relative '../../../spec_helper'
require 'set'
describe "Emumerable#to_set" do
describe "Enumerable#to_set" do
it "returns a new Set created from self" do
[1, 2, 3].to_set.should == Set[1, 2, 3]
{a: 1, b: 2}.to_set.should == Set[[:b, 2], [:a, 1]]

View file

@ -6,7 +6,7 @@ describe "Set#^" do
@set = Set[1, 2, 3, 4]
end
it "returns a new Set containing elements that are not in both self and the passed Enumberable" do
it "returns a new Set containing elements that are not in both self and the passed Enumerable" do
(@set ^ Set[3, 4, 5]).should == Set[1, 2, 5]
(@set ^ [3, 4, 5]).should == Set[1, 2, 5]
end

View file

@ -6,7 +6,7 @@ describe "SortedSet#^" do
@set = SortedSet[1, 2, 3, 4]
end
it "returns a new SortedSet containing elements that are not in both self and the passed Enumberable" do
it "returns a new SortedSet containing elements that are not in both self and the passed Enumerable" do
(@set ^ SortedSet[3, 4, 5]).should == SortedSet[1, 2, 5]
(@set ^ [3, 4, 5]).should == SortedSet[1, 2, 5]
end

View file

@ -7,7 +7,7 @@ describe "Addrinfo#ipv4_multicast?" do
Addrinfo.ip('239.255.255.250').ipv4_multicast?.should == true
end
it 'returns false for a regular addrss' do
it 'returns false for a regular address' do
Addrinfo.ip('8.8.8.8').ipv4_multicast?.should == false
end

Some files were not shown because too many files have changed in this diff Show more