diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-07 16:35:33 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-07 16:35:33 +0000 |
commit | 75334db3c6479ea3cd7462d36ca5464d386f9c72 (patch) | |
tree | c97df2c7aa02f3d0e65524890924f1b294871073 /spec/ruby/core | |
parent | 5c7c6763f6cf7b4face107735071c5470e835476 (diff) |
Update to ruby/spec@6cf8ebe
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core')
66 files changed, 977 insertions, 173 deletions
diff --git a/spec/ruby/core/array/combination_spec.rb b/spec/ruby/core/array/combination_spec.rb index 94a8e19341..f16d6f98fc 100644 --- a/spec/ruby/core/array/combination_spec.rb +++ b/spec/ruby/core/array/combination_spec.rb @@ -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 diff --git a/spec/ruby/core/array/fixtures/classes.rb b/spec/ruby/core/array/fixtures/classes.rb index 7ca9067328..42071ed0cd 100644 --- a/spec/ruby/core/array/fixtures/classes.rb +++ b/spec/ruby/core/array/fixtures/classes.rb @@ -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", diff --git a/spec/ruby/core/array/last_spec.rb b/spec/ruby/core/array/last_spec.rb index 871f4a2352..9bf8648776 100644 --- a/spec/ruby/core/array/last_spec.rb +++ b/spec/ruby/core/array/last_spec.rb @@ -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] diff --git a/spec/ruby/core/array/pack/shared/float.rb b/spec/ruby/core/array/pack/shared/float.rb index 082de27acd..6fc3b6b359 100644 --- a/spec/ruby/core/array/pack/shared/float.rb +++ b/spec/ruby/core/array/pack/shared/float.rb @@ -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 diff --git a/spec/ruby/core/array/product_spec.rb b/spec/ruby/core/array/product_spec.rb index 9207a9b014..7d810b6196 100644 --- a/spec/ruby/core/array/product_spec.rb +++ b/spec/ruby/core/array/product_spec.rb @@ -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 diff --git a/spec/ruby/core/array/rassoc_spec.rb b/spec/ruby/core/array/rassoc_spec.rb index decdaae098..62fbd40611 100644 --- a/spec/ruby/core/array/rassoc_spec.rb +++ b/spec/ruby/core/array/rassoc_spec.rb @@ -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 diff --git a/spec/ruby/core/array/repeated_combination_spec.rb b/spec/ruby/core/array/repeated_combination_spec.rb index 373b7bb6e5..b62382024a 100644 --- a/spec/ruby/core/array/repeated_combination_spec.rb +++ b/spec/ruby/core/array/repeated_combination_spec.rb @@ -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 diff --git a/spec/ruby/core/array/sum_spec.rb b/spec/ruby/core/array/sum_spec.rb index 71b8b9dc78..7d19c03480 100644 --- a/spec/ruby/core/array/sum_spec.rb +++ b/spec/ruby/core/array/sum_spec.rb @@ -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 diff --git a/spec/ruby/core/array/zip_spec.rb b/spec/ruby/core/array/zip_spec.rb index f0de864ed4..af4013debe 100644 --- a/spec/ruby/core/array/zip_spec.rb +++ b/spec/ruby/core/array/zip_spec.rb @@ -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 diff --git a/spec/ruby/core/dir/children_spec.rb b/spec/ruby/core/dir/children_spec.rb index c6329b416f..d28f1b1346 100644 --- a/spec/ruby/core/dir/children_spec.rb +++ b/spec/ruby/core/dir/children_spec.rb @@ -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 diff --git a/spec/ruby/core/dir/entries_spec.rb b/spec/ruby/core/dir/entries_spec.rb index 42f89a1623..488acec81b 100644 --- a/spec/ruby/core/dir/entries_spec.rb +++ b/spec/ruby/core/dir/entries_spec.rb @@ -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 diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb index 88ceb82c50..19f457e22a 100644 --- a/spec/ruby/core/dir/shared/glob.rb +++ b/spec/ruby/core/dir/shared/glob.rb @@ -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) diff --git a/spec/ruby/core/encoding/aliases_spec.rb b/spec/ruby/core/encoding/aliases_spec.rb index 88c7a1f2ef..22e4510993 100644 --- a/spec/ruby/core/encoding/aliases_spec.rb +++ b/spec/ruby/core/encoding/aliases_spec.rb @@ -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 diff --git a/spec/ruby/core/enumerable/fixtures/classes.rb b/spec/ruby/core/enumerable/fixtures/classes.rb index e50bf34779..5051196742 100644 --- a/spec/ruby/core/enumerable/fixtures/classes.rb +++ b/spec/ruby/core/enumerable/fixtures/classes.rb @@ -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) diff --git a/spec/ruby/core/enumerable/zip_spec.rb b/spec/ruby/core/enumerable/zip_spec.rb index 1212911697..9ec15aa030 100644 --- a/spec/ruby/core/enumerable/zip_spec.rb +++ b/spec/ruby/core/enumerable/zip_spec.rb @@ -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 diff --git a/spec/ruby/core/enumerator/chain/each_spec.rb b/spec/ruby/core/enumerator/chain/each_spec.rb index dab2c1cf1d..ab4d355f22 100644 --- a/spec/ruby/core/enumerator/chain/each_spec.rb +++ b/spec/ruby/core/enumerator/chain/each_spec.rb @@ -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) diff --git a/spec/ruby/core/exception/signal_exception_spec.rb b/spec/ruby/core/exception/signal_exception_spec.rb index c0632841d6..8e2f273a67 100644 --- a/spec/ruby/core/exception/signal_exception_spec.rb +++ b/spec/ruby/core/exception/signal_exception_spec.rb @@ -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 diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb index 9ecd730a7b..6e24e62075 100644 --- a/spec/ruby/core/file/expand_path_spec.rb +++ b/spec/ruby/core/file/expand_path_spec.rb @@ -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 diff --git a/spec/ruby/core/file/new_spec.rb b/spec/ruby/core/file/new_spec.rb index 815ecd9d36..3bb2712ada 100644 --- a/spec/ruby/core/file/new_spec.rb +++ b/spec/ruby/core/file/new_spec.rb @@ -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 diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb index c37e7316ba..931ff2d239 100644 --- a/spec/ruby/core/file/open_spec.rb +++ b/spec/ruby/core/file/open_spec.rb @@ -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 diff --git a/spec/ruby/core/file/shared/fnmatch.rb b/spec/ruby/core/file/shared/fnmatch.rb index 9b423ae47e..49a870e95a 100644 --- a/spec/ruby/core/file/shared/fnmatch.rb +++ b/spec/ruby/core/file/shared/fnmatch.rb @@ -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 diff --git a/spec/ruby/core/file/stat/dev_major_spec.rb b/spec/ruby/core/file/stat/dev_major_spec.rb index 4966d609e2..845c883a42 100644 --- a/spec/ruby/core/file/stat/dev_major_spec.rb +++ b/spec/ruby/core/file/stat/dev_major_spec.rb @@ -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 diff --git a/spec/ruby/core/file/stat/dev_minor_spec.rb b/spec/ruby/core/file/stat/dev_minor_spec.rb index ea79c12b99..ddfb6a7b6a 100644 --- a/spec/ruby/core/file/stat/dev_minor_spec.rb +++ b/spec/ruby/core/file/stat/dev_minor_spec.rb @@ -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 diff --git a/spec/ruby/core/file/stat/rdev_major_spec.rb b/spec/ruby/core/file/stat/rdev_major_spec.rb index f8a8d1b107..3d7f6ef759 100644 --- a/spec/ruby/core/file/stat/rdev_major_spec.rb +++ b/spec/ruby/core/file/stat/rdev_major_spec.rb @@ -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 diff --git a/spec/ruby/core/file/stat/rdev_minor_spec.rb b/spec/ruby/core/file/stat/rdev_minor_spec.rb index dc30c1f56c..e25c61ca86 100644 --- a/spec/ruby/core/file/stat/rdev_minor_spec.rb +++ b/spec/ruby/core/file/stat/rdev_minor_spec.rb @@ -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 diff --git a/spec/ruby/core/file/sticky_spec.rb b/spec/ruby/core/file/sticky_spec.rb index 7805c39f79..5f7b2d93eb 100644 --- a/spec/ruby/core/file/sticky_spec.rb +++ b/spec/ruby/core/file/sticky_spec.rb @@ -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) diff --git a/spec/ruby/core/float/comparison_spec.rb b/spec/ruby/core/float/comparison_spec.rb index a1ee423c24..4205d95c83 100644 --- a/spec/ruby/core/float/comparison_spec.rb +++ b/spec/ruby/core/float/comparison_spec.rb @@ -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 diff --git a/spec/ruby/core/float/round_spec.rb b/spec/ruby/core/float/round_spec.rb index df113f97b1..a21173e139 100644 --- a/spec/ruby/core/float/round_spec.rb +++ b/spec/ruby/core/float/round_spec.rb @@ -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 diff --git a/spec/ruby/core/hash/shift_spec.rb b/spec/ruby/core/hash/shift_spec.rb index 8cf3f4025a..47c9ac1821 100644 --- a/spec/ruby/core/hash/shift_spec.rb +++ b/spec/ruby/core/hash/shift_spec.rb @@ -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 = {} diff --git a/spec/ruby/core/io/read_spec.rb b/spec/ruby/core/io/read_spec.rb index 3bb581f430..6f6713d957 100644 --- a/spec/ruby/core/io/read_spec.rb +++ b/spec/ruby/core/io/read_spec.rb @@ -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 diff --git a/spec/ruby/core/io/readlines_spec.rb b/spec/ruby/core/io/readlines_spec.rb index 533c9c3132..c1ea706b26 100644 --- a/spec/ruby/core/io/readlines_spec.rb +++ b/spec/ruby/core/io/readlines_spec.rb @@ -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 diff --git a/spec/ruby/core/io/set_encoding_spec.rb b/spec/ruby/core/io/set_encoding_spec.rb index b749331ee0..9875d64ab8 100644 --- a/spec/ruby/core/io/set_encoding_spec.rb +++ b/spec/ruby/core/io/set_encoding_spec.rb @@ -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 diff --git a/spec/ruby/core/kernel/autoload_spec.rb b/spec/ruby/core/kernel/autoload_spec.rb index 5fa8fa92b3..3e7a63ede0 100644 --- a/spec/ruby/core/kernel/autoload_spec.rb +++ b/spec/ruby/core/kernel/autoload_spec.rb @@ -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 diff --git a/spec/ruby/core/kernel/eval_spec.rb b/spec/ruby/core/kernel/eval_spec.rb index 46158628a3..696c55a3ba 100644 --- a/spec/ruby/core/kernel/eval_spec.rb +++ b/spec/ruby/core/kernel/eval_spec.rb @@ -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 diff --git a/spec/ruby/core/kernel/throw_spec.rb b/spec/ruby/core/kernel/throw_spec.rb index 8f8486accc..1e56376529 100644 --- a/spec/ruby/core/kernel/throw_spec.rb +++ b/spec/ruby/core/kernel/throw_spec.rb @@ -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 diff --git a/spec/ruby/core/math/tan_spec.rb b/spec/ruby/core/math/tan_spec.rb index bf5c80f77c..031fe75085 100644 --- a/spec/ruby/core/math/tan_spec.rb +++ b/spec/ruby/core/math/tan_spec.rb @@ -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 diff --git a/spec/ruby/core/module/attr_spec.rb b/spec/ruby/core/module/attr_spec.rb index b114b06b6e..16680730d5 100644 --- a/spec/ruby/core/module/attr_spec.rb +++ b/spec/ruby/core/module/attr_spec.rb @@ -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 diff --git a/spec/ruby/core/module/autoload_spec.rb b/spec/ruby/core/module/autoload_spec.rb index b028dbc56c..05e9a61675 100644 --- a/spec/ruby/core/module/autoload_spec.rb +++ b/spec/ruby/core/module/autoload_spec.rb @@ -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) diff --git a/spec/ruby/core/module/comparison_spec.rb b/spec/ruby/core/module/comparison_spec.rb index 069bbd7a97..86ee5db22a 100644 --- a/spec/ruby/core/module/comparison_spec.rb +++ b/spec/ruby/core/module/comparison_spec.rb @@ -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 diff --git a/spec/ruby/core/module/const_get_spec.rb b/spec/ruby/core/module/const_get_spec.rb index 461b303d6d..d125c35762 100644 --- a/spec/ruby/core/module/const_get_spec.rb +++ b/spec/ruby/core/module/const_get_spec.rb @@ -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) diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb index 42b2b64331..4f34062343 100644 --- a/spec/ruby/core/module/refine_spec.rb +++ b/spec/ruby/core/module/refine_spec.rb @@ -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 diff --git a/spec/ruby/core/numeric/step_spec.rb b/spec/ruby/core/numeric/step_spec.rb index 96439927a4..a0a4c7c9f8 100644 --- a/spec/ruby/core/numeric/step_spec.rb +++ b/spec/ruby/core/numeric/step_spec.rb @@ -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 diff --git a/spec/ruby/core/process/getrlimit_spec.rb b/spec/ruby/core/process/getrlimit_spec.rb index 2ab825532b..0258bb3d80 100644 --- a/spec/ruby/core/process/getrlimit_spec.rb +++ b/spec/ruby/core/process/getrlimit_spec.rb @@ -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. diff --git a/spec/ruby/core/process/spawn_spec.rb b/spec/ruby/core/process/spawn_spec.rb index bb55fe299b..aa7a7dc3aa 100644 --- a/spec/ruby/core/process/spawn_spec.rb +++ b/spec/ruby/core/process/spawn_spec.rb @@ -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)"), diff --git a/spec/ruby/core/process/wait_spec.rb b/spec/ruby/core/process/wait_spec.rb index 5130bb4391..099fcdc518 100644 --- a/spec/ruby/core/process/wait_spec.rb +++ b/spec/ruby/core/process/wait_spec.rb @@ -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 diff --git a/spec/ruby/core/regexp/match_spec.rb b/spec/ruby/core/regexp/match_spec.rb index e3247a088d..edac0d1d42 100644 --- a/spec/ruby/core/regexp/match_spec.rb +++ b/spec/ruby/core/regexp/match_spec.rb @@ -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 diff --git a/spec/ruby/core/signal/signame_spec.rb b/spec/ruby/core/signal/signame_spec.rb index 71b69b301a..41b43d3482 100644 --- a/spec/ruby/core/signal/signame_spec.rb +++ b/spec/ruby/core/signal/signame_spec.rb @@ -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 diff --git a/spec/ruby/core/signal/trap_spec.rb b/spec/ruby/core/signal/trap_spec.rb index c11c900add..a3298c71e1 100644 --- a/spec/ruby/core/signal/trap_spec.rb +++ b/spec/ruby/core/signal/trap_spec.rb @@ -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 diff --git a/spec/ruby/core/string/chomp_spec.rb b/spec/ruby/core/string/chomp_spec.rb index 3c20141ee7..d6ad710382 100644 --- a/spec/ruby/core/string/chomp_spec.rb +++ b/spec/ruby/core/string/chomp_spec.rb @@ -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 diff --git a/spec/ruby/core/string/chop_spec.rb b/spec/ruby/core/string/chop_spec.rb index 57c037322d..033a11a95b 100644 --- a/spec/ruby/core/string/chop_spec.rb +++ b/spec/ruby/core/string/chop_spec.rb @@ -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 diff --git a/spec/ruby/core/string/element_set_spec.rb b/spec/ruby/core/string/element_set_spec.rb index 80ec5755c6..340bd2b9ca 100644 --- a/spec/ruby/core/string/element_set_spec.rb +++ b/spec/ruby/core/string/element_set_spec.rb @@ -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 = "" diff --git a/spec/ruby/core/string/setbyte_spec.rb b/spec/ruby/core/string/setbyte_spec.rb index f998e61622..3f2e03f8a8 100644 --- a/spec/ruby/core/string/setbyte_spec.rb +++ b/spec/ruby/core/string/setbyte_spec.rb @@ -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 diff --git a/spec/ruby/core/string/shared/codepoints.rb b/spec/ruby/core/string/shared/codepoints.rb index 68f82b4468..589d2ee1d0 100644 --- a/spec/ruby/core/string/shared/codepoints.rb +++ b/spec/ruby/core/string/shared/codepoints.rb @@ -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 diff --git a/spec/ruby/core/string/shared/concat.rb b/spec/ruby/core/string/shared/concat.rb index d7b9cdfec3..bc38ba9a8b 100644 --- a/spec/ruby/core/string/shared/concat.rb +++ b/spec/ruby/core/string/shared/concat.rb @@ -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 == "!" diff --git a/spec/ruby/core/string/shared/equal_value.rb b/spec/ruby/core/string/shared/equal_value.rb index d797cb1483..fccafb5821 100644 --- a/spec/ruby/core/string/shared/equal_value.rb +++ b/spec/ruby/core/string/shared/equal_value.rb @@ -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 diff --git a/spec/ruby/core/string/to_r_spec.rb b/spec/ruby/core/string/to_r_spec.rb index 9f174a2f55..7e1d635d3b 100644 --- a/spec/ruby/core/string/to_r_spec.rb +++ b/spec/ruby/core/string/to_r_spec.rb @@ -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 diff --git a/spec/ruby/core/string/unpack/c_spec.rb b/spec/ruby/core/string/unpack/c_spec.rb index 82c0f8616d..bdcbd87663 100644 --- a/spec/ruby/core/string/unpack/c_spec.rb +++ b/spec/ruby/core/string/unpack/c_spec.rb @@ -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 diff --git a/spec/ruby/core/string/upto_spec.rb b/spec/ruby/core/string/upto_spec.rb index d2f1121360..3748a6fdeb 100644 --- a/spec/ruby/core/string/upto_spec.rb +++ b/spec/ruby/core/string/upto_spec.rb @@ -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"] diff --git a/spec/ruby/core/time/at_spec.rb b/spec/ruby/core/time/at_spec.rb index 7c66104156..1493012676 100644 --- a/spec/ruby/core/time/at_spec.rb +++ b/spec/ruby/core/time/at_spec.rb @@ -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 diff --git a/spec/ruby/core/time/fixtures/classes.rb b/spec/ruby/core/time/fixtures/classes.rb index d89e4911c8..ece7ed2bca 100644 --- a/spec/ruby/core/time/fixtures/classes.rb +++ b/spec/ruby/core/time/fixtures/classes.rb @@ -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 diff --git a/spec/ruby/core/time/getlocal_spec.rb b/spec/ruby/core/time/getlocal_spec.rb index 87a412f41c..8b6a21bb58 100644 --- a/spec/ruby/core/time/getlocal_spec.rb +++ b/spec/ruby/core/time/getlocal_spec.rb @@ -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 diff --git a/spec/ruby/core/time/minus_spec.rb b/spec/ruby/core/time/minus_spec.rb index 7c4b21f0d5..a47e726196 100644 --- a/spec/ruby/core/time/minus_spec.rb +++ b/spec/ruby/core/time/minus_spec.rb @@ -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 diff --git a/spec/ruby/core/time/new_spec.rb b/spec/ruby/core/time/new_spec.rb index 8d32c4e492..fe0e1aea31 100644 --- a/spec/ruby/core/time/new_spec.rb +++ b/spec/ruby/core/time/new_spec.rb @@ -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 diff --git a/spec/ruby/core/time/plus_spec.rb b/spec/ruby/core/time/plus_spec.rb index 0861e9c9f6..91713b84b3 100644 --- a/spec/ruby/core/time/plus_spec.rb +++ b/spec/ruby/core/time/plus_spec.rb @@ -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 diff --git a/spec/ruby/core/time/succ_spec.rb b/spec/ruby/core/time/succ_spec.rb index dace9b823e..395ed67064 100644 --- a/spec/ruby/core/time/succ_spec.rb +++ b/spec/ruby/core/time/succ_spec.rb @@ -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 diff --git a/spec/ruby/core/tracepoint/enable_spec.rb b/spec/ruby/core/tracepoint/enable_spec.rb index b1a8628896..3b43d3d6b4 100644 --- a/spec/ruby/core/tracepoint/enable_spec.rb +++ b/spec/ruby/core/tracepoint/enable_spec.rb @@ -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 |