Do not rely on ripper for magic comment test
This commit is contained in:
parent
354e158367
commit
f24bf2f9ae
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
require_relative "test_helper"
|
require_relative "test_helper"
|
||||||
|
|
||||||
|
return if RUBY_ENGINE != "ruby"
|
||||||
|
|
||||||
module Prism
|
module Prism
|
||||||
class MagicCommentTest < TestCase
|
class MagicCommentTest < TestCase
|
||||||
examples = [
|
examples = [
|
||||||
@ -22,16 +24,10 @@ module Prism
|
|||||||
|
|
||||||
examples.each.with_index(1) do |example, index|
|
examples.each.with_index(1) do |example, index|
|
||||||
define_method(:"test_magic_comment_#{index}") do
|
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
|
||||||
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
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user