test(transforms): Refactor tensor ops#261
Conversation
192b742 to
76f158f
Compare
|
@besaleli the linter growls: https://github.com/mozilla-ai/encoderfile/actions/runs/21724072599/job/62661358316?pr=261 |
sure why not @javiermtorres |
besaleli
left a comment
There was a problem hiding this comment.
one formatting thing, otherwise looks beautiful!
| Ok(Tensor(new)) | ||
| } | ||
|
|
||
| #[cfg(test)] |
There was a problem hiding this comment.
put these all in a mod tests {}
There was a problem hiding this comment.
then, write #[test] as decorator of each test function
There was a problem hiding this comment.
Macros already use the test tag, defined with the same name but on a different module (after grouping into tests as suggested). For example, cargo test test_tensor results in these tests being run:
TowoMoz:156-partition-tests ⇒ cargo test test_tensor
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.69s
Running unittests src/lib.rs (target/debug/deps/encoderfile-58a353167a97c36b)
running 8 tests
test transforms::engine::tests::test_tensor_function_is_only_safe_binding ... ok
test transforms::tensor::ops::arithm::tests::test_multiplication::test_tensor ... ok
test transforms::tensor::ops::arithm::tests::test_subtraction::test_tensor ... ok
test transforms::tensor::ops::arithm::tests::test_addition::test_tensor ... ok
test transforms::tensor::ops::arithm::tests::test_division::test_tensor ... ok
test transforms::engine::tests::test_tensor_return_type ... ok
test transforms::engine::tests::test_tensor_methods_chain_twice ... ok
test transforms::engine::tests::test_tensor_metatable_preserved ... ok
But maybe you'd prefer some other organization, like adding the op name into the test name instead of making specific modules.
BTW, maybe I could factor out the broadcast tests using a table of values, as well. Not really necessary, but compacts things a bit. Wdyt?
| } | ||
| } | ||
|
|
||
| #[test] |
|
BTW, I think I didn't group into |
2dc5c7d to
d8b4924
Compare
Each operation or group of operations has been separated into its own file, including its tests. If these files again grow too much, further refinement can be done.
Closes #156