On 09.08.2010 19:34, bearophile wrote:
Lars T. Kyllingstad:
Either that, or the documentation for it needs to be changed.  Anyway, it
would be great if you'd report this.

A really basic unit testing is able to catch an error like this. This means 
Phobos needs more unit tests.

Stuff that may be added to that unittest:

import std.stdio, std.string;
void main() {
     assert(chomp("hello") == "hello");
     assert(chomp("hello\n") == "hello");
     assert(chomp("hello\r\n") == "hello");
     assert(chomp("hello", "") == "hello");
     assert(chomp("hello\n", "") == "hello");
     assert(chomp("hello\r\n", "") == "hello");
     assert(chomp("hello\r\n", "") == "hello");
     assert(chomp("helloxxx", "x") == "helloxx");
}


But instead of:
if (delimiter == null)
Is better to write:
if (delimiter.length == 0)
Or:
if (delimiter == "")

See http://d.puremagic.com/issues/show_bug.cgi?id=3889

Bye,
bearophile

Ahem.. :) Yes, I did miss your answer! How I got fooled by the preview pane and never noticed the scrollbar. I cannot see how your other bug report relates to this though. For chomps part it's just an implementation vs. documentation issue.

Reply via email to