<commit_before>/*
 * Copyright 2001-2013 Artima, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.scalatest

class OptionShouldContainSpec extends Spec with Matchers with SharedHelpers {
  object `an Option` {
    def `should be usable with contain (value) syntax` {

      val some: Option[String] = Some("hi")
      val none: Option[String] = None

      some should contain ("hi")
      Some("hi") should contain ("hi")
      some should not contain ("ho")
      Some("hi") should not contain ("ho")
      none should not contain ("hi")

      val e1 = intercept[TestFailedException] {
        some should contain ("ho")
      }
      e1.message.get should be (Resources("didNotContainExpectedElement", some, "\"ho\""))
      e1.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e1.failedCodeLineNumber.get should be (thisLineNumber - 4)

      val e2 = intercept[TestFailedException] {
        none should contain ("ho")
      }
      e2.message.get should be (Resources("didNotContainExpectedElement", none, "\"ho\""))
      e2.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e2.failedCodeLineNumber.get should be (thisLineNumber - 4)

      val e3 = intercept[TestFailedException] {
        some should not contain ("hi")
      }
      e3.message.get should be (Resources("containedExpectedElement", some, "\"hi\""))
      e3.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e3.failedCodeLineNumber.get should be (thisLineNumber - 4)

      val e4 = intercept[TestFailedException] {
        Some("hi") should contain ("ho")
      }
      e4.message.get should be (Resources("didNotContainExpectedElement", some, "\"ho\""))
      e4.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e4.failedCodeLineNumber.get should be (thisLineNumber - 4)

      val e5 = intercept[TestFailedException] {
        Some("hi") should not contain ("hi")
      }
      e5.message.get should be (Resources("containedExpectedElement", some, "\"hi\""))
      e5.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e5.failedCodeLineNumber.get should be (thisLineNumber - 4)
    }
  }
}<commit_msg>Added test for Option should contain via inspector shorthands, which now works because of the getting rid of ResultOfCollectedAnyRef[AnyRef] problem.<commit_after>/*
 * Copyright 2001-2013 Artima, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.scalatest

class OptionShouldContainSpec extends Spec with Matchers with SharedHelpers {
  object `an Option` {
    def `should be usable with contain (value) syntax` {

      val some: Option[String] = Some("hi")
      val none: Option[String] = None

      some should contain ("hi")
      Some("hi") should contain ("hi")
      some should not contain ("ho")
      Some("hi") should not contain ("ho")
      none should not contain ("hi")

      val e1 = intercept[TestFailedException] {
        some should contain ("ho")
      }
      e1.message.get should be (Resources("didNotContainExpectedElement", some, "\"ho\""))
      e1.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e1.failedCodeLineNumber.get should be (thisLineNumber - 4)

      val e2 = intercept[TestFailedException] {
        none should contain ("ho")
      }
      e2.message.get should be (Resources("didNotContainExpectedElement", none, "\"ho\""))
      e2.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e2.failedCodeLineNumber.get should be (thisLineNumber - 4)

      val e3 = intercept[TestFailedException] {
        some should not contain ("hi")
      }
      e3.message.get should be (Resources("containedExpectedElement", some, "\"hi\""))
      e3.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e3.failedCodeLineNumber.get should be (thisLineNumber - 4)

      val e4 = intercept[TestFailedException] {
        Some("hi") should contain ("ho")
      }
      e4.message.get should be (Resources("didNotContainExpectedElement", some, "\"ho\""))
      e4.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e4.failedCodeLineNumber.get should be (thisLineNumber - 4)

      val e5 = intercept[TestFailedException] {
        Some("hi") should not contain ("hi")
      }
      e5.message.get should be (Resources("containedExpectedElement", some, "\"hi\""))
      e5.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e5.failedCodeLineNumber.get should be (thisLineNumber - 4)
    }
  }

  object `a collection of Options` {
    def `be usable with contain value syntax via inspector shorthands` {

      val some1s: Vector[Option[Int]] = Vector(Some(1), Some(1), Some(1))
      val somes: Vector[Option[Int]] = Vector(Some(1), Some(1), Some(2))
      val nones: Vector[Option[Int]] = Vector(None, None, None)
      val somesNone: Vector[Option[Int]] = Vector(Some(1), Some(1), None)

      all (some1s) should contain (1)
      atLeast (2, somes) should contain (1)
      atMost (2, somes) should contain (2)
      no (somes) should contain (3)
      no (nones) should contain (1)
      no (somesNone) should contain (3)

      val e1 = intercept[TestFailedException] {
        all (somes) should contain (1)
      }
      e1.failedCodeFileName.get should be ("OptionShouldContainSpec.scala")
      e1.failedCodeLineNumber.get should be (thisLineNumber - 3)
      e1.message should be (Some("'all' inspection failed, because: \n" +
                                 "  at index 2, Some(2) did not contain element 1 (OptionShouldContainSpec.scala:" + (thisLineNumber - 5) + ") \n" +
                                 "in Vector(Some(1), Some(1), Some(2))"))
    }
  }
}
{'fraction_non_alphanumeric': 0.10997782705099779, 'fraction_numerical': 0.015521064301552107, 'mean_word_length': 3.2420062695924763, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4151421', 'n_tokens_mistral': 1981, 'n_tokens_neox': 1897, 'n_words': 626}