ruby/test/yarp/heredoc_dedent_test.rb
Kevin Newton 439f069b4b [ruby/yarp] Move tests from test/* to test/yarp/* to match CRuby
This should make it easier on the sync to determine what changed
and hopefully result in fewer merge conflicts that have to be
manually resolved.

17d82afbfc
2023-08-25 21:15:49 +00:00

18 lines
590 B
Ruby

# frozen_string_literal: true
require_relative "test_helper"
module YARP
class HeredocDedentTest < Test::Unit::TestCase
filepath = File.expand_path("fixtures/tilde_heredocs.txt", __dir__)
File.read(filepath).split(/(?=\n)\n(?=<)/).each_with_index do |heredoc, index|
define_method "test_heredoc_#{index}" do
parts = YARP.parse(heredoc).value.statements.body.first.parts
actual = parts.map { |part| part.is_a?(StringNode) ? part.unescaped : "1" }.join
assert_equal(eval(heredoc), actual, "Expected heredocs to match.")
end
end
end
end