/
SmalltalkImageTest.class.st
114 lines (102 loc) · 3.9 KB
/
SmalltalkImageTest.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"
Tests for SmalltalkImage
"
Class {
#name : #SmalltalkImageTest,
#superclass : #TestCase,
#category : #'System-Support-Tests'
}
{ #category : #'tests-arguments' }
SmalltalkImageTest >> testExtractAllKinds [
| args extract keys |
args := #('ArgWithoutMinus1' '-ArgWithMinus1' 'ArgWithoutMinus2' 'ArgWithoutMinus3' '-ArgWithMinus2').
extract := SmalltalkImage current extractMinusParametersFrom: args.
keys := extract keys sort.
self assert: extract isDictionary.
self assert: extract size equals: 3.
self assert: (keys at: 1) equals: #*.
self assert: (keys at: 2) equals: #ArgWithMinus1.
self assert: (keys at: 3) equals: #ArgWithMinus2.
self assert: (extract at: #*) equals: (Array with: 'ArgWithoutMinus1').
self assert: (extract at: #ArgWithMinus1) equals: #('ArgWithoutMinus2' 'ArgWithoutMinus3').
self assert: (extract at: #ArgWithMinus2) isEmpty
]
{ #category : #'tests-arguments' }
SmalltalkImageTest >> testExtractEmpty [
| args extract |
args := #().
extract := SmalltalkImage current extractMinusParametersFrom: args.
self assert: extract class equals: Dictionary.
self assert: extract isEmpty
]
{ #category : #'tests-arguments' }
SmalltalkImageTest >> testExtractNil [
| args extract |
args := nil.
extract := SmalltalkImage current extractMinusParametersFrom: args.
self assert: extract class equals: Dictionary.
self assert: extract isEmpty
]
{ #category : #'tests-arguments' }
SmalltalkImageTest >> testExtractOneArgNoMinus [
| args extract |
args := #('ArgNoMinus').
extract := SmalltalkImage current extractMinusParametersFrom: args.
self assert: extract isDictionary.
self assert: extract size equals: 1.
self assert: (extract keys at: 1) equals: #*.
self assert: (extract at: #*) equals: args
]
{ #category : #'tests-arguments' }
SmalltalkImageTest >> testExtractOneArgWithMinus [
| args extract |
args := #('-ArgWithMinus').
extract := SmalltalkImage current extractMinusParametersFrom: args.
self assert: extract isDictionary.
self assert: extract size equals: 1.
self assert: (extract keys at: 1) equals: #ArgWithMinus.
self assert: (extract at: #ArgWithMinus) isEmpty
]
{ #category : #'tests-arguments' }
SmalltalkImageTest >> testExtractOneArgWithMinusThenArgsWithout [
| args extract |
args := #('-ArgWithMinus' 'ArgWithoutMinus1' 'ArgWithoutMinus2').
extract := SmalltalkImage current extractMinusParametersFrom: args.
self assert: extract isDictionary.
self assert: extract size equals: 1.
self assert: (extract keys at: 1) equals: #ArgWithMinus.
self assert: (extract at: #ArgWithMinus) equals: #('ArgWithoutMinus1' 'ArgWithoutMinus2')
]
{ #category : #'tests-arguments' }
SmalltalkImageTest >> testExtractTwoArgsWithAndWithoutMinus [
| args extract keys |
args := #('ArgWithoutMinus' '-ArgWithMinus').
extract := SmalltalkImage current extractMinusParametersFrom: args.
keys := extract keys sort.
self assert: extract isDictionary.
self assert: extract size equals: 2.
self assert: (keys at: 1) equals: #*.
self assert: (keys at: 2) equals: #ArgWithMinus.
self assert: (extract at: #*) equals: (Array with: 'ArgWithoutMinus').
self assert: (extract at: #ArgWithMinus) isEmpty
]
{ #category : #testing }
SmalltalkImageTest >> testOpenLog [
"It must be possible to write to the log even when the log file can''t be created."
"Standard case where a file can be created with this name."
self writeToLogWithFileNamed: 'file.log'.
"Other cases where a file with the given name can not be created."
self writeToLogWithFileNamed: ''.
self writeToLogWithFileNamed: '.'.
]
{ #category : #helpers }
SmalltalkImageTest >> writeToLogWithFileNamed: filename [
| oldLogFileName |
oldLogFileName := Smalltalk logFileName.
Smalltalk logFileName: filename.
[
| stream |
stream := Smalltalk image openLog.
stream nextPutAll: 'foobar' "We just make sure we can write something. I don't know any reliable way to check if it has really been written" ]
ensure: [ Smalltalk logFileName: oldLogFileName ]
]