svunit / svmock

A mock framework for use with SVUnit
Apache License 2.0
15 stars 4 forks source link

Defining parameterized mocks isn't possible anymore #15

Open tudortimi opened 5 years ago

tudortimi commented 5 years ago
`SVMOCK(the_mock #(type T), the_class #(T))
tudortimi commented 5 years ago

This used to work in the past, but the name of the mock is now concatenated to create a define. I'm not sure what this define is used for.

nosnhojn commented 5 years ago

There's a great reason for this. but for the life of me I can't remember what that is. I think it has something to do with needing to use the name of the class under the hood to be able to specialize arguments and method names so that there was no overlap (i.e. name conflicts) between mocks.

I'm looking through the code now thinking I had a half-hack to get avoid this being a dead-stop but I can't see it...

tudortimi commented 5 years ago

I think the concatenated define is there to be able to decide in the mocker expansions if you want to call super.(...).

tudortimi commented 5 years ago

What's the use case for mocks without any parent class? The only thing I can think of is when you want to test a class that takes a type parameter, where you pass the mock type as the parameter value.

tudortimi commented 4 years ago

I think I know how to solve this now. If we don't want a parent, we can use a dummy class as a parent. This dummy class would be defined in svmock. This dummy class would be the default parameter of the `SVMOCK macro.

tudortimi commented 1 year ago

Another idea using the pre-processor: https://stackoverflow.com/a/77293308/1334062

This is a good trick to keep in mind.