<commit_before>package ch.epfl.scala.index.model
package release

object DefaultReleaseTests extends org.specs2.mutable.Specification {

  def prepare(organization: String, repository: String, groupdId: String, releases: List[(String, String)]) = {
    releases.map{ case (artifactId, rawVersion) =>
        for {
          (artifact, target) <- Artifact(artifactId)
          version <- SemanticVersion(rawVersion)
        } yield   (artifactId, rawVersion, artifact, target, version)
      }.flatten.map{ case (artifactId, rawVersion, artifact, target, version) =>
        Release(
          MavenReference(groupdId, artifactId, rawVersion),
          Release.Reference(organization, repository, artifact, version, target)
        )
      }.toSet
  }

  "Default Release" >> {
    "latest version pre release scala" >> {
      
      val organization = "typelevel"
      val repository = "cats"
      val groupdId = "org.typelevel"
      val releases = prepare(organization, repository, groupdId,
        List(
          ("cats-core_2.11"       , "0.6.0"   ),
          ("cats-core_2.11"       , "0.6.0-M2"),
          ("cats-core_2.11"       , "0.6.0-M1"),
          ("cats-core_2.11"       , "0.5.0"   ),
          ("cats-core_2.11"       , "0.4.1"   ),
          ("cats-core_2.11"       , "0.4.0"   ),
          ("cats-core_2.10"       , "0.6.0"   ),
          ("cats-core_2.10"       , "0.6.0-M2"),
          ("cats-core_2.10"       , "0.6.0-M1"),
          ("cats-core_2.10"       , "0.5.0"   ),
          ("cats-core_2.10"       , "0.4.1"   ),
          ("cats-core_2.10"       , "0.4.0"   ),
          ("cats-core_sjs0.6_2.11", "0.6.0"   ),
          ("cats-core_sjs0.6_2.11", "0.6.0-M2"),
          ("cats-core_sjs0.6_2.11", "0.6.0-M1"),
          ("cats-core_sjs0.6_2.11", "0.5.0"   ),
          ("cats-core_sjs0.6_2.11", "0.4.1"   ),
          ("cats-core_sjs0.6_2.11", "0.4.0"   ),
          ("cats-core_sjs0.6_2.10", "0.6.0"   ),
          ("cats-core_sjs0.6_2.10", "0.6.0-M2"),
          ("cats-core_sjs0.6_2.10", "0.6.0-M1"),
          ("cats-core_sjs0.6_2.10", "0.5.0"   ),
          ("cats-core_sjs0.6_2.10", "0.4.1"   ),
          ("cats-core_sjs0.6_2.10", "0.4.0"   )
        )
      ) 

      val result = DefaultRelease(repository, ReleaseSelection(None, None), releases, None)
      val expected: Option[ReleaseOptions] =
        Some(ReleaseOptions(
          artifacts = List(
            "cats-core"
          ),
          versions = List(
            SemanticVersion("0.6.0"   ).get,
            SemanticVersion("0.6.0-M2").get,
            SemanticVersion("0.6.0-M1").get,
            SemanticVersion("0.5.0"   ).get,
            SemanticVersion("0.4.1"   ).get,
            SemanticVersion("0.4.0"   ).get
          ),
          targets = List(
            ScalaTarget(SemanticVersion("2.11").get),
            ScalaTarget(SemanticVersion("2.11").get, Some(SemanticVersion("0.6").get)),
            ScalaTarget(SemanticVersion("2.10").get),
            ScalaTarget(SemanticVersion("2.10").get, Some(SemanticVersion("0.6").get))
          ),
          release = Release(
            MavenReference(groupdId, "cats-core_2.11", "0.6.0"),
            Release.Reference(
              organization,
              repository,
              "cats-core",
              SemanticVersion("0.6.0").get,
              ScalaTarget(SemanticVersion("2.11").get)
            )
          )
        ))
<commit_msg>avoid compiler crash<commit_after>package ch.epfl.scala.index.model
package release

object DefaultReleaseTests extends org.specs2.mutable.Specification {

  def prepare(organization: String, repository: String, groupdId: String, releases: List[(String, String)]) = {
    releases.map{ case (artifactId, rawVersion) =>
        for {
          (artifact, target) <- Artifact(artifactId)
          version <- SemanticVersion(rawVersion)
        } yield   (artifactId, rawVersion, artifact, target, version)
      }.flatten.map{ case (artifactId, rawVersion, artifact, target, version) =>
        Release(
          MavenReference(groupdId, artifactId, rawVersion),
          Release.Reference(organization, repository, artifact, version, target)
        )
      }.toSet
  }

  "Default Release" >> {
    "latest version pre release scala" >> {
      
      val organization = "typelevel"
      val repository = "cats"
      val groupdId = "org.typelevel"
      val releases = prepare(organization, repository, groupdId,
        List(
          ("cats-core_2.11"       , "0.6.0"   ),
          ("cats-core_2.11"       , "0.6.0-M2"),
          ("cats-core_2.11"       , "0.6.0-M1"),
          ("cats-core_2.11"       , "0.5.0"   ),
          ("cats-core_2.11"       , "0.4.1"   ),
          ("cats-core_2.11"       , "0.4.0"   ),
          ("cats-core_2.10"       , "0.6.0"   ),
          ("cats-core_2.10"       , "0.6.0-M2"),
          ("cats-core_2.10"       , "0.6.0-M1"),
          ("cats-core_2.10"       , "0.5.0"   ),
          ("cats-core_2.10"       , "0.4.1"   ),
          ("cats-core_2.10"       , "0.4.0"   ),
          ("cats-core_sjs0.6_2.11", "0.6.0"   ),
          ("cats-core_sjs0.6_2.11", "0.6.0-M2"),
          ("cats-core_sjs0.6_2.11", "0.6.0-M1"),
          ("cats-core_sjs0.6_2.11", "0.5.0"   ),
          ("cats-core_sjs0.6_2.11", "0.4.1"   ),
          ("cats-core_sjs0.6_2.11", "0.4.0"   ),
          ("cats-core_sjs0.6_2.10", "0.6.0"   ),
          ("cats-core_sjs0.6_2.10", "0.6.0-M2"),
          ("cats-core_sjs0.6_2.10", "0.6.0-M1"),
          ("cats-core_sjs0.6_2.10", "0.5.0"   ),
          ("cats-core_sjs0.6_2.10", "0.4.1"   ),
          ("cats-core_sjs0.6_2.10", "0.4.0"   )
        )
      ) 

      val result = DefaultRelease(repository, ReleaseSelection(None, None), releases, None)
      
      val versions: List[SemanticVersion] =
        List(
          SemanticVersion("0.6.0"   ).get,
          SemanticVersion("0.6.0-M2").get,
          SemanticVersion("0.6.0-M1").get,
          SemanticVersion("0.5.0"   ).get,
          SemanticVersion("0.4.1"   ).get,
          SemanticVersion("0.4.0"   ).get
        )

      val targets: List[ScalaTarget] = 
        List(
          ScalaTarget(SemanticVersion("2.11").get),
          ScalaTarget(SemanticVersion("2.11").get, Some(SemanticVersion("0.6").get)),
          ScalaTarget(SemanticVersion("2.10").get),
          ScalaTarget(SemanticVersion("2.10").get, Some(SemanticVersion("0.6").get))
        )

      val expected: Option[ReleaseOptions] =
        Some(ReleaseOptions(
          artifacts = List(
            "cats-core"
          ),
          versions = versions,
          targets = targets,
          release = Release(
            MavenReference(groupdId, "cats-core_2.11", "0.6.0"),
            Release.Reference(
              organization,
              repository,
              "cats-core",
              SemanticVersion("0.6.0").get,
              ScalaTarget(SemanticVersion("2.11").get)
            )
          )
        ))

{'fraction_non_alphanumeric': 0.17133822049734082, 'fraction_numerical': 0.0646830530401035, 'mean_word_length': 1.7361384191899332, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7593167', 'n_tokens_mistral': 2629, 'n_tokens_neox': 2460, 'n_words': 342}