Skip to content

Commit d7aa698

Browse files
authored
Merge pull request #71 from hpi-swa-lab/bugfix/styling
Fixes styling for empty method bodies
2 parents 2aeb463 + 5b22324 commit d7aa698

20 files changed

+132
-44
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests
2+
testStylerAddsExamplesMorphFor: anOriginalSourceCode
3+
4+
| formattedSourceCode attributes |
5+
formattedSourceCode := styler format: anOriginalSourceCode.
6+
7+
attributes := formattedSourceCode attributesAt: (formattedSourceCode asString indexOf: Character startOfHeader).
8+
attributes := attributes select: [:anAttribute | styler hasExamplesMorph: anAttribute].
9+
self assert: 1 equals: attributes size.
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tests
2+
testStylerAddsExamplesMorphForEmptyMethodBody
3+
4+
self testStylerAddsExamplesMorphFor: 'method' asText.
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
tests
2+
testStylerAddsExamplesMorphForEmptyNewLinedMethodBody
3+
4+
self testStylerAddsExamplesMorphFor: 'method
5+
' asText.
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
tests
2+
testStylerAddsExamplesMorphForEmptyTabbedNewLinedMethodBody
3+
4+
self testStylerAddsExamplesMorphFor: 'method
5+
' asText.
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tests
2+
testStylerAddsExamplesMorphForEmptyTwoNewLinedMethodBody
3+
4+
self testStylerAddsExamplesMorphFor: 'method
5+
6+
' asText.
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests
2+
testStylerAddsExamplesMorphForSomeFilledMethodBody
3+
4+
self testStylerAddsExamplesMorphFor: 'method
5+
| a b |
6+
a := 1.
7+
b := 2.
8+
' asText.
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
tests
2+
testStylerReusesExamplesMorphWhenStyledAgain
3+
4+
| formattedSourceCode oldAttributes newAttributes originalSourceCode |
5+
originalSourceCode := 'method' asText.
6+
7+
formattedSourceCode := styler format: originalSourceCode.
8+
oldAttributes := formattedSourceCode attributesAt: (formattedSourceCode asString indexOf: Character startOfHeader).
9+
oldAttributes := oldAttributes select: [:anAttribute | styler hasExamplesMorph: anAttribute].
10+
11+
formattedSourceCode := styler format: formattedSourceCode.
12+
newAttributes := formattedSourceCode attributesAt: (formattedSourceCode asString indexOf: Character startOfHeader).
13+
newAttributes := newAttributes select: [:anAttribute | styler hasExamplesMorph: anAttribute].
14+
15+
self assert: oldAttributes first identical: newAttributes first.
16+

packages/Babylonian-Tests.package/BPStylerTest.class/instance/testStylerSetsAnchorAttributeForNestedProbes.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ testStylerSetsAnchorAttributeForNestedProbes
66
"<bpProbe id: 1>""<bpProbe id: 2>"2 + 3"</bpProbe>""</bpProbe>"' asText.
77
formattedSourceCode := styler styledTextFor: originalSourceCode.
88

9-
theTextAttributes := (formattedSourceCode attributesAt: 12) select: [:attribute |
9+
theTextAttributes := (formattedSourceCode attributesAt: 11) select: [:attribute |
1010
attribute isKindOf: TextAnchor].
1111
self assert: 2 equals: theTextAttributes size.
12-
12 to: 16 do: [:offset |
12+
11 to: 15 do: [:offset |
1313
anchorTextAttributes := (formattedSourceCode attributesAt: offset) select: [:attribute |
1414
attribute isKindOf: TextAnchor].
1515

packages/Babylonian-Tests.package/BPStylerTest.class/instance/testStylerSetsAnchorAttributeForProbe.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ testStylerSetsAnchorAttributeForProbe
66
"<bpProbe id: 31412>"2 + 3"</bpProbe>"' asText.
77
formattedSourceCode := styler styledTextFor: originalSourceCode.
88

9-
theTextAttribute := ((formattedSourceCode attributesAt: 12) select: [:attribute |
9+
theTextAttribute := ((formattedSourceCode attributesAt: 11) select: [:attribute |
1010
attribute isKindOf: TextAnchor]) first.
11-
12 to: 16 do: [:offset |
11+
11 to: 15 do: [:offset |
1212
anchorTextAttributes := (formattedSourceCode attributesAt: offset) select: [:attribute |
1313
attribute isKindOf: TextAnchor].
1414

packages/Babylonian-Tests.package/BPStylerTest.class/instance/testStylerSetsAnchorAttributeForProbeOnOperand.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ testStylerSetsAnchorAttributeForProbeOnOperand
66
"<bpProbe id: 31412>"2"</bpProbe>" + 3' asText.
77
formattedSourceCode := styler styledTextFor: originalSourceCode.
88

9-
theTextAttribute := ((formattedSourceCode attributesAt: 12) select: [:attribute |
9+
theTextAttribute := ((formattedSourceCode attributesAt: 11) select: [:attribute |
1010
attribute isKindOf: TextAnchor]) first.
11-
12 to: 13 do: [:offset |
11+
11 to: 12 do: [:offset |
1212
anchorTextAttributes := (formattedSourceCode attributesAt: offset) select: [:attribute |
1313
attribute isKindOf: TextAnchor].
1414

0 commit comments

Comments
 (0)