diff options
| author | alpaca-tc <alpaca-tc@alpaca.tc> | 2023-11-04 23:04:51 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-11-05 00:54:22 +0900 |
| commit | 8ed733f8f22cdc56a9d2694078871cfc401cb029 (patch) | |
| tree | 7b22b0e20ef70f5bf4bfa7aef69deb10d3a53a31 /test/ruby | |
| parent | d896269068355ba9ab90ee464150ef4fe76313b5 (diff) | |
ast.rb: Fix bug for source of multibyte characters
first_column and last_column return byte positions, but existing implementations
did not consider multibyte.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_ast.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index c8617d50f0..234c7af219 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -746,6 +746,14 @@ dummy assert_equal("def test_keep_script_lines_for_of\n", node_method.source.lines.first) end + def test_source_with_multibyte_characters + ast = RubyVM::AbstractSyntaxTree.parse(%{a("\u00a7");b("\u00a9")}, keep_script_lines: true) + a_fcall, b_fcall = ast.children[2].children + + assert_equal(%{a("\u00a7")}, a_fcall.source) + assert_equal(%{b("\u00a9")}, b_fcall.source) + end + def test_keep_tokens_for_parse node = RubyVM::AbstractSyntaxTree.parse(<<~END, keep_tokens: true) 1.times do |
