Skip to content

Commit

Permalink
Refactor use of data in test-unit
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Mar 20, 2024
1 parent 9ab5d47 commit 986a570
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 1 addition & 3 deletions test/core/test_library_loading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ def test_naming_convention_for_bundler
compilable_paths = Dir.glob('lib/**/*.rb')
raise unless compilable_paths.size >= 5

compilable_paths.each do |path|
data(path, path)
end
data(compilable_paths.to_h { |path| [path, path] })
def test_vm_compilable(path)
assert_instance_of(String, RubyVM::InstructionSequence.compile_file(path).to_binary)
end
Expand Down
4 changes: 1 addition & 3 deletions test/core/test_ractor_shareable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def test_instances_are_can_be_shareable
const_name_to_value = ULID.constants.to_h { |const_name| [const_name, ULID.const_get(const_name)] }
raise unless const_name_to_value.size >= 10

const_name_to_value.each_pair do |name, value|
data(name.to_s, value)
end
data(const_name_to_value)
def test_shareable_constants(const_value)
assert_true(Ractor.shareable?(const_value))

Expand Down
4 changes: 1 addition & 3 deletions test/core/test_ulid_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,7 @@ def test_freeze
assert_same(ulid, ulid.freeze)
end

ULID_RETURNING_METHODS.each do |method_name|
data("ULID##{method_name}", method_name)
end
data(ULID_RETURNING_METHODS.to_h { |method_name| ["ULID##{method_name}", method_name] })
def test_all_returned_ulids_are_frozen(method_name)
assert_true(ULID.sample.public_send(method_name).frozen?)
end
Expand Down

0 comments on commit 986a570

Please sign in to comment.