brain-dead truncation?
As in my irbrc:
class IRB::Irb
def output_value
text =
if @context.inspect?
sprintf @context.return_format, @context.last_value.inspect
else
sprintf @context.return_format, @context.last_value
end
max = @context.max_output_size
if text.size < max
puts text
else
puts text[0..max-1] + "..." + text[-2..-1]
end
end
end
> Imagine an assert failure where inspecting an object in the assert
> spews three pages of stuff. What should we do about this, exactly?
git reset --hard HEAD
My favorite git command EVAR!
--
Phlip
http://c2.com/cgi/wiki?ZeekLand
If an inspected value has newlines, Wrong indents successive lines so they don't break the left margin flow. Your eye can find the next "is" line fairly easily.
Long (wide) values are a bit more troublesome. I've been thinking the right thing to do is truncate them, but allow (and mention) a "verbose" option so you can see the full values when you run it again. Only problem is that we may not actually have a command line to set that option on, but we do support runtime options so that shouldn't be so bad.
Sent from my iPhone
> There's two aspects to "too long": width and height.
That answer works on many levels.
The rebuttal to my (flippant) suggestion to revert the code is
diagnostics should try to tell you WHY they failed, as close as
possible to the root problem. If it's one character in a long string,
the assertion should point that out. That helps the decision "fix or
revert".
However, if you revert anyway, and get the same problem anyway, then
reverting is still working on your side...
--
Phlip
http://c2.com/cgi/wiki?ZeekLand
http://stackoverflow.com/questions/2068859/how-to-get-the-width-of-terminal-window-in-ruby
https://github.com/cldwalker/hirb/blob/master/lib/hirb/util.rb#L59
I'll spike something out right now, for fun.
- A
--
Alex Chaffee - al...@stinky.com - http://alexch.github.com
Stalk me: http://friendfeed.com/alexch | http://twitter.com/alexch |
http://alexch.tumblr.com
And it does, if you use StringComparison. But Steve's talking about
something like
assert { request.params['foo'] == 'bar' }
where Wrong will dig in to the request object and show a bunch of crap
you don't want --
request.params['foo'] is 'baz'
request.params is {:foo => 'baz', :meat => 'bacon'}
request is BLAHBLAHBLAHFORFORTYLINES
-- obscuring the "params['foo'] is 'baz'" that just scrolled up out of
view that's actually relevant to your assertion. That's why I think
truncation is probably best, but I'll experiment with line wrapping
since it preserves all data, which is important for, e.g., continuous
integration build reports, but still looks somewhat nice.
So wait, what happens to the inspect that's 3 pages long (because Rack
Request points to a bunch of objects internally that you don't care
about)?
On Tue, Dec 7, 2010 at 11:22 AM, Alex Chaffee <ale...@gmail.com> wrote:
> Screenshot attached. I think it's ready to roll out. Any objections?
>
>
>
>
>>>
>>>
Out of curiosity... why inspect and not pretty_inspect?
Sent from my iPhone
The output of inspect / pretty_inspect is usually _almost_ parsable ruby.