Comments (8)
I had this same thought. I quite like it. We should see how well the AST stuff works (see #24) as this might make it easy.
from is.
see the new PR #25
included are the var names and also your proposal with the variable src (for NoErr)
see is_test.go:170 or this testcase with the error source example.
I am currentley not happy with the print output. There are a lot of information (file, line, var name, var value, var type, comment, err src) in just one line. Maybe there is a better way to format the otput.
Anyhow the AST stuff makes fun and is simpliar than I thout.
from is.
Will check that out in a new experimental branch.
from is.
Thanks @v-braun.
While you're there, I wonder how easy it might be to detect where a variable came from, or more specifically where it was last assigned to.
How cool would it be if you would write this:
err := something()
is.NoErr(err)
And get a failure that said:
err: some error // from: something()
from is.
i have built something simmiliar! will push it later.
not exactley your example but is also nice:
is.NoErr(errors.New("BANG!"))
will end in:
err: errors.New("BANG!")
That is for sure not exactley your example but also very helpfull.
I think the other case is also solvable through AST but is much more complex.
So in theory I have the error ast.Node and have only to search the entire AST again for a declaration/assignment to this ast.Node.
from is.
@v-braun This is very cool but I'm not sure the complexity is worth it just yet. I'll review the code more. But I had a thought. Maybe it shouldn't show the code if there is a comment? In theory, if you put a comment, that's what you care about isn't it?
from is.
I agree with @matryer, while it is a neat idea this problem can already be solved with a debugger. You know where the test went wrong, put a breakpoint on the function under test and you can inspect each step.
from is.
Closing for now, thanks all.
from is.
Related Issues (20)
- Additional error assertations HOT 8
- flag.Parse in init() prevents own flags in tests HOT 7
- -nocolor flag not supported by Go Test in go-1.11.4 HOT 4
- Lines should be escaped before printing
- Add a Contains method HOT 3
- My editor thinks this is bad practice HOT 4
- New Release? HOT 1
- Proposal: is.Less and is.Greater HOT 2
- Ditch the indentation? HOT 1
- Small simplification
- Potential issue when running go test -json HOT 4
- Is the project still alive? HOT 5
- Proposal: value matcher interface in is.Equal HOT 2
- Release v1.5.0 HOT 2
- Proposal: Use generics to add type safety support to is.Equal HOT 10
- Revisiting `is.Equal` and the role of `reflect.DeepEqual` HOT 11
- gofmt all the things
- Issue equating zero `big.{Int,Float}`'s HOT 2
- Proposal: custom stacktrace HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from is.