Skip to content
This repository

Improved error reporting in ExUnit #265

Closed
josevalim opened this Issue · 9 comments

5 participants

José Valim Rafael Mendonça França Alexei Sholik Dickson S. Guedes Yurii Rashkovskii
José Valim
Owner

We can make the assert macro even smarter than what it is today. For example, the following scenario:

assert List.member?(some_list(), 3 + 5)

When failing, could show the following error message:

Expected true got false
  assert List.member?(some_list(), 3 + 5)
      some_list() #=> [1,2,3]
      3 + 5 #=> 8

By showing the line that failed and breaking apart each argument, we can see exactly why it fails, even if the error message was not good enough.

The first step to implement this feature is the ability to print trees. Since the macro receives a tree, for example { :+, 1, [1,2] }, we need to be able to convert this tree to a string. For example:

Macro.to_binary({ :+, 1, [1,2] }) #=> "1 + 2"
Rafael Mendonça França

Cool. I can try to implement tomorrow if you want.

Alexei Sholik
alco commented

Don't forget the line numbers too!

Dickson S. Guedes

@rafaelfranca did you start this?

José Valim
Owner

I don't think he did. What is implemented for sure though is Macro.to_binary.

José Valim
Owner

I am closing this since it is open for some time now. It is still a desired feature and whoever is interested please go ahead!

Yurii Rashkovskii

Is it a good idea to close an issue if you want to find somebody interested to do it? :-1:

José Valim
Owner
Yurii Rashkovskii
Yurii Rashkovskii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.