Skip to content

Commit 6cfa0b0

Browse files
EntenwilliNicolas-Boltz
authored andcommitted
Revert "Update testcases for (now missing) behaviors"
This reverts commit d1ac2ca.
1 parent f93da60 commit 6cfa0b0

3 files changed

Lines changed: 238 additions & 0 deletions

File tree

tests/org.dataflowanalysis.pcm.extension.dddsl.tests/src/org/dataflowanalysis/pcm/extension/dddsl/tests/DDDslFormatterTest.xtend

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,88 @@ class DDDslFormatterTest {
7171
C
7272
}'''.assertFormatting
7373
}
74+
75+
76+
@Test
77+
def testBehavior() {
78+
val expected = '''
79+
dictionary id "123456"
80+
81+
behavior Behavior1 {
82+
input in1
83+
input in2
84+
output out1
85+
output out2
86+
87+
out1.*.* := in1.*.*
88+
out2.*.* := in2.*.*
89+
}'''
90+
91+
val toBeFormatted = '''
92+
dictionary id "123456"
93+
94+
behavior Behavior1 {
95+
input in1
96+
input in2
97+
output out1
98+
output out2
99+
100+
out1 . * . * := in1 . * . *
101+
out2 . * . * := in2 . * . *
102+
}'''
103+
assertFormatting(expected, toBeFormatted)
104+
}
105+
106+
@Test
107+
def testTerms() {
108+
val expected = '''
109+
dictionary id "123456"
110+
111+
enum FirstEnum {
112+
A
113+
}
114+
enumCharacteristicType Type1 using FirstEnum
115+
116+
behavior Behavior1 {
117+
input in1
118+
input in2
119+
output out1
120+
output out2
121+
122+
out1.Type1.* := in1.Type1.*
123+
out1. {
124+
Type1.A := in2.Type1.A
125+
*.* := in1.*.*
126+
}
127+
out2.Type1.A := in2.Type1.A
128+
out1.*.* := true
129+
out2.*.* := !(in1.*.* & in2.*.*)
130+
}'''
131+
132+
val toBeFormatted = '''
133+
dictionary id "123456"
134+
135+
enum FirstEnum {
136+
A
137+
}
138+
enumCharacteristicType Type1 using FirstEnum
139+
behavior Behavior1 {
140+
input in1
141+
input in2
142+
output out1
143+
output out2
144+
145+
out1 . Type1 . * := in1 . Type1 . *
146+
out1 . {
147+
Type1 . A := in2 . Type1 . A
148+
* . * := in1 . * . *
149+
}
150+
out2 . Type1 . A := in2 . Type1 . A
151+
out1 . * . * := true
152+
out2 . * . * := ! ( in1 . * . * & in2 . * . * )
153+
}'''
154+
assertFormatting(expected, toBeFormatted)
155+
}
74156

75157

76158
protected def assertFormatting(CharSequence expected) {

tests/org.dataflowanalysis.pcm.extension.dddsl.tests/src/org/dataflowanalysis/pcm/extension/dddsl/tests/DDDslParsingTest.xtend

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,25 @@ class DDDslParsingTest {
4343
}
4444
enumCharacteristicType AssignedRoles using Roles
4545
enumCharacteristicType ReadAccess using Roles
46+
47+
behavior foo {
48+
input ccd
49+
output RESULT
50+
RESULT.{
51+
*.* := ccd.*.*
52+
ReadAccess.Airline := true
53+
}
54+
55+
}
4656
'''.parse
57+
var characterisations = result.reusableBehaviours.get(0).variableUsages.get(0).
58+
variableCharacterisation_VariableUsage;
59+
var characterisation = characterisations.get(1) as ConfidentialityVariableCharacterisation
60+
var lhs = characterisation.lhs as LhsEnumCharacteristicReference
61+
assertNotNull(lhs.characteristicType)
62+
assertNotNull(lhs.characteristicType.name)
63+
assertNotNull(lhs.literal)
64+
assertNotNull(lhs.literal.name)
4765
}
4866

4967
protected def parse(CharSequence text) {

tests/org.dataflowanalysis.pcm.extension.dictionary.characterized.dsl.tests/src/org/dataflowanalysis/pcm/extension/dictionary/characterized/dsl/tests/CharacterizedDataDictionaryFormatterTest.xtend

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,144 @@ class CharacterizedDataDictionaryFormatterTest {
100100
'''.assertFormatting
101101
}
102102

103+
@Test
104+
def testBehaviorDefinition() {
105+
'''
106+
dictionary id "123456"
107+
108+
behavior SomeBehavior {
109+
input in1
110+
input in2
111+
output out1
112+
output out2
113+
114+
out1.*.* := in1.*.*
115+
out2.*.* := in2.*.*
116+
}
117+
118+
'''.assertFormatting
119+
}
120+
121+
@Test
122+
def testWildcardAssignments() {
123+
val initial = '''
124+
dictionary id "123456"
125+
126+
behavior SomeBehavior {
127+
input in1
128+
input in2
129+
output out1
130+
output out2
131+
132+
out1 . * . * := in1 . * . *
133+
out2 . * . * := container . * . *
134+
}
135+
136+
'''
137+
val expected = '''
138+
dictionary id "123456"
139+
140+
behavior SomeBehavior {
141+
input in1
142+
input in2
143+
output out1
144+
output out2
145+
146+
out1.*.* := in1.*.*
147+
out2.*.* := container.*.*
148+
}'''
149+
assertFormatting(expected, initial)
150+
}
151+
152+
@Test
153+
def testBinaryLogicTerm() {
154+
val initial = '''
155+
dictionary id "123456"
156+
157+
behavior SomeBehavior {
158+
input in1
159+
input in2
160+
output out1
161+
output out2
162+
163+
out1 . * . * := in1 . * . * & in2 . * . *
164+
out2 . * . * := container . * . * | in2 . * . *
165+
}
166+
167+
'''
168+
val expected = '''
169+
dictionary id "123456"
170+
171+
behavior SomeBehavior {
172+
input in1
173+
input in2
174+
output out1
175+
output out2
176+
177+
out1.*.* := in1.*.* & in2.*.*
178+
out2.*.* := container.*.* | in2.*.*
179+
}'''
180+
assertFormatting(expected, initial)
181+
}
182+
183+
@Test
184+
def testUnaryTerm() {
185+
val initial = '''
186+
dictionary id "123456"
187+
188+
behavior SomeBehavior {
189+
input in1
190+
input in2
191+
output out1
192+
output out2
193+
194+
out1 . * . * := ! in1 . * . *
195+
}
196+
197+
'''
198+
val expected = '''
199+
dictionary id "123456"
200+
201+
behavior SomeBehavior {
202+
input in1
203+
input in2
204+
output out1
205+
output out2
206+
207+
out1.*.* := !in1.*.*
208+
}'''
209+
assertFormatting(expected, initial)
210+
}
211+
212+
@Test
213+
def testPrimaryTerm() {
214+
val initial = '''
215+
dictionary id "123456"
216+
217+
behavior SomeBehavior {
218+
input in1
219+
input in2
220+
output out1
221+
output out2
222+
223+
out1 . * . * := ( in1 . * . * )
224+
}
225+
226+
'''
227+
val expected = '''
228+
dictionary id "123456"
229+
230+
behavior SomeBehavior {
231+
input in1
232+
input in2
233+
output out1
234+
output out2
235+
236+
out1.*.* := (in1.*.*)
237+
}'''
238+
assertFormatting(expected, initial)
239+
}
240+
103241
protected def assertFormatting(CharSequence expected) {
104242
val toBeFormatted = expected.toString.replaceAll("\\s(?=([^\"']*[\"'][^\"']*[\"'])*[^\"']*$)", " ")
105243
assertFormatting(expected.toString.trim, toBeFormatted)

0 commit comments

Comments
 (0)