-
-
Notifications
You must be signed in to change notification settings - Fork 354
/
RGEnvironmentBackendTest.class.st
182 lines (121 loc) · 5.22 KB
/
RGEnvironmentBackendTest.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
Class {
#name : #RGEnvironmentBackendTest,
#superclass : #RGBackendTest,
#traits : 'TRGReadOnlyTest',
#classTraits : 'TRGReadOnlyTest classTrait',
#category : #'Ring-Tests-Core'
}
{ #category : #'as yet unclassified' }
RGEnvironmentBackendTest >> backendClass [
^ RGEnvironmentBackend
]
{ #category : #'as yet unclassified' }
RGEnvironmentBackendTest >> checkHierarchyConsistencyOf: anRGClass [
self assert: (anRGClass ~~ anRGClass superclass).
self assert: (anRGClass ~~ anRGClass metaclass).
self assert: (anRGClass ~~ anRGClass superclass metaclass).
self assert: (anRGClass superclass ~~ anRGClass metaclass).
self assert: (anRGClass superclass ~~ anRGClass superclass metaclass).
self assert: (anRGClass metaclass ~~ anRGClass superclass metaclass).
self assert: (anRGClass superclass superclass == anRGClass superclass).
self assert: (anRGClass superclass metaclass == anRGClass metaclass superclass).
self assert: (anRGClass superclass metaclass superclass == anRGClass superclass metaclass).
self assert: (anRGClass superclass metaclass metaclass == anRGClass superclass metaclass).
]
{ #category : #tests }
RGEnvironmentBackendTest >> testAST [
| method anAst |
method := RGMethod new.
method sourceCode: 'someMethod ^ true'.
anAst := method ast.
self assert: (anAst isMethod).
self assert: (anAst lastIsReturn)
]
{ #category : #tests }
RGEnvironmentBackendTest >> testCreationOfDefinitions [
| env1 method |
env1 := RGEnvironment new.
"self should: [ (Object>>#isRingObject) asRingDefinitionIn: env1 ] raise: RGNotFoundError."
method := (Object>>#isRGObject) ensureRingDefinitionIn: env1.
self assert: method class equals: RGMethod.
self assert: method selector equals: #isRGObject.
self assert: method parent name equals: #Object.
self assert: (method environment == env1).
]
{ #category : #tests }
RGEnvironmentBackendTest >> testDefaultEnvironmentContent [
| env |
env := RGEnvironment unnamed.
self testDefaultContentFor: env.
" self assert: env ask behaviors size equals: 12.
self assert: env ask packages size equals: 1.
"
]
{ #category : #tests }
RGEnvironmentBackendTest >> testDefinitionsIdentity [
| env1 |
env1 := RGEnvironment new.
self assert: (((Object>>#isRGObject) ensureRingDefinitionIn: env1) == ((Object>>#isRGObject) ensureRingDefinitionIn: env1)).
self assert: (((Object>>#isRGObject) ensureRingDefinitionIn: env1) parent
== ((Object>>#isRGObject) ensureRingDefinitionIn: env1) parent).
]
{ #category : #tests }
RGEnvironmentBackendTest >> testImplicitEnvironmentContentForClassDefinition [
| def def2 env |
def := RGClass named: #SomeClass.
env := def environment.
"we have SomeClass, SomeClass class, SomeClass superclass, SomeClass superclass class"
self assert: env ask behaviors size equals: 4.
"we have one package for SomeClass and SomeClass class, other for SomeClass superclass
and SomeClass superclass class"
self assert: env ask packages size equals: 2.
self assert: (env ask behaviors select: #isMeta) size equals: 2.
self checkHierarchyConsistencyOf: def.
self assert: (def isRingResolved).
self deny: (def superclass isRingResolved).
self deny: (def metaclass isRingResolved).
self deny: (def superclass metaclass isRingResolved).
def2 := RGClass named: #SomeOtherClass parent: env.
self assert: env ask behaviors size equals: 8.
self assert: env ask packages size equals: 4.
self checkHierarchyConsistencyOf: def2.
self assert: (def2 isRingResolved).
self deny: (def2 superclass isRingResolved).
self deny: (def2 metaclass isRingResolved).
self deny: (def2 superclass metaclass isRingResolved).
]
{ #category : #tests }
RGEnvironmentBackendTest >> testImplicitEnvironmentContentForMetaclassDefinition [
| def env baseClass|
def := RGMetaclass named: #'SomeClass class'.
env := def environment.
"we have SomeClass, SomeClass class, SomeClass superclass, SomeClass superclass class"
self assert: env ask behaviors size equals: 4.
"we have one package for SomeClass and SomeClass class, other for SomeClass superclass
and SomeClass superclass class"
self assert: env ask packages size equals: 2.
self assert: (env ask behaviors select: #isMeta) size equals: 2.
baseClass := def baseClass.
self checkHierarchyConsistencyOf: baseClass.
self deny: (baseClass isRingResolved).
self deny: (baseClass superclass isRingResolved).
self assert: (baseClass metaclass isRingResolved).
self deny: (baseClass superclass metaclass isRingResolved).
]
{ #category : #tests }
RGEnvironmentBackendTest >> testImplicitEnvironmentContentForMethodDefinition [
| def env |
def := RGMethod named: #someMethod.
env := def environment.
"we have SomeClass, SomeClass class, SomeClass superclass, SomeClass superclass class"
self assert: env ask behaviors size equals: 4.
"we have one package for SomeClass and SomeClass class, other for SomeClass superclass
and SomeClass superclass class"
self assert: env ask packages size equals: 2.
self assert: (env ask behaviors select: #isMeta) size equals: 2.
self checkHierarchyConsistencyOf: def parent.
self deny: (def parent isRingResolved).
self deny: (def parent superclass isRingResolved).
self deny: (def parent metaclass isRingResolved).
self deny: (def parent superclass metaclass isRingResolved).
]