-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incorporate filepeek #20
Comments
Wow, I am sensing a lot of trouble and errors that are difficult to understand for users here. Maybe I am mistaken, but this would almost certainly lead to tests that work in one place and suddenly fail in another. Even if we provided the most helpful of failure messages, I fear that the trouble for users is not justified by the convenience gain. By the way: Even though I have read through robstoll/atrium#40, I still don’t understand why we cannot provide methods Edit: To be more precise, I am suggesting something like: fun <T, R> Expect<T>.property(provider: T.() -> KProperty0<R>): Expect<R> =
feature { p(provider(it)) } The way I imagine it, we could then write: expect(Person(...))
.property { ::name }
.toBe("robert") Which is almost as good as your example, but without Voodoo. I think it solves the ambiguity issues as well as the current solution. What am I missing? |
Could you please elaborate in case you are not talking about IO errors?
There is an easy answer to this, Kotlin's type inference algorithm is not good enough. It cannot distinguish lambdas based on their return type. See the many bugs I created and listed on Atrium's README concerning type inference and overload resolution ambiguities. I hope this will get better. As soon as it gets better I would improve the syntax. Regarding your imaginations, that's more or less what I planed to do if Kotlin were better. So please upvote all issues regarding type inference and overload resolution ambiguities here https://github.com/robstoll/atrium#kotlin-bugs as well as the following https://youtrack.jetbrains.com/issue/KT-22920 (would allow to write |
Another approach to allow Edit I had a quick glance at compiler plugins, they could modify code, however, as it seems there is quite a bit of overhead involved and it would require an own gradle plugin => looking at https://github.com/robstoll/atrium/wiki/Requirements#r101-little-custom-build-logic this is probably not what we want |
Maybe my understanding of your proposed approach is bad. But I understand that you want to access the source code in order to understand “what the user means” at runtime. As you have said, filepeek would rely on the sources being available at runtime. And I feel like this could be a major problem: The tests run successfully, then they are run differently, such that accessing the source code is not possible, and suddentl stop working.
That only means that my proposed approach would fail to compile in some cases, right? It would still be useful to have it for the simple cases, would it not? For example, with expect("testString")
.property { ::length }
.isGreaterThan(3) I do not get code completion after What I am trying to achive here is getting the syntax as good as possible, even if it is just for common and not for all cases, without needing to resort to complicated solutions. I see that things get a lot complicater with functions and that most code would not compile due to resolution ambiguity. But can we at least add the
How likely do you think it that the Kotlin bugs standing in our way will get fixed in the near future? Because if can avoid writing a compiler plugin, maybe we should avoid it. |
It's perfectly fine and I share your concerns as outlined above because IO opertions seem not to be a good fit for testing IMO. However, I was in contact with Christoph Sturm, the author of filepeek and asked him what experiences he made and he said so far it was good. That is why I am considering it again. One thing I tried to simplify with We wouldn't need to build a IntelliJ plugin as we only inspect code and transform it. For instance, we would expand |
I think we can give it a shot if we make sure that it a) does still supports autocomplete I still doubt that the improvement is worth the effort. Even though the current
Counter argument: If |
Good, I suggest we wait with filepeek until it supports JS, then we can reassess.
Personally I am not sure at all, the issue was created 2 years ago and has still no target version. So most likely it will make it into 1.4.x but not earlier. If I find time I will look into a compiler plugin but I am with you that this is not really a high prio issue. |
so that we can write:
instead of
feature { f(it::name) }
however, it works currently only for JVM.
Thus, either we wait until its implemented for JS or we provide this feature only for JVM.
Moreover, it can currently not deal with the case that the test source is not available. I don't want that tests fail due to this.
The text was updated successfully, but these errors were encountered: