Skip to content

Commit

Permalink
Update Acronym to match latest test data. Refs #488. (#593)
Browse files Browse the repository at this point in the history
* Update acronym to match canonical-data. Refs #488

* Update acronym to match canonical-data. Refs #488
  • Loading branch information
ricemery authored and ErikSchierboom committed Jan 1, 2019
1 parent 85edf4c commit ab17bcd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 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
}
}
19 changes: 17 additions & 2 deletions exercises/acronym/src/test/scala/AcronymTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.scalatest.{Matchers, FunSuite}

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

test("basic") {
Expand All @@ -26,4 +26,19 @@ class AcronymTest extends FunSuite with Matchers {
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 ab17bcd

Please sign in to comment.