google / google/xls

[enhancement] Add possibility to parameterize tests

Open
#1,583 1 comment 0 reactions 0 assignees View on GitHub
dslx enhancement testing
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

### What's hard to do? (limit 100 words)

When writing tests it is not possible to create different cases using test parameterization. It would be helpful to be able to write tests that reuse logic and differ in some values.

### Current best alternative workaround (limit 100 words)

The user has to use `for` loop in test proc's `next` or create multiple test procs.

### Your view of the "best case XLS enhancement" (limit 100 words)

The test parameters should be defined using attributes and passed to the test. The test is ran separately using each value.

1. Similar attributes as in [rstest](https://crates.io/crates/rstest), params are passed to `next`
```rust
#[test_proc]
#[case(u32:0, u32:3, ...)]
#[case(u32:1, u32:4, ...)]
#[case(u32:2, u32:5, ...)]
proc PassthroughTest {
...

next (state: (), param_a: u32, param_b: u32, ...) {
...
}
}
```
2. As above, but params are used similarly as in parameterized procs (this would allow spawning parameterized procs using those test params)
```rust
#[test_proc]
#[case(u32:0, u32:3, ...)]
#[case(u32:1, u32:4, ...)]
#[case(u32:2, u32:5, ...)]
proc PassthroughTest {
...
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.