March 11, 2012
On 03/11/2012 06:14 PM, Jonathan M Davis wrote:
> On Sunday, March 11, 2012 13:33:34 Magnus Lie Hetland wrote:
>> On 2012-03-10 17:10:52 +0000, Jonathan M Davis said:
>>>> Otherwise, this wouldn't have been a problem :)
>>>
>>> Then you'll probably have to write a wrapper function which just uses
>>> byLine and join to grab the string line by line and then put it back
>>> together again.
>> Indeed. Not a problem.
>>
>> Just surprised me that there wasn't a standard way of writing
>> file-related unit tests :)
>
> Well, most of the file-related unit tests in Phobos don't care much about the
> contents of the file, and if they do, it's becaus they're testing one of the
> functions for reading one (such as byLine or read), in which case, they're not
> looking to read in the whole file at once. So, as far as Phobos' unit tests are
> concerned, there's not really any need for what you're trying to do. That
> doesn't mean that it shouldn't be supported, but it just doesn't appear to
> have ever come up.
>
> - Jonathan M Davis

What real world product did the designers of the D language do?
March 12, 2012
On Sun, Mar 11, 2012 at 02:14:59PM -0700, Jonathan M Davis wrote:
> On Sunday, March 11, 2012 13:33:34 Magnus Lie Hetland wrote:
> > On 2012-03-10 17:10:52 +0000, Jonathan M Davis said:
> > >> Otherwise, this wouldn't have been a problem :)
> > > 
> > > Then you'll probably have to write a wrapper function which just uses byLine and join to grab the string line by line and then put it back together again.
> > Indeed. Not a problem.
> > 
> > Just surprised me that there wasn't a standard way of writing file-related unit tests :)
> 
> Well, most of the file-related unit tests in Phobos don't care much about the contents of the file, and if they do, it's becaus they're testing one of the functions for reading one (such as byLine or read), in which case, they're not looking to read in the whole file at once. So, as far as Phobos' unit tests are concerned, there's not really any need for what you're trying to do. That doesn't mean that it shouldn't be supported, but it just doesn't appear to have ever come up.
[...]

I think he's talking about unit tests in general D code, not unittests in Phobos.


T

-- 
Heuristics are bug-ridden by definition. If they didn't have bugs, they'd be algorithms.
March 12, 2012
On 2012-03-11 21:14:59 +0000, Jonathan M Davis said:

> So, as far as Phobos' unit tests are  concerned, there's not really any need for what you're trying to do.

Sure. Just would have thought that maybe some unit-testing D user out there had written a function that wrote something to a file ;-)

But no problem -- not many lines to add to  my own code.

-- 
Magnus Lie Hetland
http://hetland.org

March 12, 2012
On Mon, Mar 12, 2012 at 01:54:08PM +0100, Magnus Lie Hetland wrote:
> On 2012-03-11 21:14:59 +0000, Jonathan M Davis said:
> 
> >So, as far as Phobos' unit tests are  concerned, there's not really any need for what you're trying to do.
> 
> Sure. Just would have thought that maybe some unit-testing D user out there had written a function that wrote something to a file ;-)
[...]

I've written unittests that create files to test code with.

However, I never thought far enough to make it something generic that can be used elsewhere. :-) So I use actual filenames (not tmpfiles) so that later unittests can reference actual filenames to load different datasets into the program for testing. Not the nicest solution, since it will overwrite files in the working directory, but presumably only developers will bother running unittests anyway so this shouldn't be a problem.


T

-- 
Truth, Sir, is a cow which will give [skeptics] no more milk, and so they are gone to milk the bull. -- Sam. Johnson
1 2
Next ›   Last »