summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2025-12-16 12:51:45 +0900
committerNobuyoshi Nakada <nobu.nakada@gmail.com>2025-12-16 16:13:07 +0900
commit065c48cdf11a1c4cece84db44ed8624d294f8fd5 (patch)
tree4a58159bae3dd1f41a4e74bf7aab3b06864b1a55 /test/ruby
parent5b0fefef417cad1733c18a0b66db07bcb1de5caf (diff)
Revert "[Feature #6012] Extend `source_location` for end position
and columns" This reverts commit 073c4e1cc712064e626914fa4a5a8061f903a637. https://bugs.ruby-lang.org/issues/6012#note-31 > we will cancel this feature in 4.0 because of design ambiguities > such as whether to return column positions in bytes or characters as > in [#21783]. [#21783]: https://bugs.ruby-lang.org/issues/21783
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_lambda.rb12
-rw-r--r--test/ruby/test_proc.rb18
2 files changed, 13 insertions, 17 deletions
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb
index 3cbb54306c..7738034240 100644
--- a/test/ruby/test_lambda.rb
+++ b/test/ruby/test_lambda.rb
@@ -276,27 +276,27 @@ class TestLambdaParameters < Test::Unit::TestCase
end
def test_do_lambda_source_location
- exp = [__LINE__ + 1, 12, __LINE__ + 5, 7]
+ exp_lineno = __LINE__ + 3
lmd = ->(x,
y,
z) do
#
end
- file, *loc = lmd.source_location
+ file, lineno = lmd.source_location
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
- assert_equal(exp, loc)
+ assert_equal(exp_lineno, lineno, "must be at the beginning of the block")
end
def test_brace_lambda_source_location
- exp = [__LINE__ + 1, 12, __LINE__ + 5, 5]
+ exp_lineno = __LINE__ + 3
lmd = ->(x,
y,
z) {
#
}
- file, *loc = lmd.source_location
+ file, lineno = lmd.source_location
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
- assert_equal(exp, loc)
+ assert_equal(exp_lineno, lineno, "must be at the beginning of the block")
end
def test_not_orphan_return
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 92cdfc6757..b50875e7b0 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -513,7 +513,7 @@ class TestProc < Test::Unit::TestCase
file, lineno = method(:source_location_test).to_proc.binding.source_location
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
- assert_equal(@@line_of_source_location_test[0], lineno, 'Bug #2427')
+ assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
end
def test_binding_error_unless_ruby_frame
@@ -1499,19 +1499,15 @@ class TestProc < Test::Unit::TestCase
assert_include(EnvUtil.labeled_class(name, Proc).new {}.to_s, name)
end
- @@line_of_source_location_test = [__LINE__ + 1, 2, __LINE__ + 3, 5]
+ @@line_of_source_location_test = __LINE__ + 1
def source_location_test a=1,
b=2
end
def test_source_location
- file, *loc = method(:source_location_test).source_location
+ file, lineno = method(:source_location_test).source_location
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
- assert_equal(@@line_of_source_location_test, loc, 'Bug #2427')
-
- file, *loc = self.class.instance_method(:source_location_test).source_location
- assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
- assert_equal(@@line_of_source_location_test, loc, 'Bug #2427')
+ assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
end
@@line_of_attr_reader_source_location_test = __LINE__ + 3
@@ -1544,13 +1540,13 @@ class TestProc < Test::Unit::TestCase
end
def test_block_source_location
- exp_loc = [__LINE__ + 3, 49, __LINE__ + 4, 49]
- file, *loc = block_source_location_test(1,
+ exp_lineno = __LINE__ + 3
+ file, lineno = block_source_location_test(1,
2,
3) do
end
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
- assert_equal(exp_loc, loc)
+ assert_equal(exp_lineno, lineno)
end
def test_splat_without_respond_to