summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-04-01 14:34:15 -0400
committergit <[email protected]>2024-04-03 18:06:20 +0000
commitf24bf2f9ae4545c291a0182413104d897e1d0cb0 (patch)
tree9f5c9f28d1a58f9b85b16fabc5fdf23d159a7c36
parent354e15836719e110cdf02e6a71f5d76f6bf39fbd (diff)
Do not rely on ripper for magic comment test
-rw-r--r--test/prism/magic_comment_test.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/test/prism/magic_comment_test.rb b/test/prism/magic_comment_test.rb
index 4c02af732c..9e2e92af92 100644
--- a/test/prism/magic_comment_test.rb
+++ b/test/prism/magic_comment_test.rb
@@ -2,6 +2,8 @@
require_relative "test_helper"
+return if RUBY_ENGINE != "ruby"
+
module Prism
class MagicCommentTest < TestCase
examples = [
@@ -22,16 +24,10 @@ module Prism
examples.each.with_index(1) do |example, index|
define_method(:"test_magic_comment_#{index}") do
- assert_magic_comment(example)
+ expected = RubyVM::InstructionSequence.compile(%Q{#{example}\n""}).eval.encoding
+ actual = Prism.parse(example).encoding
+ assert_equal expected, actual
end
end
-
- private
-
- def assert_magic_comment(example)
- expected = Ripper.new(example).tap(&:parse).encoding
- actual = Prism.parse(example).encoding
- assert_equal expected, actual
- end
end
end