aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-12-24 21:14:02 +0100
committerXavier Noria <fxn@hashref.com>2012-12-24 21:16:16 +0100
commit26c024e95999e545fbef85a25165234af77ea605 (patch)
treed882bcb5d56b1873be7da4ee84e7dc7f2dbb450d /activesupport/test
parentef5d85709d346e55827e88f53430a2cbe1e5fb9e (diff)
downloadrails-26c024e95999e545fbef85a25165234af77ea605.tar.gz
rails-26c024e95999e545fbef85a25165234af77ea605.tar.bz2
rails-26c024e95999e545fbef85a25165234af77ea605.zip
silences "possibly useless use of :: in void context" warnings
The AS utility silence_warnings does not really silence this one, because it is issued at parse-time. It seemed to in some places because the constant was the only expression in the block and therefore it was its return value, that could potentially be used by silence_warnings are return value of the yield call. To bypass the warning we assign to a variable. The chosen variable is "_" because it is special-cased in parse.c not to issue an "assigned but unused variable" warning in turn.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/dependencies_test.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb
index 51a7e4b2fe..9d913c27b0 100644
--- a/activesupport/test/dependencies_test.rb
+++ b/activesupport/test/dependencies_test.rb
@@ -923,10 +923,8 @@ class DependenciesTest < ActiveSupport::TestCase
def test_remove_constant_does_not_autoload_already_removed_parents_as_a_side_effect
with_autoloading_fixtures do
- silence_warnings do
- ::A
- ::A::B
- end
+ _ = ::A # assignment to silence parse-time warning "possibly useless use of :: in void context"
+ _ = ::A::B # assignment to silence parse-time warning "possibly useless use of :: in void context"
ActiveSupport::Dependencies.remove_constant('A')
ActiveSupport::Dependencies.remove_constant('A::B')
assert !defined?(A)
@@ -936,9 +934,7 @@ class DependenciesTest < ActiveSupport::TestCase
def test_load_once_constants_should_not_be_unloaded
with_autoloading_fixtures do
ActiveSupport::Dependencies.autoload_once_paths = ActiveSupport::Dependencies.autoload_paths
- silence_warnings do
- ::A
- end
+ _ = ::A # assignment to silence parse-time warning "possibly useless use of :: in void context"
assert defined?(A)
ActiveSupport::Dependencies.clear
assert defined?(A)