I've written tests with empty files like so:

(aReference / 'emptyFile) writeStreamDo: [ :stream | ].

It's a bit lengthy but it's a pretty cool syntax for most write operations to 
files.

Max


On 04.02.2011, at 17:10, Lukas Renggli wrote:

> Stef,
> 
> There is not much sense in creating a file without also putting
> something inside. There are various methods that give you a write
> straeam onto a new file.
> 
> Also note that FSFilesystem>>#createDirectory: is a private method,
> like about all other methods in there too. You are not supposed to
> call it directly.
> 
> Lukas
> 
> On Friday, 4 February 2011, Stéphane Ducasse <stephane.duca...@inria.fr> 
> wrote:
>> Hi
>> 
>> I would like to write a test to see if children includes files
>> 
>> | ref children alpha |
>> filesystem createDirectory: '/alpha'.
>> filesystem createDirectory: '/alpha/beta'.
>> filesystem createDirectory: '/alpha/gamma/'.
>> 
>> Now how do I create a file? There is createDirectory but not createFile.
>> 
>> I think that there is a lot of work before FS can get into the image.....
>> 
>> Stef
>> 
>> 
>> 
>> 
>> testChildrenWithFilesAndDirectories
>>        "Children of a reference are all the files and directories contained 
>> in this reference"
>>        "self debug: #testChildrenWithFilesAndDirectories"
>>        | ref children alpha |
>>        filesystem createDirectory: '/alpha'.
>>        filesystem createDirectory: '/alpha/beta'.
>>        filesystem createDirectory: '/alpha/gamma/'.
>>        filesystem working / '/alpha/gamma/'.
>>        alpha :=  filesystem referenceTo: '/alpha'.
>>        alpha / 'zork.text'.
>>        self halt.
>>        ref := filesystem referenceTo: '/alpha'.
>>        children := ref children.
>>        self assert: children size = 2.
>> 
>>        children do:
>>                [:child |
>>                self assert: child class = FSReference.
>>                self assert: (child isChildOf: ref).
>>                self assert: (#('beta' 'gamma') includes: child basename)]
>> 
> 
> -- 
> Lukas Renggli
> www.lukas-renggli.ch
> 


Reply via email to