diff options
| author | Earlopain <14981592+Earlopain@users.noreply.github.com> | 2026-05-08 21:10:27 +0200 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2026-05-08 20:12:59 +0000 |
| commit | 07ae044b0dd4968b4ef6dd072cc0a2a851d79902 (patch) | |
| tree | 2a126468f5bf45d6bcb03b99dc197d2908e4ef80 /test | |
| parent | dc90c26a103ad62df73464cc1896edbcc90bd0c7 (diff) | |
[ruby/prism] Take the strings encoding as the initial encoding in the ripper translator
When no magic encoding comment is present, it does not default to utf-8,
and takes the encoding of the string that contains the source code instead.
Most of the time that will be utf-8, but not always.
https://github.com/ruby/prism/commit/1a273db780
Diffstat (limited to 'test')
| -rw-r--r-- | test/prism/ruby/ripper_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/prism/ruby/ripper_test.rb b/test/prism/ruby/ripper_test.rb index 05be087868..4fff630561 100644 --- a/test/prism/ruby/ripper_test.rb +++ b/test/prism/ruby/ripper_test.rb @@ -224,6 +224,12 @@ module Prism assert_equal(Ripper.tokenize(source), Translation::Ripper.tokenize(source)) end + def test_encoding + source = '"わたし"'.encode(Encoding::Windows_31J) + assert_equal(Ripper.tokenize(source), Translation::Ripper.tokenize(source)) + assert_equal(Ripper.sexp(source), Translation::Ripper.sexp(source)) + end + def test_sexp_coercion string_like = Object.new def string_like.to_str |
