Skip to content

chore: reduce boilerplate code #582

@stuarttimwhite

Description

@stuarttimwhite

Background and Motivation

There are some places within our test code where there is syntactically inefficient code. Here are two examples:

  1. Initializing a Vec<TestScalar> with
    vec![TestScalar::from(1), TestScalar::from(2), ...], instead of
    [1, 2, ...].map(TestScalar::from).into_iter().collect() or something similar.
    Sometimes these vecs should be used as slices anyway, in which case the iter and collect steps aren't necessary.
  2. Some files will have several very similar tests with only little variation but have no centralization of the common functionality. For example, look at the tests in /src/base/database/table_test_accessor_test.rs. Each test starts with a very similar setup. That could be centralized in one utility function.

It would be very nice to reduce this unnecessary boilerplate code.

Changes Required

Reduction in unnecessary extra boilerplate code. This doesn't have to be restricted to test code, but that tends to be the area with a lot of unnecessary extra code. No need to restrict yourself to the two examples above. We generally like to keep macros out of our code base, but we'll consider it if you want to use a macro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions