Skip to content
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

[Stdlib, Spec-lib] Myst spec failures now includes path to the failure #161

Merged
merged 5 commits into from
Feb 16, 2018

Conversation

Jens0512
Copy link
Member

This completes #139 and #141

require "stdlib/spec.mt"

describe("Fish") do
  describe("#swim") do
    it("moves the fish forward")do
      assert(false)
    end
  end
end

Will now print:


  Fish #swim moves the fish forward
    Assertion failed.
    Expected: true
         Got: false

In red :D

Also with this came a simple module Color with #colored which is what is used for printing red and green stuff here. To make that work, I added some lexing for escape codes (notably \e).

Jens added 2 commits February 16, 2018 18:00
```
require "stdlib/spec.mt"

describe("Fish") do
  describe("#swim") do
    it("moves the fish forward")do
      assert(false)
    end
  end
end
```
Will now print: 
```text

  Fish #swim moves the fish forward
    Assertion failed.
    Expected: true
         Got: false

```
In red :D

Also with this came a simple module `Color` with `#colored` which is what is used for printing red and green stuff here. To make that work, I added some lexing for escape codes (notably `\e`).
(Forgot to put some stuff in the previous)

def get_path(current : String)
when !describe_stack.empty?
return describe_stack.pop.get_path("<(@name)> <(current)>")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't actually run this yet, but is pop the desired behavior here? Seems like it would be modifying the stack when you're just trying to get a value from it.

Looks like we don't have a List#last method that could replace it anyway. Could be worth adding (along with List#first)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, i just though it didn't matter as the program exits when a spec fails. I should do a first and last still though, for #140.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually that wouldn't work here anyways if there was nested describes. So i'll figure something else

@faultyserver
Copy link
Member

This is awesome stuff! I'm excited to get this in and be able to use it :)

@faultyserver faultyserver added this to the Next milestone Feb 16, 2018
ANSI_CYAN = "\e[0;36m"
ANSI_WHITE = "\e[0;37m"

def colored(string, sym)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having a type restriction on sym would make sense here. Since the only valid input is a symbol, it doesn't make sense to accept anything else.

@faultyserver
Copy link
Member

Looks good! Thanks for all of this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants