[ruby/prism] Remove warnings check from parse_success? method

https://github.com/ruby/prism/commit/e30a241fb3
This commit is contained in:
Kevin Newton 2023-12-07 09:34:16 -05:00 committed by git
parent 8e86a4347e
commit 10bc0bd4ab
3 changed files with 8 additions and 12 deletions

View File

@ -68,7 +68,7 @@ module Prism
# :call-seq: # :call-seq:
# Prism::parse_failure?(source, **options) -> bool # Prism::parse_failure?(source, **options) -> bool
# #
# Returns true if the source is invalid Ruby code. # Returns true if the source parses with errors.
def self.parse_failure?(source, **options) def self.parse_failure?(source, **options)
!parse_success?(source, **options) !parse_success?(source, **options)
end end
@ -76,7 +76,7 @@ module Prism
# :call-seq: # :call-seq:
# Prism::parse_file_failure?(filepath, **options) -> bool # Prism::parse_file_failure?(filepath, **options) -> bool
# #
# Returns true if the file at filepath is invalid Ruby code. # Returns true if the file at filepath parses with errors.
def self.parse_file_failure?(filepath, **options) def self.parse_file_failure?(filepath, **options)
!parse_file_success?(filepath, **options) !parse_file_success?(filepath, **options)
end end

View File

@ -799,8 +799,7 @@ parse_lex_file(int argc, VALUE *argv, VALUE self) {
} }
/** /**
* Parse the given input and return true if it parses without errors or * Parse the given input and return true if it parses without errors.
* warnings.
*/ */
static VALUE static VALUE
parse_input_success_p(pm_string_t *input, const pm_options_t *options) { parse_input_success_p(pm_string_t *input, const pm_options_t *options) {
@ -810,7 +809,7 @@ parse_input_success_p(pm_string_t *input, const pm_options_t *options) {
pm_node_t *node = pm_parse(&parser); pm_node_t *node = pm_parse(&parser);
pm_node_destroy(&parser, node); pm_node_destroy(&parser, node);
VALUE result = parser.error_list.size == 0 && parser.warning_list.size == 0 ? Qtrue : Qfalse; VALUE result = parser.error_list.size == 0 ? Qtrue : Qfalse;
pm_parser_free(&parser); pm_parser_free(&parser);
return result; return result;
@ -820,8 +819,8 @@ parse_input_success_p(pm_string_t *input, const pm_options_t *options) {
* call-seq: * call-seq:
* Prism::parse_success?(source, **options) -> Array * Prism::parse_success?(source, **options) -> Array
* *
* Parse the given string and return true if it parses without errors or * Parse the given string and return true if it parses without errors. For
* warnings. For supported options, see Prism::parse. * supported options, see Prism::parse.
*/ */
static VALUE static VALUE
parse_success_p(int argc, VALUE *argv, VALUE self) { parse_success_p(int argc, VALUE *argv, VALUE self) {
@ -840,8 +839,8 @@ parse_success_p(int argc, VALUE *argv, VALUE self) {
* call-seq: * call-seq:
* Prism::parse_file_success?(filepath, **options) -> Array * Prism::parse_file_success?(filepath, **options) -> Array
* *
* Parse the given file and return true if it parses without errors or warnings. * Parse the given file and return true if it parses without errors. For
* For supported options, see Prism::parse. * supported options, see Prism::parse.
*/ */
static VALUE static VALUE
parse_file_success_p(int argc, VALUE *argv, VALUE self) { parse_file_success_p(int argc, VALUE *argv, VALUE self) {

View File

@ -23,9 +23,6 @@ module Prism
def test_parse_success? def test_parse_success?
assert Prism.parse_success?("1") assert Prism.parse_success?("1")
refute Prism.parse_success?("<>") refute Prism.parse_success?("<>")
assert Prism.parse_success?("m //", verbose: false)
refute Prism.parse_success?("m //", verbose: true)
end end
def test_parse_file_success? def test_parse_file_success?