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

Human-readable output of unicode characters in expectation results #384

Open
artempyanykh opened this issue Nov 2, 2018 · 2 comments
Open

Human-readable output of unicode characters in expectation results #384

artempyanykh opened this issue Nov 2, 2018 · 2 comments

Comments

@artempyanykh
Copy link

@artempyanykh artempyanykh commented Nov 2, 2018

When there are non-ascii chars in strings, the resulting output shows codes of those chars instead of their human-readable representation, e.g.

expected: "\1084\1072\1075\1072\1079\1080\1085"
  but got: "\1052\1072\1075\1072\1079\1080\1085"

In GHCi there is a way to specify a different show function, e.g. :set -interactive-print Text.Show.Unicode.uprint.

Is there a way to similarly alter Hspec's output function to properly handle unicode chars?

@sol

This comment has been minimized.

Copy link
Member

@sol sol commented Nov 2, 2018

Hey! Thanks for opening this issue!

Currently this is not supported and I'm not sure how deep we need to dig to add it. I like the idea though and I'm happy to look into it eventually, but can't commit to a timeline.

As a workaround, you can use a newtype on your strings for now, that alter the show instance, e.g. (untested):

newtype UString = UString String

instance Show UString where
  show (UString s) = ushow s
@artempyanykh

This comment has been minimized.

Copy link
Author

@artempyanykh artempyanykh commented Nov 5, 2018

Hey @sol ! Got it, thank you! And thanks for the workaround, much better then decoding utf-8 codes 😃

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.