Skip to content

Commit

Permalink
Merge pull request #362 from macta/better-legacy-exercise-support
Browse files Browse the repository at this point in the history
Better legacy exercise support
  • Loading branch information
macta authored May 18, 2019
2 parents 4ddd170 + 675c23b commit aa784ba
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dev/src/ExercismTests/ExercismExerciseTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ ExercismExerciseTest >> testExercisePackageTag [
ExercismExerciseTest >> testFind [

self assert: (ExercismExercise find: 'hello-world' ifAbsent: [nil]) equals: HelloWorldTest exercise.
self assert: (ExercismExercise find: 'missing-exercise' ifAbsent: [ 'missing' ]) equals: 'missing'
self assert: (ExercismExercise find: 'missing-exercise' ifAbsent: [ 'missing' ]) equals: 'missing'.
self assert: (ExercismExercise find: 'missing-exercise' ifAbsent: [ :name | 'missing param' ]) equals: 'missing param'
]

{ #category : #tests }
Expand Down
17 changes: 17 additions & 0 deletions dev/src/ExercismTests/ExercismPackageTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Class {
#name : #ExercismPackageTest,
#superclass : #TestCase,
#category : #'ExercismTests-UnitTests'
}

{ #category : #tests }
ExercismPackageTest >> testExerciseNameOnRPackage [
self assert: TestExerciseTest package exerciseName equals: 'ExerciseNormal'.
self assert: HelloWorldTest package exerciseName equals: 'HelloWorld'
]

{ #category : #tests }
ExercismPackageTest >> testExerciseNameOnRPackageTag [
"Test legacy exerciseNames on RPackageTags"
self assert: self class package classTags anyOne exerciseName equals: 'UnitTests'.
]
2 changes: 1 addition & 1 deletion dev/src/ExercismTools/ClyExercismSubmitCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ClyExercismSubmitCommand >> description [
ClyExercismSubmitCommand >> execute [
| exerciseName result |

exerciseName := ($@ split: self selectedItem name) last.
exerciseName := self selectedItem exerciseName.

[ result := ExercismManager default
submitToExercism:
Expand Down
2 changes: 1 addition & 1 deletion dev/src/ExercismTools/ExercismExercise.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ExercismExercise class >> find: exercismName ifAbsent: aBlock [
kebabedName := exercismName asKebabCase.
^ self allExercises
detect: [ :ex | ex name = kebabedName ]
ifNone: aBlock
ifNone: [ aBlock cull: exercismName ]
]

{ #category : #'instance creation' }
Expand Down
5 changes: 5 additions & 0 deletions dev/src/ExercismTools/RPackage.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Extension { #name : #RPackage }

{ #category : #'*ExercismTools' }
RPackage >> exerciseName [
^ (name allRegexMatches: '\w+') last
]

{ #category : #'*ExercismTools' }
RPackage >> root [
^self
Expand Down
6 changes: 6 additions & 0 deletions dev/src/ExercismTools/RPackageTag.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ RPackageTag >> definedClasses [
^ self classes
]

{ #category : #'*ExercismTools' }
RPackageTag >> exerciseName [
"Provided for legacy compatibility"
^self name
]

{ #category : #'*ExercismTools' }
RPackageTag >> promoteAsExercismRPackage [
"This method converts this rpackage tag into an rpackage compatible with exercism"
Expand Down

0 comments on commit aa784ba

Please sign in to comment.