Sha256: 298e043fe2cc448b50a93b0424c6f970267397608047bb7d3adc07007021c987

Contents?: true

Size: 1.98 KB

Versions: 181

Compression:

Stored size: 1.98 KB

Contents

import org.scalatest._

class WordCountTest extends FlatSpec with Matchers {
  it should "count one word" in {
    val phrase = new Phrase("word")
    phrase.wordCount should be (Map("word" -> 1))
  }

  it should "count one of each" in {
    pending
    val phrase = new Phrase("one of each")
    val counts = Map("one" -> 1, "of" -> 1, "each" -> 1)
    phrase.wordCount should be (counts)
  }

  it should "count multiple occurrences" in {
    pending
    val phrase = new Phrase("one fish two fish red fish blue fish")
    val counts = Map("one" -> 1, "fish" -> 4, "two" -> 1, "red" -> 1, "blue" -> 1)
    phrase.wordCount should be (counts)
  }

  it should "count everything just once" in {
    pending
    val phrase = new Phrase("all the kings horses and all the kings men")
    phrase.wordCount
    val counts = Map(
      "all" -> 2, "the" -> 2, "kings" -> 2, "horses" -> 1, "and" -> 1, "men" -> 1
    )
    phrase.wordCount should be (counts)
  }

  it should "ignore punctuation" in {
    pending
    val phrase = new Phrase("car : carpet as java : javascript!!&@$%^&")
    val counts = Map(
      "car" -> 1, "carpet" -> 1, "as" -> 1, "java" -> 1, "javascript" -> 1
    )
    phrase.wordCount should be (counts)
  }

  it should "handle cramped lists" in {
    pending
    val phrase = new Phrase("one,two,three")
    phrase.wordCount should be (Map("one" -> 1, "two" -> 1, "three" -> 1))
  }

  it should "include numbers" in {
    pending
    val phrase = new Phrase("testing, 1, 2 testing")
    val counts = Map("testing" -> 2, "1" -> 1, "2" -> 1)
    phrase.wordCount should be (counts)
  }

  it should "normalize case" in {
    pending
    val phrase = new Phrase("go Go GO")
    val counts = Map("go" -> 3)
    phrase.wordCount should be (counts)
  }

  it should "allow apostrophes" in {
    pending
    val phrase = new Phrase("First: don't laugh. Then: don't cry.")
    val counts =
      Map("first" -> 1, "don't" -> 2, "laugh" -> 1, "then" -> 1, "cry" -> 1)
    phrase.wordCount should be (counts)
  }
}

Version data entries

181 entries across 181 versions & 1 rubygems

Version Path
trackler-2.2.1.39 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.38 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.37 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.36 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.35 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.34 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.33 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.32 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.31 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.30 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.29 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.28 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.27 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.26 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.25 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.24 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.23 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.22 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.21 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala
trackler-2.2.1.20 tracks/scala/exercises/word-count/src/test/scala/WordCountTest.scala