Skip to content

Commit

Permalink
fixes: pharo-project#5428 resync enlumineur
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Jan 1, 2020
1 parent a3829b0 commit 5dae917
Show file tree
Hide file tree
Showing 16 changed files with 847 additions and 332 deletions.
36 changes: 18 additions & 18 deletions src/EnlumineurFormatter-Tests/EFArrayExpressionTest.class.st
Expand Up @@ -172,23 +172,23 @@ EFArrayExpressionTest >> spaceInsideArrayConfiguration [
manually so that the spacesBefore string is correctly computed."
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testEmptyArray [
| source |
configurationSelector := #basicConfiguration.
source := self formatExpression: '{}'.
self assert: source equals: '{}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testFiveSpaceAroundBrackets [
| source |
configurationSelector := #fiveSpacesInsideArrayConfiguration.
source := self formatExpression: ' { 1. 2. 3 } '.
self assert: source equals: '{ 1. 2. 3 }'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testFormatElement [
| source |
configurationSelector := #basicConfiguration.
Expand All @@ -199,7 +199,7 @@ EFArrayExpressionTest >> testFormatElement [
(b := 2)}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testNewLineAfterBracesWhenMultiline [
| source |
configurationSelector := #multiLineConfiguration.
Expand All @@ -225,39 +225,39 @@ EFArrayExpressionTest >> testNewLineAfterBracesWhenMultiline [
(self + (1 @ -1))}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testNoExtraSpaceAroundPeriod [
| source |
configurationSelector := #basicConfiguration.
source := self formatExpression: '{1. 2. 3}'.
self assert: source equals: '{1. 2. 3}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testNoSpaceAroundBrackets [
| source |
configurationSelector := #basicConfiguration.
source := self formatExpression: ' { 1. 2. 3 } '.
self assert: source equals: '{1. 2. 3}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testOneSpaceAroundBrackets [
| source |
configurationSelector := #oneSpaceInsideArrayConfiguration.
source := self formatExpression: ' { 1. 2. 3 } '.
self assert: source equals: '{ 1. 2. 3 }'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testPeriodAtEndOfMethod [
| source |
configurationSelector := #periodAtEndOfMethod.
source := self formatExpression: '{1 factorial}'.
self assert: source equals: '{1 factorial}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testPeriodAtEndOfMethodWithMultipleElementArrayShouldNotHavePeriodAtEnd [
| source |
configurationSelector := #periodAtEndOfMethod.
Expand All @@ -267,7 +267,7 @@ EFArrayExpressionTest >> testPeriodAtEndOfMethodWithMultipleElementArrayShouldNo
(a := 2)}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testPeriodAtEndOfMethodWithMultipleElementArrayShouldNotHavePointAtTheEnd [
| source |
configurationSelector := #periodAtEndOfMethod.
Expand All @@ -278,39 +278,39 @@ EFArrayExpressionTest >> testPeriodAtEndOfMethodWithMultipleElementArrayShouldNo
(3 + 2)}' "we should not have a point at the end."
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testSpaceAroundPeriod [
| source |
configurationSelector := #basicConfiguration.
source := self formatExpression: '{1. 2. 3}'.
self assert: source equals: '{1. 2. 3}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testSpaceBeforePeriod [
| source |
configurationSelector := #basicConfiguration.
source := self formatExpression: '{1 . 2 . 3}'.
self assert: source equals: '{1. 2. 3}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testSpaceInside [
| source |
configurationSelector := #spaceInsideArrayConfiguration.
source := self formatExpression: ' { 1. 2. 3 } '.
self assert: source equals: '{ 1. 2. 3 }'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testThreeSpacesBeforePeriod [
| source |
configurationSelector := #threeSpacesBeforeDotInArrayConfiguration.
source := self formatExpression: '{1. 2. 3}'.
self assert: source equals: '{1 . 2 . 3}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testToLongNewLine [
| source |
configurationSelector := #maxLineLengthConfiguration.
Expand All @@ -323,7 +323,7 @@ EFArrayExpressionTest >> testToLongNewLine [
1}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testToLongNewLine2 [
| source |
configurationSelector := #maxLineLengthConfiguration.
Expand All @@ -335,7 +335,7 @@ EFArrayExpressionTest >> testToLongNewLine2 [
5. 6. 7. 1}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testToLongNewLine2WithSpaceBefore [
| source |
configurationSelector := #maxLineLengthConfigurationWithSpaceBefore.
Expand All @@ -347,7 +347,7 @@ EFArrayExpressionTest >> testToLongNewLine2WithSpaceBefore [
5 . 6 . 7 . 1}'
]

{ #category : #test }
{ #category : #tests }
EFArrayExpressionTest >> testToLongNewLineWithSpaceBefore [
| source |
configurationSelector := #maxLineLengthConfigurationWithSpaceBefore.
Expand Down
84 changes: 84 additions & 0 deletions src/EnlumineurFormatter-Tests/EFBenchTest.class.st
@@ -0,0 +1,84 @@
Class {
#name : #EFBenchTest,
#superclass : #TestCase,
#category : #'EnlumineurFormatter-Tests'
}

{ #category : #tests }
EFBenchTest >> basicMethod [
[[[[[ [
[ :y :z |
[ :x | 1 to: 10 do: [:i | Transcript show:i ; cr ;cr] ]]]
]]]]]
]

{ #category : #tests }
EFBenchTest >> basicMethod2 [
<sampleInstance>

1 to: 10 do: [:i | Transcript show:i ; cr ;cr]

]

{ #category : #tests }
EFBenchTest >> basicMethod3 [
"a method with many similar expressions."
| x y |
x to: y do: [:i | Transcript show:i ; cr ;cr].
x to: y do: [:i | Transcript show:i ; cr ;cr].
x to: y do: [:i | Transcript show:i ; cr: x ; cr: x ].

]

{ #category : #resources }
EFBenchTest >> longNestedMethod [

self foo: [ :b1 |
b1 value: [ :b2 |
b2 value: [ :b3 |
b2 value: [ :b4 |
b3 value: [ :b5 |
b4 value: [ :b6 |
b5 value: [ :b7 |
b6 value: [ :b8|
b7 value: [ :b9 |
b8 value: [ :b10 |
b9 value: 2] ] ] ]] ] ] ] ] ]
]

{ #category : #resources }
EFBenchTest >> longNestedMethodShort [
| b0 |
self value: [:b1 | b0 value: [:b2 | b1 value: [:b3 | b2 value: [:b4 | b3 value: [:b5 | b4 value: [:b6 | b5 value: [:b7 | b7 value: 2 ] ] ] ] ] ] ]
]

{ #category : #tests }
EFBenchTest >> testBasicBlueInk [

BIConfigurableFormatter format: (EFBenchTest >> #basicMethod) ast
]

{ #category : #tests }
EFBenchTest >> testBasicEF [
self skip.
[ EFFormatter format: (EFBenchTest >> #basicMethod) ast ] bench
]

{ #category : #tests }
EFBenchTest >> testBasicEF2 [

EFFormatter format: (EFBenchTest >> #basicMethod2) ast
]

{ #category : #tests }
EFBenchTest >> testEF [
"
[ EFFormatter format: (EFBenchTest >> #longNestedMethodShort) ast ] bench '0.159 per second'
[ RBSimpleFormatter format: (EFBenchTest >> #longNestedMethodShort) ast ] bench
>>>'15597.361 per second'
[ BIConfigurableFormatter format: (EFBenchTest >> #longNestedMethodShort) ast ] bench '7341.000 per second'
"
]

0 comments on commit 5dae917

Please sign in to comment.