mojo
mojo copied to clipboard
`TestSuite` not overloaded for basic types like Int
Bug Description
There is a compiler error when using the TestSuite
on Int
values. Consider the following code snippet
from Testing import TestSuite
let x: Int = 42
let y: Int = 42
let ts = TestSuite("testing")
ts.assertEqual(x, y)
When run on the Mojo playground I get the following error:
error: Expression [31]:22:19: invalid call to 'assertEqual': callee expects 2 input parameters but 0 were provided
ts.assertEqual(x, y)
~~~~~~~~~~~~~~^~~~~~
/.modular/Kernels/mojo/Stdlib/Testing.mojo:81:5: function declared here
fn assertEqual[
^
Steps to Reproduce
- Run the above code snippet
- Observe the error
Additional notes
The above code snippet also doesn't work for assertAlmostEqual
. Also, as notied in the discord the code snippet below does work:
let x: SI32 = 42
let y: SI32 = 42
let ts = TestSuite("testing")
print(ts.assertEqual(x, y))
Thanks for the issue! This doesn't seem to be a bug -- rather the API for TestSuite only seems to be providing overloads for the SIMD
type. @abduld FYI
Oh right, I probably should have noticed that in the declaration... I guess I expect it to work with any type that defines some form of mojo equivalent operator==
. Perhaps a parameterized version can be added later to accommodate for that?
Thanks