author | Claus Gittinger <cg@exept.de> |
Thu, 17 May 2018 23:12:11 +0200 | |
changeset 1935 | 0b014f108ad8 |
parent 1447 | 2351db93aa5b |
child 1500 | d406a10b2965 |
child 2161 | 17265ac15ada |
permissions | -rw-r--r-- |
1447 | 1 |
"{ Package: 'stx:goodies/regression' }" |
822 | 2 |
|
3 |
"{ NameSpace: RegressionTests }" |
|
4 |
||
5 |
TestCase subclass:#FilenameTests |
|
6 |
instanceVariableNames:'filename' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
869
32dea6c8b627
class: RegressionTests::FilenameTests
Claus Gittinger <cg@exept.de>
parents:
822
diff
changeset
|
9 |
category:'tests-Regression' |
822 | 10 |
! |
11 |
||
12 |
||
13 |
!FilenameTests methodsFor:'running'! |
|
14 |
||
15 |
tearDown |
|
16 |
filename notNil ifTrue:[ |
|
1447 | 17 |
filename exists ifTrue:[ |
18 |
filename remove |
|
19 |
] |
|
822 | 20 |
]. |
21 |
||
22 |
"Created: / 21-02-2013 / 17:56:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
23 |
! ! |
|
24 |
||
25 |
!FilenameTests methodsFor:'tests'! |
|
26 |
||
27 |
test_01 |
|
28 |
" |
|
29 |
Tests whether filenames are properly encoded before |
|
30 |
passed to an operating system (i.e. whether paths |
|
31 |
are string-type transparent) |
|
32 |
" |
|
33 |
||
34 |
| path | |
|
35 |
||
36 |
filename := 'abcd' asFilename. |
|
37 |
"Create the file" |
|
1447 | 38 |
filename writingFileDo:[:s|]. |
822 | 39 |
|
40 |
path := filename pathName. |
|
41 |
"Make sure it is all ascii" |
|
42 |
self assert: (path allSatisfy:[:c|c codePoint <= 127]). |
|
43 |
||
44 |
self assert: path asFilename exists. |
|
45 |
self assert: path asUnicode16String asFilename exists. |
|
46 |
self assert: path asUnicode32String asFilename exists. |
|
47 |
||
48 |
"Created: / 21-02-2013 / 17:45:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
49 |
! |
|
50 |
||
51 |
test_01_unix |
|
52 |
" |
|
53 |
Tests whether filenames are properly encoded before |
|
54 |
passed to an operating system (i.e. whether paths |
|
55 |
are string-type transparent) |
|
56 |
||
57 |
This has been fixed in JV's stx:libbasic rev 7766f4524d50. |
|
58 |
||
59 |
See https://swing.fit.cvut.cz/hg/stx.libbasic/rev/7766f4524d50 |
|
60 |
||
61 |
" |
|
62 |
||
63 |
| path locale | |
|
64 |
||
65 |
OperatingSystem isUNIXlike ifFalse:[ ^ self ]. |
|
66 |
||
67 |
filename := 'unix' asFilename. |
|
68 |
"Create the file" |
|
1447 | 69 |
filename writingFileDo:[:s|]. |
822 | 70 |
|
71 |
path := filename pathName. |
|
72 |
"Make sure it is all ascii" |
|
73 |
self assert: (path allSatisfy:[:c|c codePoint <= 127]). |
|
74 |
||
75 |
"Now, pretend standard locale..." |
|
76 |
locale := OperatingSystem getEnvironment: 'LANG'. |
|
77 |
||
78 |
[ |
|
1447 | 79 |
OperatingSystem setEnvironment: 'LANG' to: 'C'. |
80 |
OperatingSystem initialize. "/reinitialize locale definitions |
|
822 | 81 |
|
1447 | 82 |
self assert: path asFilename exists. |
83 |
self assert: path asUnicode16String asFilename exists. |
|
84 |
self assert: path asUnicode32String asFilename exists. |
|
822 | 85 |
|
86 |
] ensure:[ |
|
1447 | 87 |
OperatingSystem setEnvironment: 'LANG' to: locale. |
88 |
OperatingSystem initialize. "/reinitialize locale definitions |
|
822 | 89 |
] |
90 |
||
91 |
"Created: / 21-02-2013 / 17:56:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
92 |
! ! |
|
93 |
||
94 |
!FilenameTests class methodsFor:'documentation'! |
|
95 |
||
96 |
version |
|
97 |
^ '$Header$' |
|
98 |
! |
|
99 |
||
100 |
version_CVS |
|
101 |
^ '$Header$' |
|
102 |
! ! |
|
103 |