diff options
author | Kevin Newton <[email protected]> | 2023-09-27 12:24:48 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2023-09-27 13:57:38 -0400 |
commit | 4f73a7c2f7ff16aa78cf0dec2d4c7f90a2c41c9b (patch) | |
tree | 3b6f0cedc858d46d30a28c6d03439d653884a915 /test/prism | |
parent | 8ab56869a64fdccc094f4a83c6367fb23b72d38b (diff) |
Sync to prism rename commits
Diffstat (limited to 'test/prism')
-rw-r--r-- | test/prism/bom_test.rb | 4 | ||||
-rw-r--r-- | test/prism/comments_test.rb | 6 | ||||
-rw-r--r-- | test/prism/compiler_test.rb | 6 | ||||
-rw-r--r-- | test/prism/desugar_compiler_test.rb | 6 | ||||
-rw-r--r-- | test/prism/dispatcher_test.rb | 4 | ||||
-rw-r--r-- | test/prism/encoding_test.rb | 18 | ||||
-rw-r--r-- | test/prism/errors_test.rb | 10 | ||||
-rw-r--r-- | test/prism/fixtures/spanning_heredoc.txt | 6 | ||||
-rw-r--r-- | test/prism/fuzzer_test.rb | 4 | ||||
-rw-r--r-- | test/prism/heredoc_dedent_test.rb | 4 | ||||
-rw-r--r-- | test/prism/library_symbols_test.rb | 28 | ||||
-rw-r--r-- | test/prism/locals_test.rb | 4 | ||||
-rw-r--r-- | test/prism/location_test.rb | 6 | ||||
-rw-r--r-- | test/prism/memsize_test.rb | 4 | ||||
-rw-r--r-- | test/prism/newline_test.rb | 8 | ||||
-rw-r--r-- | test/prism/parse_serialize_test.rb | 8 | ||||
-rw-r--r-- | test/prism/parse_test.rb | 41 | ||||
-rw-r--r-- | test/prism/pattern_test.rb | 8 | ||||
-rw-r--r-- | test/prism/regexp_test.rb | 6 | ||||
-rw-r--r-- | test/prism/ripper_compat_test.rb | 2 | ||||
-rw-r--r-- | test/prism/ruby_api_test.rb | 16 | ||||
-rw-r--r-- | test/prism/test_helper.rb | 6 | ||||
-rw-r--r-- | test/prism/unescape_test.rb | 4 | ||||
-rw-r--r-- | test/prism/version_test.rb | 2 |
24 files changed, 100 insertions, 111 deletions
diff --git a/test/prism/bom_test.rb b/test/prism/bom_test.rb index 3a4e04a900..1525caf458 100644 --- a/test/prism/bom_test.rb +++ b/test/prism/bom_test.rb @@ -6,7 +6,7 @@ return if RUBY_ENGINE == "jruby" || RUBY_ENGINE == "truffleruby" require_relative "test_helper" -module YARP +module Prism class BOMTest < TestCase def test_ident assert_bom("foo") @@ -53,7 +53,7 @@ module YARP def assert_bom(source) bommed = "\xEF\xBB\xBF#{source}" - assert_equal YARP.lex_ripper(bommed), YARP.lex_compat(bommed).value + assert_equal Prism.lex_ripper(bommed), Prism.lex_compat(bommed).value end end end diff --git a/test/prism/comments_test.rb b/test/prism/comments_test.rb index b7aadc0768..0748beb391 100644 --- a/test/prism/comments_test.rb +++ b/test/prism/comments_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class CommentsTest < TestCase def test_comment_inline source = "# comment" @@ -67,7 +67,7 @@ module YARP end # Foo end RUBY - result = YARP.parse(source) + result = Prism.parse(source) result.attach_comments! tree = result.value class_node = tree.statements.body.first @@ -92,7 +92,7 @@ module YARP end_column: end_column } - result = YARP.parse(source) + result = Prism.parse(source) assert result.errors.empty?, result.errors.map(&:message).join("\n") assert_equal type, result.comments.first.type diff --git a/test/prism/compiler_test.rb b/test/prism/compiler_test.rb index 141e183469..ed028d03d8 100644 --- a/test/prism/compiler_test.rb +++ b/test/prism/compiler_test.rb @@ -2,9 +2,9 @@ require_relative "test_helper" -module YARP +module Prism class CompilerTest < TestCase - class SExpressions < YARP::Compiler + class SExpressions < Prism::Compiler def visit_arguments_node(node) [:arguments, super] end @@ -24,7 +24,7 @@ module YARP def test_compiler expected = [:program, [[[:call, [[:integer], [:arguments, [[:integer]]]]]]]] - assert_equal expected, YARP.parse("1 + 2").value.accept(SExpressions.new) + assert_equal expected, Prism.parse("1 + 2").value.accept(SExpressions.new) end end end diff --git a/test/prism/desugar_compiler_test.rb b/test/prism/desugar_compiler_test.rb index 8d2b207fed..c72e141c6b 100644 --- a/test/prism/desugar_compiler_test.rb +++ b/test/prism/desugar_compiler_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class DesugarCompilerTest < TestCase def test_and_write assert_desugars("(AndNode (ClassVariableReadNode) (ClassVariableWriteNode (CallNode)))", "@@foo &&= bar") @@ -72,14 +72,14 @@ module YARP end def assert_desugars(expected, source) - ast = YARP.parse(source).value.accept(DesugarCompiler.new) + ast = Prism.parse(source).value.accept(DesugarCompiler.new) assert_equal expected, ast_inspect(ast.statements.body.last) ast.accept(EnsureEveryNodeOnceInAST.new) end def assert_not_desugared(source, reason) - ast = YARP.parse(source).value + ast = Prism.parse(source).value assert_equal_nodes(ast, ast.accept(DesugarCompiler.new)) end end diff --git a/test/prism/dispatcher_test.rb b/test/prism/dispatcher_test.rb index e67562e2da..0d8a6d35e9 100644 --- a/test/prism/dispatcher_test.rb +++ b/test/prism/dispatcher_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class DispatcherTest < TestCase class TestListener attr_reader :events_received @@ -29,7 +29,7 @@ module YARP dispatcher = Dispatcher.new dispatcher.register(listener, :on_call_node_enter, :on_call_node_leave, :on_integer_node_enter) - root = YARP.parse(<<~RUBY).value + root = Prism.parse(<<~RUBY).value def foo something(1, 2, 3) end diff --git a/test/prism/encoding_test.rb b/test/prism/encoding_test.rb index 8427bddcbe..b2e602b286 100644 --- a/test/prism/encoding_test.rb +++ b/test/prism/encoding_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class EncodingTest < TestCase %w[ ascii @@ -39,27 +39,27 @@ module YARP CP1252 ].each do |encoding| define_method "test_encoding_#{encoding}" do - result = YARP.parse("# encoding: #{encoding}\nident") + result = Prism.parse("# encoding: #{encoding}\nident") actual = result.value.statements.body.first.name.encoding assert_equal Encoding.find(encoding), actual end end def test_coding - result = YARP.parse("# coding: utf-8\nident") + result = Prism.parse("# coding: utf-8\nident") actual = result.value.statements.body.first.name.encoding assert_equal Encoding.find("utf-8"), actual end def test_coding_with_whitespace - result = YARP.parse("# coding \t \r \v : \t \v \r ascii-8bit \nident") + result = Prism.parse("# coding \t \r \v : \t \v \r ascii-8bit \nident") actual = result.value.statements.body.first.name.encoding assert_equal Encoding.find("ascii-8bit"), actual end def test_emacs_style - result = YARP.parse("# -*- coding: utf-8 -*-\nident") + result = Prism.parse("# -*- coding: utf-8 -*-\nident") actual = result.value.statements.body.first.name.encoding assert_equal Encoding.find("utf-8"), actual end @@ -67,7 +67,7 @@ module YARP # This test may be a little confusing. Basically when we use our strpbrk, it # takes into account the encoding of the file. def test_strpbrk_multibyte - result = YARP.parse(<<~RUBY) + result = Prism.parse(<<~RUBY) # encoding: Shift_JIS %w[\x81\x5c] RUBY @@ -86,19 +86,19 @@ module YARP utf-8-mac utf-8-* ].each do |encoding| - result = YARP.parse("# coding: #{encoding}\nident") + result = Prism.parse("# coding: #{encoding}\nident") actual = result.value.statements.body.first.name.encoding assert_equal Encoding.find("utf-8"), actual end end def test_first_lexed_token - encoding = YARP.lex("# encoding: ascii-8bit").value[0][0].value.encoding + encoding = Prism.lex("# encoding: ascii-8bit").value[0][0].value.encoding assert_equal Encoding.find("ascii-8bit"), encoding end def test_slice_encoding - slice = YARP.parse("# encoding: Shift_JIS\nア").value.slice + slice = Prism.parse("# encoding: Shift_JIS\nア").value.slice assert_equal (+"ア").force_encoding(Encoding::SHIFT_JIS), slice assert_equal Encoding::SHIFT_JIS, slice.encoding end diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb index 2b3c8f5c89..2a8e19447c 100644 --- a/test/prism/errors_test.rb +++ b/test/prism/errors_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class ErrorsTest < TestCase include DSL @@ -1175,7 +1175,7 @@ module YARP end def test_invalid_message_name - result = YARP.parse("+.@foo,+=foo") + result = Prism.parse("+.@foo,+=foo") assert_equal "", result.value.statements.body.first.write_name end @@ -1354,7 +1354,7 @@ module YARP # Ripper behaves differently on JRuby/TruffleRuby, so only check this on CRuby assert_nil Ripper.sexp_raw(source) if compare_ripper - result = YARP.parse(source) + result = Prism.parse(source) node = result.value.statements.body.last assert_equal_nodes(expected, node, compare_location: false) @@ -1363,12 +1363,12 @@ module YARP def assert_error_messages(source, errors, compare_ripper: RUBY_ENGINE == "ruby") assert_nil Ripper.sexp_raw(source) if compare_ripper - result = YARP.parse(source) + result = Prism.parse(source) assert_equal(errors, result.errors.map(&:message)) end def expression(source) - YARP.parse(source).value.statements.body.last + Prism.parse(source).value.statements.body.last end end end diff --git a/test/prism/fixtures/spanning_heredoc.txt b/test/prism/fixtures/spanning_heredoc.txt index a52a4c3c27..d88e0e4be1 100644 --- a/test/prism/fixtures/spanning_heredoc.txt +++ b/test/prism/fixtures/spanning_heredoc.txt @@ -31,7 +31,7 @@ A j] # ripper can't parse this successfully, though ruby runs it correctly -# TODO: yarp does not include the "\n" in "l\nl" in the AST like ruby does +# TODO: prism does not include the "\n" in "l\nl" in the AST like ruby does pp <<-A, %W[l\ k A @@ -43,8 +43,8 @@ m A n] -# ripper gets this one wrong in the same way that YARP does ... -# TODO: yarp does not include the "\n" in "p\np" in the AST like ruby does +# ripper gets this one wrong in the same way that prism does ... +# TODO: prism does not include the "\n" in "p\np" in the AST like ruby does pp <<-A, %I[p\ o A diff --git a/test/prism/fuzzer_test.rb b/test/prism/fuzzer_test.rb index f4abcd4ac8..04e45518b1 100644 --- a/test/prism/fuzzer_test.rb +++ b/test/prism/fuzzer_test.rb @@ -2,11 +2,11 @@ require_relative "test_helper" -module YARP +module Prism # These tests are simply to exercise snippets found by the fuzzer that caused invalid memory access. class FuzzerTest < TestCase def self.snippet(name, source) - define_method(:"test_fuzzer_#{name}") { YARP.dump(source) } + define_method(:"test_fuzzer_#{name}") { Prism.dump(source) } end snippet "incomplete global variable", "$" diff --git a/test/prism/heredoc_dedent_test.rb b/test/prism/heredoc_dedent_test.rb index 9d26febc01..1dd7e4d511 100644 --- a/test/prism/heredoc_dedent_test.rb +++ b/test/prism/heredoc_dedent_test.rb @@ -2,13 +2,13 @@ require_relative "test_helper" -module YARP +module Prism class HeredocDedentTest < 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 - node = YARP.parse(heredoc).value.statements.body.first + node = Prism.parse(heredoc).value.statements.body.first if node.is_a? StringNode actual = node.unescaped else diff --git a/test/prism/library_symbols_test.rb b/test/prism/library_symbols_test.rb index 53f56d9bfa..c8eedb0674 100644 --- a/test/prism/library_symbols_test.rb +++ b/test/prism/library_symbols_test.rb @@ -4,9 +4,9 @@ require_relative "test_helper" return if RUBY_PLATFORM !~ /linux/ -module YARP +module Prism # - # examine a yarp dll or static archive for expected external symbols. + # examine a prism dll or static archive for expected external symbols. # these tests only work on a linux system right now. # class LibrarySymbolsTest < TestCase @@ -15,7 +15,7 @@ module YARP @librubyparser_a = File.expand_path("../../build/librubyparser.a", __dir__) @librubyparser_so = File.expand_path("../../build/librubyparser.so", __dir__) - @yarp_so = File.expand_path("../../lib/yarp/yarp.so", __dir__) + @prism_so = File.expand_path("../../lib/prism/prism.so", __dir__) end # objdump runner and helpers @@ -64,12 +64,12 @@ module YARP assert_empty(names(visible_global_objdump_symbols(@librubyparser_a))) end - def test_librubyparser_a_contains_hidden_yp_symbols + def test_librubyparser_a_contains_hidden_pm_symbols omit("librubyparser.a is not built") unless File.exist?(@librubyparser_a) names(hidden_global_objdump_symbols(@librubyparser_a)).tap do |symbols| - assert_includes(symbols, "yp_parse") - assert_includes(symbols, "yp_version") + assert_includes(symbols, "pm_parse") + assert_includes(symbols, "pm_version") end end @@ -80,23 +80,23 @@ module YARP omit("librubyparser.so is not built") unless File.exist?(@librubyparser_so) names(global_nm_symbols(@librubyparser_so)).tap do |symbols| - assert_includes(symbols, "yp_parse") - assert_includes(symbols, "yp_version") + assert_includes(symbols, "pm_parse") + assert_includes(symbols, "pm_version") end names(local_nm_symbols(@librubyparser_so)).tap do |symbols| - assert_includes(symbols, "yp_encoding_shift_jis_isupper_char") + assert_includes(symbols, "pm_encoding_shift_jis_isupper_char") end # TODO: someone who uses this library needs to finish this test end # - # shared object - yarp.so + # shared object - prism.so # - def test_yarp_so_exports_only_the_C_extension_init_function - omit("yarp.so is not built") unless File.exist?(@yarp_so) + def test_prism_so_exports_only_the_C_extension_init_function + omit("prism.so is not built") unless File.exist?(@prism_so) - names(global_nm_symbols(@yarp_so)).tap do |symbols| - assert_equal(["Init_yarp"], symbols) + names(global_nm_symbols(@prism_so)).tap do |symbols| + assert_equal(["Init_prism"], symbols) end end end diff --git a/test/prism/locals_test.rb b/test/prism/locals_test.rb index 45aecdcaf7..06324f9d94 100644 --- a/test/prism/locals_test.rb +++ b/test/prism/locals_test.rb @@ -15,7 +15,7 @@ return if RUBY_PLATFORM =~ /i686/ require_relative "test_helper" -module YARP +module Prism class LocalsTest < TestCase invalid = [] todos = [] @@ -93,7 +93,7 @@ module YARP source = File.read(filepath) expected = Debug.cruby_locals(source) - actual = Debug.yarp_locals(source) + actual = Debug.prism_locals(source) assert_equal(expected, actual) end diff --git a/test/prism/location_test.rb b/test/prism/location_test.rb index a8e9b345a1..b5c108e399 100644 --- a/test/prism/location_test.rb +++ b/test/prism/location_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class LocationTest < TestCase def test_AliasGlobalVariableNode assert_location(AliasGlobalVariableNode, "alias $foo $bar") @@ -839,7 +839,7 @@ module YARP end def test_all_tested - expected = YARP.constants.grep(/.Node$/).sort - %i[MissingNode ProgramNode] + expected = Prism.constants.grep(/.Node$/).sort - %i[MissingNode ProgramNode] actual = LocationTest.instance_methods(false).grep(/.Node$/).map { |name| name[5..].to_sym }.sort assert_equal expected, actual end @@ -847,7 +847,7 @@ module YARP private def assert_location(kind, source, expected = 0...source.length) - result = YARP.parse(source) + result = Prism.parse(source) assert_equal [], result.comments assert_equal [], result.errors diff --git a/test/prism/memsize_test.rb b/test/prism/memsize_test.rb index 07c85ce329..d7e1448dbc 100644 --- a/test/prism/memsize_test.rb +++ b/test/prism/memsize_test.rb @@ -2,9 +2,9 @@ require_relative "test_helper" -return if YARP::BACKEND == :FFI +return if Prism::BACKEND == :FFI -module YARP +module Prism class MemsizeTest < TestCase def test_memsize result = Debug.memsize("2 + 3") diff --git a/test/prism/newline_test.rb b/test/prism/newline_test.rb index 7bf79d46e5..6fd0aee2d5 100644 --- a/test/prism/newline_test.rb +++ b/test/prism/newline_test.rb @@ -4,7 +4,7 @@ require_relative "test_helper" return unless defined?(RubyVM::InstructionSequence) -module YARP +module Prism class NewlineTest < TestCase base = File.dirname(__dir__) Dir["{lib,test}/**/*.rb", base: base].each do |relative| @@ -20,9 +20,9 @@ module YARP source = File.read(filepath, binmode: true, external_encoding: Encoding::UTF_8) expected = rubyvm_lines(source) - result = YARP.parse_file(filepath) + result = Prism.parse_file(filepath) assert_empty result.errors - actual = yarp_lines(result) + actual = prism_lines(result) source.each_line.with_index(1) do |line, line_number| # Lines like `while (foo = bar)` result in two line flags in the @@ -74,7 +74,7 @@ module YARP lines.sort end - def yarp_lines(result) + def prism_lines(result) result.mark_newlines! queue = [result.value] diff --git a/test/prism/parse_serialize_test.rb b/test/prism/parse_serialize_test.rb index 18ff0c4319..001518c14d 100644 --- a/test/prism/parse_serialize_test.rb +++ b/test/prism/parse_serialize_test.rb @@ -2,13 +2,13 @@ require_relative "test_helper" -return if YARP::BACKEND == :FFI +return if Prism::BACKEND == :FFI -module YARP +module Prism class ParseSerializeTest < TestCase def test_parse_serialize dumped = Debug.parse_serialize_file(__FILE__) - result = YARP.load(File.read(__FILE__), dumped) + result = Prism.load(File.read(__FILE__), dumped) assert_kind_of ParseResult, result, "Expected the return value to be a ParseResult" assert_equal __FILE__, find_file_node(result)&.filepath, "Expected the filepath to be set correctly" @@ -19,7 +19,7 @@ module YARP metadata = [filepath.bytesize, filepath.b, 1, 1, 1, "foo".b].pack("LA*LLLA*") dumped = Debug.parse_serialize_file_metadata(filepath, metadata) - result = YARP.load(File.read(__FILE__), dumped) + result = Prism.load(File.read(__FILE__), dumped) assert_kind_of ParseResult, result, "Expected the return value to be a ParseResult" end diff --git a/test/prism/parse_test.rb b/test/prism/parse_test.rb index aa3a76ad7c..8eb87befa0 100644 --- a/test/prism/parse_test.rb +++ b/test/prism/parse_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class ParseTest < TestCase # When we pretty-print the trees to compare against the snapshots, we want to # be certain that we print with the same external encoding. This is because @@ -20,26 +20,26 @@ module YARP end def test_empty_string - result = YARP.parse("") + result = Prism.parse("") assert_equal [], result.value.statements.body end def test_parse_takes_file_path filepath = "filepath.rb" - result = YARP.parse("def foo; __FILE__; end", filepath) + result = Prism.parse("def foo; __FILE__; end", filepath) assert_equal filepath, find_source_file_node(result.value).filepath end def test_parse_lex - node, tokens = YARP.parse_lex("def foo; end").value + node, tokens = Prism.parse_lex("def foo; end").value assert_kind_of ProgramNode, node assert_equal 5, tokens.length end def test_parse_lex_file - node, tokens = YARP.parse_lex_file(__FILE__).value + node, tokens = Prism.parse_lex_file(__FILE__).value assert_kind_of ProgramNode, node refute_empty tokens @@ -85,23 +85,12 @@ module YARP # and explicitly set the external encoding to UTF-8 to override the binmode default. source = File.read(filepath, binmode: true, external_encoding: Encoding::UTF_8) - if ripper_should_parse - src = source - - case relative - when /break|next|redo|if|unless|rescue|control|keywords|retry/ - # Uncaught syntax errors: Invalid break, Invalid next - src = "->do\nrescue\n#{src}\nend" - ripper_should_match = false - end - - # Make sure that it can be correctly parsed by Ripper. If it can't, then we have a fixture - # that is invalid Ruby. - refute_nil(Ripper.sexp_raw(src), "Ripper failed to parse") - end + # Make sure that it can be correctly parsed by Ripper. If it can't, then we have a fixture + # that is invalid Ruby. + refute_nil(Ripper.sexp_raw(source), "Ripper failed to parse") if ripper_should_parse # Next, assert that there were no errors during parsing. - result = YARP.parse(source, relative) + result = Prism.parse(source, relative) assert_empty result.errors # Next, pretty print the source. @@ -128,7 +117,7 @@ module YARP # Next, assert that the value can be serialized and deserialized without # changing the shape of the tree. - assert_equal_nodes(result.value, YARP.load(source, YARP.dump(source, relative)).value) + assert_equal_nodes(result.value, Prism.load(source, Prism.dump(source, relative)).value) # Next, check that the location ranges of each node in the tree are a # superset of their respective child nodes. @@ -142,13 +131,13 @@ module YARP if ripper_should_parse && ripper_should_match # Finally, assert that we can lex the source and get the same tokens as # Ripper. - lex_result = YARP.lex_compat(source) + lex_result = Prism.lex_compat(source) assert_equal [], lex_result.errors tokens = lex_result.value begin - YARP.lex_ripper(source).zip(tokens).each do |(ripper, yarp)| - assert_equal ripper, yarp + Prism.lex_ripper(source).zip(tokens).each do |(ripper, prism)| + assert_equal ripper, prism end rescue SyntaxError raise ArgumentError, "Test file has invalid syntax #{filepath}" @@ -171,10 +160,10 @@ module YARP file_contents.split(/(?<=\S)\n\n(?=\S)/).each do |snippet| snippet = snippet.rstrip - result = YARP.parse(snippet, relative) + result = Prism.parse(snippet, relative) assert_empty result.errors - assert_equal_nodes(result.value, YARP.load(snippet, YARP.dump(snippet, relative)).value) + assert_equal_nodes(result.value, Prism.load(snippet, Prism.dump(snippet, relative)).value) end end end diff --git a/test/prism/pattern_test.rb b/test/prism/pattern_test.rb index d34fe84458..af1efa7560 100644 --- a/test/prism/pattern_test.rb +++ b/test/prism/pattern_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class PatternTest < TestCase def test_invalid_syntax assert_raise(Pattern::CompilationError) { scan("", "<>") } @@ -69,7 +69,7 @@ module YARP end def test_constant_path - results = scan("Foo + Bar + Baz", "YARP::ConstantReadNode") + results = scan("Foo + Bar + Baz", "Prism::ConstantReadNode") assert_equal 3, results.length end @@ -84,7 +84,7 @@ module YARP results = scan("Foo + Bar + Baz", "{ name: /^[[:punct:]]$/ }") assert_equal 2, results.length - assert_equal ["YARP::CallNode"], results.map { |node| node.class.name }.uniq + assert_equal ["Prism::CallNode"], results.map { |node| node.class.name }.uniq end def test_nil @@ -126,7 +126,7 @@ module YARP private def scan(source, query) - YARP::Pattern.new(query).scan(YARP.parse(source).value).to_a + Prism::Pattern.new(query).scan(Prism.parse(source).value).to_a end end end diff --git a/test/prism/regexp_test.rb b/test/prism/regexp_test.rb index 865c70a2c8..67114c7bf3 100644 --- a/test/prism/regexp_test.rb +++ b/test/prism/regexp_test.rb @@ -2,9 +2,9 @@ require_relative "test_helper" -return if YARP::BACKEND == :FFI +return if Prism::BACKEND == :FFI -module YARP +module Prism class RegexpTest < TestCase ############################################################################## # These tests test the actual use case of extracting named capture groups @@ -236,7 +236,7 @@ module YARP def options(flags) options = ["/foo/#{flags}", "/foo\#{1}/#{flags}"].map do |source| - YARP.parse(source).value.statements.body.first.options + Prism.parse(source).value.statements.body.first.options end # Check that we get the same set of options from both regular expressions diff --git a/test/prism/ripper_compat_test.rb b/test/prism/ripper_compat_test.rb index 9fcdfe63c6..af38d1e946 100644 --- a/test/prism/ripper_compat_test.rb +++ b/test/prism/ripper_compat_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class RipperCompatTest < TestCase def test_1_plus_2 assert_equivalent("1 + 2") diff --git a/test/prism/ruby_api_test.rb b/test/prism/ruby_api_test.rb index dc12012f44..a6ce976a85 100644 --- a/test/prism/ruby_api_test.rb +++ b/test/prism/ruby_api_test.rb @@ -2,19 +2,19 @@ require_relative "test_helper" -module YARP +module Prism class RubyAPITest < TestCase def test_ruby_api filepath = __FILE__ source = File.read(filepath, binmode: true, external_encoding: Encoding::UTF_8) - assert_equal YARP.lex(source, filepath).value, YARP.lex_file(filepath).value - assert_equal YARP.dump(source, filepath), YARP.dump_file(filepath) + assert_equal Prism.lex(source, filepath).value, Prism.lex_file(filepath).value + assert_equal Prism.dump(source, filepath), Prism.dump_file(filepath) - serialized = YARP.dump(source, filepath) - ast1 = YARP.load(source, serialized).value - ast2 = YARP.parse(source, filepath).value - ast3 = YARP.parse_file(filepath).value + serialized = Prism.dump(source, filepath) + ast1 = Prism.load(source, serialized).value + ast2 = Prism.parse(source, filepath).value + ast3 = Prism.parse_file(filepath).value assert_equal_nodes ast1, ast2 assert_equal_nodes ast2, ast3 @@ -58,7 +58,7 @@ module YARP private def parse_expression(source) - YARP.parse(source).value.statements.body.first + Prism.parse(source).value.statements.body.first end end end diff --git a/test/prism/test_helper.rb b/test/prism/test_helper.rb index 086b73dd56..a16de14cbe 100644 --- a/test/prism/test_helper.rb +++ b/test/prism/test_helper.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require "yarp" +require "prism" require "ripper" require "pp" require "test/unit" require "tempfile" -puts "Using YARP backend: #{YARP::BACKEND}" if ENV["YARP_FFI_BACKEND"] +puts "Using prism backend: #{Prism::BACKEND}" if ENV["PRISM_FFI_BACKEND"] # It is useful to have a diff even if the strings to compare are big # However, ruby/ruby does not have a version of Test::Unit with access to @@ -15,7 +15,7 @@ if defined?(Test::Unit::Assertions::AssertionMessage) Test::Unit::Assertions::AssertionMessage.max_diff_target_string_size = 5000 end -module YARP +module Prism class TestCase < ::Test::Unit::TestCase private diff --git a/test/prism/unescape_test.rb b/test/prism/unescape_test.rb index a7d955b315..c2129051ec 100644 --- a/test/prism/unescape_test.rb +++ b/test/prism/unescape_test.rb @@ -2,9 +2,9 @@ require_relative "test_helper" -return if YARP::BACKEND == :FFI +return if Prism::BACKEND == :FFI -module YARP +module Prism class UnescapeNoneTest < TestCase def test_backslash assert_unescape_none("\\") diff --git a/test/prism/version_test.rb b/test/prism/version_test.rb index 6011eb695d..29ee6b224c 100644 --- a/test/prism/version_test.rb +++ b/test/prism/version_test.rb @@ -2,7 +2,7 @@ require_relative "test_helper" -module YARP +module Prism class VersionTest < TestCase def test_version_is_set refute_nil VERSION |