1 UnitTests definePrototype: #File &basis: TestCase.
2 "Unit test for file functionality."
4 UnitTests File addSlot: #inputFileName valued: ('LICENSE' as: File Locator).
5 UnitTests File addSlot: #outputFileName valued: ('LICENSE.copy' as: File Locator).
7 t@(UnitTests File traits) testLocatorConversion
8 "Note this test avoids using '~' in the filenames so that the platform library isn't required"
10 filenames: {'src/lib/file.slate'. '/'. '/usr'. 'foo.bar'}.
11 filenames do: [| :filename |
12 t assert: (filename isSuffixOf: ((filename as: File Locator) as: filename))
13 description: 'Parsing and printing a filename failed: ' ; filename].
16 t@(UnitTests File traits) testIdentityCompare
18 t assert: (t inputFileName with: t inputFileName sessionDo:
19 [| :file1 :file2 | file1 hasSameContentsAs: file2] &mode: File Read)
20 description: 'Comparing the contents of \'' ; (t inputFileName as: String) ; '\' with itself failed'.
23 t@(UnitTests File traits) testCopy
25 t inputFileName with: t outputFileName sessionDo:
26 [| :file1 :file2 | file1 copyContentsTo: file2] &mode1: File Read &mode2: File CreateWrite.
27 t assert: (t inputFileName with: t outputFileName sessionDo:
28 [| :file1 :file2 | file1 hasSameContentsAs: file2] &mode: File Read)
31 t@(UnitTests File traits) suite
32 [t suiteForSelectors: {
33 #testLocatorConversion.