Skip to content

Commit

Permalink
Update acronym to match canonical-data. Refs exercism#488
Browse files Browse the repository at this point in the history
  • Loading branch information
ricemery committed Dec 31, 2018
1 parent 85edf4c commit 74d38ba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
5 changes: 4 additions & 1 deletion exercises/acronym/example.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
object Acronym {
def abbreviate(phrase: String): String = {
"[A-Z]+[a-z]*|[a-z]+".r.findAllIn(phrase).map(s => s.head.toUpper).mkString
"('\\w+)|(\\w+'\\w+)|(\\w+')|(\\w+)".r
.findAllIn(phrase)
.map(_.head.toUpper)
.mkString
}
}
27 changes: 21 additions & 6 deletions exercises/acronym/src/test/scala/AcronymTest.scala
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
import org.scalatest.{Matchers, FunSuite}

/** @version 1.3.0 */
/** @version 1.6.0 */
class AcronymTest extends FunSuite with Matchers {

test("basic") {
Acronym.abbreviate("Portable Network Graphics") should be ("PNG")
}

test("lowercase words") {
pending
//pending
Acronym.abbreviate("Ruby on Rails") should be ("ROR")
}

test("punctuation") {
pending
//pending
Acronym.abbreviate("First In, First Out") should be ("FIFO")
}

test("all caps word") {
pending
//pending
Acronym.abbreviate("GNU Image Manipulation Program") should be ("GIMP")
}

test("punctuation without whitespace") {
pending
//pending
Acronym.abbreviate("Complementary metal-oxide semiconductor") should be ("CMOS")
}
}

test("very long abbreviation") {
//pending
Acronym.abbreviate("Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me") should be ("ROTFLSHTMDCOALM")
}

test("consecutive delimiters") {
//pending
Acronym.abbreviate("Something - I made up from thin air") should be ("SIMUFTA")
}

test("apostrophes") {
//pending
Acronym.abbreviate("Halley's Comet") should be ("HC")
}
}

0 comments on commit 74d38ba

Please sign in to comment.