From ab17bcda08ebee8b8a5ea732686aa17dbb7afe7a Mon Sep 17 00:00:00 2001 From: Ric Emery Date: Tue, 1 Jan 2019 05:58:00 -0700 Subject: [PATCH] Update Acronym to match latest test data. Refs #488. (#593) * Update acronym to match canonical-data. Refs #488 * Update acronym to match canonical-data. Refs #488 --- exercises/acronym/example.scala | 5 ++++- .../acronym/src/test/scala/AcronymTest.scala | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/exercises/acronym/example.scala b/exercises/acronym/example.scala index 2dd389df..3017e2a3 100644 --- a/exercises/acronym/example.scala +++ b/exercises/acronym/example.scala @@ -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 } } diff --git a/exercises/acronym/src/test/scala/AcronymTest.scala b/exercises/acronym/src/test/scala/AcronymTest.scala index e2ac6ed9..9cc2c358 100644 --- a/exercises/acronym/src/test/scala/AcronymTest.scala +++ b/exercises/acronym/src/test/scala/AcronymTest.scala @@ -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") { @@ -26,4 +26,19 @@ class AcronymTest extends FunSuite with Matchers { pending Acronym.abbreviate("Complementary metal-oxide semiconductor") should be ("CMOS") } -} \ No newline at end of file + + 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") + } +}