Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

Commit f608b70

Browse files
committed
Don't use error-prone hardcoded syms.
1 parent 449b875 commit f608b70

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/test_cache_loops.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ def test_concurrency
3838
cache[key]
3939
cache.delete(key)
4040
RUBY_EVAL
41-
do_thread_loop(:concurrency, code)
41+
do_thread_loop(__method__, code)
4242
end
4343

4444
def test_put_if_absent
45-
do_thread_loop(:put_if_absent, 'acc += 1 unless cache.put_if_absent(key, key)', :key_count => 100_000) do |result, cache, options, keys|
45+
do_thread_loop(__method__, 'acc += 1 unless cache.put_if_absent(key, key)', :key_count => 100_000) do |result, cache, options, keys|
4646
assert_standard_accumulator_test_result(result, cache, options, keys)
4747
end
4848
end
4949

5050
def test_compute_if_absent
5151
code = 'cache.compute_if_absent(key) { acc += 1; key }'
52-
do_thread_loop(:compute_if_absent, code) do |result, cache, options, keys|
52+
do_thread_loop(__method__, code) do |result, cache, options, keys|
5353
assert_standard_accumulator_test_result(result, cache, options, keys)
5454
end
5555
end
@@ -62,7 +62,7 @@ def test_compute_put_if_absent
6262
acc += 1 unless cache.put_if_absent(key, key)
6363
end
6464
RUBY_EVAL
65-
do_thread_loop(:compute_put_if_absent, code) do |result, cache, options, keys|
65+
do_thread_loop(__method__, code) do |result, cache, options, keys|
6666
assert_standard_accumulator_test_result(result, cache, options, keys)
6767
end
6868
end
@@ -133,7 +133,7 @@ def test_count_race
133133
v = cache[key]
134134
acc += change if cache.replace_pair(key, v, v + change)
135135
RUBY_EVAL
136-
do_thread_loop(:count_race, code, :loop_count => 5, :prelude => prelude, :cache_setup => ZERO_VALUE_CACHE_SETUP) do |result, cache, options, keys|
136+
do_thread_loop(__method__, code, :loop_count => 5, :prelude => prelude, :cache_setup => ZERO_VALUE_CACHE_SETUP) do |result, cache, options, keys|
137137
result_sum = sum(result)
138138
assert_equal(sum(keys.map {|key| cache[key]}), result_sum)
139139
assert_equal(sum(cache.values), result_sum)
@@ -143,14 +143,14 @@ def test_count_race
143143

144144
def test_get_and_set_new
145145
code = 'acc += 1 unless cache.get_and_set(key, key)'
146-
do_thread_loop(:get_and_set_new, code) do |result, cache, options, keys|
146+
do_thread_loop(__method__, code) do |result, cache, options, keys|
147147
assert_standard_accumulator_test_result(result, cache, options, keys)
148148
end
149149
end
150150

151151
def test_get_and_set_existing
152152
code = 'acc += 1 if cache.get_and_set(key, key) == -1'
153-
do_thread_loop(:get_and_set_existing, code, :cache_setup => INITIAL_VALUE_CACHE_SETUP, :initial_value => -1) do |result, cache, options, keys|
153+
do_thread_loop(__method__, code, :cache_setup => INITIAL_VALUE_CACHE_SETUP, :initial_value => -1) do |result, cache, options, keys|
154154
assert_standard_accumulator_test_result(result, cache, options, keys)
155155
end
156156
end
@@ -260,7 +260,7 @@ def count_up_via_compute(opts = {})
260260
old_value ? old_value + 1 : 1
261261
end
262262
RUBY_EVAL
263-
do_thread_loop(:count_up_via_compute, code, {:loop_count => 5}.merge(opts)) do |result, cache, options, keys|
263+
do_thread_loop(__method__, code, {:loop_count => 5}.merge(opts)) do |result, cache, options, keys|
264264
assert_count_up(result, cache, options, keys)
265265
result.inject(nil) do |previous_value, next_value| # since compute guarantees atomicity all count ups should be equal
266266
assert_equal previous_value, next_value if previous_value
@@ -273,7 +273,7 @@ def count_up_via_merge_pair(opts = {})
273273
code = <<-RUBY_EVAL
274274
cache.merge_pair(key, 1) {|old_value| old_value + 1}
275275
RUBY_EVAL
276-
do_thread_loop(:count_up_via_merge_pair, code, {:loop_count => 5}.merge(opts)) do |result, cache, options, keys|
276+
do_thread_loop(__method__, code, {:loop_count => 5}.merge(opts)) do |result, cache, options, keys|
277277
all_match = true
278278
expected_value = options[:loop_count] * options[:thread_count]
279279
keys.each do |key|
@@ -291,7 +291,7 @@ def add_remove_to_zero(opts = {})
291291
acc += 1 unless cache.put_if_absent(key, key)
292292
acc -= 1 if cache.delete_pair(key, key)
293293
RUBY_EVAL
294-
do_thread_loop(:add_remove_to_zero, code, {:loop_count => 5}.merge(opts)) do |result, cache, options, keys|
294+
do_thread_loop(__method__, code, {:loop_count => 5}.merge(opts)) do |result, cache, options, keys|
295295
assert_all_key_mappings_exist(cache, keys, false)
296296
assert_equal(cache.size, sum(result))
297297
end
@@ -301,7 +301,7 @@ def add_remove_to_zero_via_merge_pair(opts = {})
301301
code = <<-RUBY_EVAL
302302
acc += (cache.merge_pair(key, key) {}) ? 1 : -1
303303
RUBY_EVAL
304-
do_thread_loop(:add_remove_to_zero_via_merge_pair, code, {:loop_count => 5}.merge(opts)) do |result, cache, options, keys|
304+
do_thread_loop(__method__, code, {:loop_count => 5}.merge(opts)) do |result, cache, options, keys|
305305
assert_all_key_mappings_exist(cache, keys, false)
306306
assert_equal(cache.size, sum(result))
307307
end

0 commit comments

Comments
 (0)