summaryrefslogtreecommitdiff
path: root/test/did_you_mean
diff options
context:
space:
mode:
authorYuki Nishijima <yk.nishijima@gmail.com>2021-12-21 22:09:33 +0900
committerYuki Nishijima <yk.nishijima@gmail.com>2021-12-21 22:10:03 +0900
commitcdb7d699d0641e8f081d590d06d07887ac09961f (patch)
tree0c3db45b8511c5d0815e0ddd5d549fc720fccd50 /test/did_you_mean
parent4560091b1c99ab33db0d653b9dd2d977fe4676d5 (diff)
downloadruby-cdb7d699d0641e8f081d590d06d07887ac09961f.tar.gz
Revert commits for did_you_mean
This reverts commit 4560091b1c99ab33db0d653b9dd2d977fe4676d5. This reverts commit a6f76122a2395bd914daa0aa04fb5a6ce4e0c045. This reverts commit e59b18a6379c55f15ccda85c27d6997d44ef5293. This reverts commit 505dfae05d56d844ea150676edb87850a406d071.
Diffstat (limited to 'test/did_you_mean')
-rw-r--r--test/did_you_mean/core_ext/test_name_error_extension.rb7
-rw-r--r--test/did_you_mean/helper.rb4
-rw-r--r--test/did_you_mean/test_ractor_compatibility.rb102
3 files changed, 3 insertions, 110 deletions
diff --git a/test/did_you_mean/core_ext/test_name_error_extension.rb b/test/did_you_mean/core_ext/test_name_error_extension.rb
index 91871cda9a..9dc08dbde3 100644
--- a/test/did_you_mean/core_ext/test_name_error_extension.rb
+++ b/test/did_you_mean/core_ext/test_name_error_extension.rb
@@ -1,7 +1,7 @@
require_relative '../helper'
class NameErrorExtensionTest < Test::Unit::TestCase
- SPELL_CHECKERS = DidYouMean.spell_checkers
+ SPELL_CHECKERS = DidYouMean::SPELL_CHECKERS
class TestSpellChecker
def initialize(*); end
@@ -9,14 +9,13 @@ class NameErrorExtensionTest < Test::Unit::TestCase
end
def setup
- @original_spell_checker = DidYouMean.spell_checkers['NameError']
- DidYouMean.correct_error(NameError, TestSpellChecker)
+ @org, SPELL_CHECKERS['NameError'] = SPELL_CHECKERS['NameError'], TestSpellChecker
@error = assert_raise(NameError){ doesnt_exist }
end
def teardown
- DidYouMean.correct_error(NameError, @original_spell_checker)
+ SPELL_CHECKERS['NameError'] = @org
end
def test_message
diff --git a/test/did_you_mean/helper.rb b/test/did_you_mean/helper.rb
index 7cb7b10282..d8aa41c3d1 100644
--- a/test/did_you_mean/helper.rb
+++ b/test/did_you_mean/helper.rb
@@ -4,10 +4,6 @@ module DidYouMean
module TestHelper
class << self
attr_reader :root
-
- def ractor_compatible?
- defined?(Ractor) && RUBY_VERSION >= "3.1.0"
- end
end
if File.file?(File.expand_path('../lib/did_you_mean.rb', __dir__))
diff --git a/test/did_you_mean/test_ractor_compatibility.rb b/test/did_you_mean/test_ractor_compatibility.rb
deleted file mode 100644
index 1a9e63997f..0000000000
--- a/test/did_you_mean/test_ractor_compatibility.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-require_relative './helper'
-
-return if not DidYouMean::TestHelper.ractor_compatible?
-
-class RactorCompatibilityTest < Test::Unit::TestCase
- include DidYouMean::TestHelper
-
- class ::Book; end
- class FirstNameError < NameError; end
-
- def test_class_name_suggestion_works_in_ractor
- error = Ractor.new {
- begin
- Boook
- rescue NameError => e
- e.corrections # It is important to call the #corrections method within Ractor.
- e
- end
- }.take
-
- assert_correction "Book", error.corrections
- end
-
- def test_key_name_suggestion_works_in_ractor
- error = Ractor.new {
- begin
- hash = { "foo" => 1, bar: 2 }
-
- hash.fetch(:bax)
- rescue KeyError => e
- e.corrections # It is important to call the #corrections method within Ractor.
- e
- end
- }.take
-
- assert_correction ":bar", error.corrections
- assert_match "Did you mean? :bar", error.to_s
- end
-
- def test_method_name_suggestion_works_in_ractor
- error = Ractor.new {
- begin
- self.to__s
- rescue NoMethodError => e
- e.corrections # It is important to call the #corrections method within Ractor.
- e
- end
- }.take
-
- assert_correction :to_s, error.corrections
- assert_match "Did you mean? to_s", error.to_s
- end
-
- if defined?(::NoMatchingPatternKeyError)
- def test_pattern_key_name_suggestion_works_in_ractor
- error = Ractor.new {
- begin
- eval(<<~RUBY, binding, __FILE__, __LINE__)
- hash = {foo: 1, bar: 2, baz: 3}
- hash => {fooo:}
- fooo = 1 # suppress "unused variable: fooo" warning
- RUBY
- rescue NoMatchingPatternKeyError => e
- e.corrections # It is important to call the #corrections method within Ractor.
- e
- end
- }.take
-
- assert_correction ":foo", error.corrections
- assert_match "Did you mean? :foo", error.to_s
- end
- end
-
- def test_can_raise_other_name_error_in_ractor
- error = Ractor.new {
- begin
- raise FirstNameError, "Other name error"
- rescue FirstNameError => e
- e.corrections # It is important to call the #corrections method within Ractor.
- e
- end
- }.take
-
- assert_not_match(/Did you mean\?/, error.message)
- end
-
- def test_variable_name_suggestion_works_in_ractor
- error = Ractor.new {
- in_ractor = in_ractor = 1
-
- begin
- in_reactor
- rescue NameError => e
- e.corrections # It is important to call the #corrections method within Ractor.
- e
- end
- }.take
-
- assert_correction :in_ractor, error.corrections
- assert_match "Did you mean? in_ractor", error.to_s
- end
-end