diff --git a/dev/src/ExercismTests/ExercismExerciseTest.class.st b/dev/src/ExercismTests/ExercismExerciseTest.class.st index 2d450c81..c5448813 100644 --- a/dev/src/ExercismTests/ExercismExerciseTest.class.st +++ b/dev/src/ExercismTests/ExercismExerciseTest.class.st @@ -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 } diff --git a/dev/src/ExercismTests/ExercismPackageTest.class.st b/dev/src/ExercismTests/ExercismPackageTest.class.st new file mode 100644 index 00000000..d02e62e9 --- /dev/null +++ b/dev/src/ExercismTests/ExercismPackageTest.class.st @@ -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'. +] diff --git a/dev/src/ExercismTools/ClyExercismSubmitCommand.class.st b/dev/src/ExercismTools/ClyExercismSubmitCommand.class.st index dc30b8bb..06d9a8d1 100644 --- a/dev/src/ExercismTools/ClyExercismSubmitCommand.class.st +++ b/dev/src/ExercismTools/ClyExercismSubmitCommand.class.st @@ -31,7 +31,7 @@ ClyExercismSubmitCommand >> description [ ClyExercismSubmitCommand >> execute [ | exerciseName result | - exerciseName := ($@ split: self selectedItem name) last. + exerciseName := self selectedItem exerciseName. [ result := ExercismManager default submitToExercism: diff --git a/dev/src/ExercismTools/ExercismExercise.class.st b/dev/src/ExercismTools/ExercismExercise.class.st index 84727c80..7dca805e 100644 --- a/dev/src/ExercismTools/ExercismExercise.class.st +++ b/dev/src/ExercismTools/ExercismExercise.class.st @@ -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' } diff --git a/dev/src/ExercismTools/RPackage.extension.st b/dev/src/ExercismTools/RPackage.extension.st index 41bb793c..8a4a691f 100644 --- a/dev/src/ExercismTools/RPackage.extension.st +++ b/dev/src/ExercismTools/RPackage.extension.st @@ -1,5 +1,10 @@ Extension { #name : #RPackage } +{ #category : #'*ExercismTools' } +RPackage >> exerciseName [ + ^ (name allRegexMatches: '\w+') last +] + { #category : #'*ExercismTools' } RPackage >> root [ ^self diff --git a/dev/src/ExercismTools/RPackageTag.extension.st b/dev/src/ExercismTools/RPackageTag.extension.st index b2fce87a..347a4f93 100644 --- a/dev/src/ExercismTools/RPackageTag.extension.st +++ b/dev/src/ExercismTools/RPackageTag.extension.st @@ -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"