Skip to content

Commit

Permalink
Fix bug in AbsolutePath>>#withParents returning two times Root in som…
Browse files Browse the repository at this point in the history
…e cases.

Fixes #4258
  • Loading branch information
jecisc committed Aug 23, 2019
1 parent a63a0f6 commit 903781c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/FileSystem-Path/AbsolutePath.class.st
Expand Up @@ -55,5 +55,9 @@ AbsolutePath >> printPathOn: aStream delimiter: aCharacter [
{ #category : #enumerating }
AbsolutePath >> withParents [
^ super withParents addFirst: (Path root); yourself
| root |
^ super withParents
remove: (root := Path root) ifAbsent: [ "In case it's absent we do not care." ];
addFirst: root;
yourself
]
20 changes: 14 additions & 6 deletions src/FileSystem-Tests-Core/PathTest.class.st
Expand Up @@ -56,7 +56,7 @@ PathTest >> testAbsoluteWithParents [
self assert: (allPaths fourth isChildOf: allPaths third).

self assert: allPaths fourth equals: path.
self assert: allPaths fourth == path
self assert: allPaths fourth identicalTo: path
]

{ #category : #tests }
Expand Down Expand Up @@ -617,7 +617,7 @@ PathTest >> testRelativeWithParents [
PathTest >> testResolveAbsolute [
| path |
path := Path / 'griffle'.
self assert: path resolve == path.
self assert: path resolve identicalTo: path.
self assert: path isAbsolute
]

Expand Down Expand Up @@ -653,7 +653,7 @@ PathTest >> testResolvePath [
PathTest >> testResolveRelative [
| path |
path := Path * 'griffle'.
self assert: path resolve == path.
self assert: path resolve identicalTo: path.
self assert: path isRelative
]

Expand All @@ -673,7 +673,7 @@ PathTest >> testResolveString [
PathTest >> testRootParent [
| root |
root := Path root.
self assert: root parent == root
self assert: root parent identicalTo: root
]

{ #category : #tests }
Expand Down Expand Up @@ -720,15 +720,15 @@ PathTest >> testUnequalContent [
| a b |
a := Path * 'plonk'.
b := Path * 'griffle'.
self deny: a = b.
self deny: a identicalTo: b.
]

{ #category : #tests }
PathTest >> testUnequalSize [
| a b |
a := Path * 'plonk'.
b := (Path * 'plonk') / 'griffle'.
self deny: a = b.
self deny: a identicalTo: b.
]

{ #category : #tests }
Expand Down Expand Up @@ -762,6 +762,14 @@ PathTest >> testWithExtentionReplacesExtension [
self assert: result basename equals: 'plonk.griffle'
]

{ #category : #tests }
PathTest >> testWithParentsOnRootReturnRoot [
"Non regression test. Before sending #withParents to the root returned two time root.This is wrong behavior and this test ensure we do not have a regression."

self assert: FileLocator root fullPath withParents size equals: 1.
self assert: FileLocator root fullPath withParents anyOne equals: Path root
]

{ #category : #tests }
PathTest >> testWorkingDirPrintString [
| path actual |
Expand Down

0 comments on commit 903781c

Please sign in to comment.