gedaiu / fluent-asserts

DLang fluent assertions done right
http://fluentasserts.szabobogdan.com/
MIT License
43 stars 6 forks source link

throwException!T.original returns different Type in 0.14 alpha #97

Closed skruppy closed 3 years ago

skruppy commented 3 years ago

The following example compiles and behaves as expected in Version 0.13.0 but fails to compile with 0.14.0-alpha.8 (return type of original is Expect, not the expected SomeException)

import std.stdio;
import fluent.asserts;

void main() {
    writeln("Edit source/app.d to start your project.");
}

class SomeException : Exception {
    this(string msg, string file = __FILE__, size_t line = __LINE__) {
        super(msg, file, line);
    }
}

unittest {
    SomeException ex = ({throw new SomeException("msg");}).should.throwException!SomeException.original;
}
gedaiu commented 3 years ago

does thrown works for you?

unittest {
    Throwable ex = ({throw new SomeException("msg");}).should.throwException!SomeException.thrown;
}
skruppy commented 3 years ago

Kind of. I actually need the correct type, which is not a big problem since I can simply use thrown and cast(SomeException). This is my current workaround. But I guess it's a regression bug.

Things I don't understand:

gedaiu commented 3 years ago

I had to change the library structs to have a more modern interface like chai from js. This helps on allowing other devs to bind their custom checks to the lib. If you want to check the latest work please have a look at the master branch.

If you really need the prev behavior i’ll need to see how can I do this without adding more templates… because I also aim to improve the compilation speed with this new version.

Unfortunately the docs are outdated. I did not have much time to focus on this project and the current version is still an alpha. I’ll make a beta release once I can get some focus time on it.

skruppy commented 3 years ago

Oh OK. The API change is then probably what confused me then. Since there is a workaround and this change was intended and hence not a regression, I'll close this issue (even if original was convenient :wink:).

Maybe it's a good idea to mark original or ThrowableProxy some day with deprecated("Hint to new API").

Thanks for all your great work :heart: