org.scalatest.Inspectors.scala Maven / Gradle / Ivy
/*
* 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
import scala.collection.GenTraversable
import scala.collection.GenSeq
import Suite.indentLines
import enablers.Collecting
import scala.language.higherKinds
import enablers.InspectorAsserting
import org.scalactic._
import org.scalatest.exceptions._
/**
* Provides nestable inspector methods (or just inspectors) that enable assertions to be made about collections.
*
*
* For example, the forAll
method enables you to state that something should be true about all elements of a collection, such
* as that all elements should be positive:
*
*
*
* scala> import org.scalatest._
* import org.scalatest._
*
* scala> import Assertions._
* import Assertions._
*
* scala> import Inspectors._
* import Inspectors._
*
* scala> val xs = List(1, 2, 3, 4, 5)
* xs: List[Int] = List(1, 2, 3, 4, 5)
*
* scala> forAll (xs) { x => assert(x > 0) }
*
*
*
* Or, with matchers:
*
*
*
* scala> import Matchers._
* import Matchers._
*
* scala> forAll (xs) { x => x should be > 0 }
*
*
*
* To make assertions about nested collections, you can nest the inspector method invocations.
* For example, given the following list of lists of Int
:
*
*
*
* scala> val yss =
* | List(
* | List(1, 2, 3),
* | List(1, 2, 3),
* | List(1, 2, 3)
* | )
* yss: List[List[Int]] = List(List(1, 2, 3), List(1, 2, 3), List(1, 2, 3))
*
*
*
* You can assert that all Int
elements in all nested lists are positive by nesting two forAll
method invocations, like this:
*
*
*
* scala> forAll (yss) { ys =>
* | forAll (ys) { y => y should be > 0 }
* | }
*
*
*
* The full list of inspector methods are:
*
*
*
* forAll
- succeeds if the assertion holds true for every element
* forAtLeast
- succeeds if the assertion holds true for at least the specified number of elements
* forAtMost
- succeeds if the assertion holds true for at most the specified number of elements
* forBetween
- succeeds if the assertion holds true for between the specified minimum and maximum number of elements, inclusive
* forEvery
- same as forAll
, but lists all failing elements if it fails (whereas forAll
just reports the first failing element)
* forExactly
- succeeds if the assertion holds true for exactly the specified number of elements
*
*
*
* The error messages produced by inspector methods are designed to make sense no matter how deeply you nest the method invocations.
* Here's an example of a nested inspection that fails and the resulting error message:
*
*
*
* scala> forAll (yss) { ys =>
* | forAll (ys) { y => y should be < 2 }
* | }
* org.scalatest.exceptions.TestFailedException: forAll failed, because:
* at index 0, forAll failed, because:
* at index 1, 2 was not less than 2 (<console>:20)
* in List(1, 2, 3) (<console>:20)
* in List(List(1, 2, 3), List(1, 2, 3), List(1, 2, 3))
* at org.scalatest.InspectorsHelper$.forAll(Inspectors.scala:146)
* ...
*
*
*
* One way the error message is designed to help you understand the error is by using indentation that mimics the indentation of the
* source code (optimistically assuming the source will be nicely indented). The error message above indicates the outer forAll
failed
* because its initial List
(i.e., at index 0) failed
* the assertion, which was that all elements of that initial List[Int]
at index 0 should be less than 2. This assertion failed because index 1 of
* that inner list contained the value 2, which was indeed “not less than 2.” The error message for the inner list is an indented line inside the error message
* for the outer list. The actual contents of each list are displayed at the end in inspector error messages, also indented appropriately. The actual contents
* are placed at the end so that for very large collections, the contents will not drown out and make it difficult to find the messages that describe
* actual causes of the failure.
*
*
*
* The forAll
and forEvery
methods are similar in that both succeed only if the assertion holds for all elements of the collection.
* They differ in that forAll
will only report the first element encountered that failed the assertion, but forEvery
will report all
* elements that fail the assertion. The tradeoff is that while forEvery
gives more information, it may take longer to run because it must inspect every element
* of the collection. The forAll
method can simply stop inspecting once it encounters the first failing element. Here's an example that
* shows the difference in the forAll
and forEvery
error messages:
*
*
*
* scala> forAll (xs) { x => x should be < 3 }
* org.scalatest.exceptions.TestFailedException: forAll failed, because:
* at index 2, 3 was not less than 3 (<console>:18)
* in List(1, 2, 3, 4, 5)
* at org.scalatest.InspectorsHelper$.forAll(Inspectors.scala:146)
* ...
*
* scala> forEvery (xs) { x => x should be < 3 }
* org.scalatest.exceptions.TestFailedException: forEvery failed, because:
* at index 2, 3 was not less than 3 (<console>:18),
* at index 3, 4 was not less than 3 (<console>:18),
* at index 4, 5 was not less than 3 (<console>:18)
* in List(1, 2, 3, 4, 5)
* at org.scalatest.InspectorsHelper$.forEvery(Inspectors.scala:226)
* ...
*
*
*
* Note that if you're using matchers, you can alternatively use inspector shorthands for writing non-nested
* inspections. Here's an example:
*
*
*
* scala> all (xs) should be > 3
* org.scalatest.exceptions.TestFailedException: 'all' inspection failed, because:
* at index 0, 1 was not greater than 3
* in List(1, 2, 3, 4, 5)
* at org.scalatest.InspectorsHelper$.forAll(Inspectors.scala:146)
*
*
*
* You can use Inspectors
on any scala.collection.GenTraversable
, java.util.Collection
,
* java.util.Map
(with Entry
), Array
, or String
.
* Here are some examples:
*
*
*
* scala> import org.scalatest._
* import org.scalatest._
*
* scala> import Inspectors._
* import Inspectors._
*
* scala> import Matchers._
* import Matchers._
*
* scala> forAll (Array(1, 2, 3)) { e => e should be < 5 }
*
* scala> import collection.JavaConverters._
* import collection.JavaConverters._
*
* scala> val js = List(1, 2, 3).asJava
* js: java.util.List[Int] = [1, 2, 3]
*
* scala> forAll (js) { j => j should be < 5 }
*
* scala> val jmap = Map("a" -> 1, "b" -> 2).asJava
* jmap: java.util.Map[String,Int] = {a=1, b=2}
*
* scala> forAtLeast(1, jmap) { e => e shouldBe Entry("b", 2) }
*
* scala> forAtLeast(2, "hello, world!") { c => c shouldBe 'o' }
*
*/
trait Inspectors {
/**
* Ensure that all elements in a given collection pass the given inspection function, where "pass" means returning normally from the function (i.e.,
* without throwing an exception).
*
*
* The difference between forAll
and forEvery
is that
* forAll
will stop on the first failure, while forEvery
will continue to inspect all elements after the
* first failure (and report all failures).
*
*
* @param xs the collection of elements
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam E the type of element in the collection
* @tparam C the type of collection
*
*/
inline def forAll[E, C[_], ASSERTION, RESULT](xs: C[E])(fun: E => ASSERTION)(implicit collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAllMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure that all elements in a given scala.collection.GenMap
pass the given inspection function, where "pass" means returning normally from the function (i.e.,
* without throwing an exception).
*
*
* The difference between forAll
and forEvery
is that
* forAll
will stop on the first failure, while forEvery
will continue to inspect all scala.collection.GenMap
entries after the
* first failure (and report all failures).
*
*
* @param xs the java.util.Map
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the Map
* @tparam V the type of value in the Map
* @tparam MAP subtype of java.util.Map
*
*/
inline def forAll[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](xs: MAP[K, V])(fun: ((K, V)) => ASSERTION)(implicit collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAllForMapMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-START
/**
* Ensure that all elements in a given java.util.Map
pass the given inspection function, where "pass" means returning normally from the function (i.e.,
* without throwing an exception).
*
*
* The difference between forAll
and forEvery
is that
* forAll
will stop on the first failure, while forEvery
will continue to inspect all java.util.Map
elements after the
* first failure (and report all failures).
*
*
* @param xs the java.util.Map
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the Java Map
* @tparam V the type of value in the Java Map
* @tparam JMAP subtype of java.util.Map
*
*/
inline def forAll[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](xs: JMAP[K, V])(fun: org.scalatest.Entry[K, V] => ASSERTION)(implicit collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAllForJMapMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-END
/**
* Ensure that all characters in a given String
pass the given inspection function, where "pass" means returning normally from the function (i.e.,
* without throwing an exception).
*
*
* The difference between forAll
and forEvery
is that
* forAll
will stop on the first failure, while forEvery
will continue to inspect all characters in the String
after the
* first failure (and report all failures).
*
*
* @param xs the String
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
*
*/
inline def forAll[ASSERTION, RESULT](xs: String)(fun: Char => ASSERTION)(implicit collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAllForStringMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure that at least min
number of elements of a given collection pass the given inspection function.
*
* @param min the minimum number of elements that must pass the inspection function
* @param xs the collection of elements
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam E the type of element in the collection
* @tparam C the type of collection
*
*/
inline def forAtLeast[E, C[_], ASSERTION, RESULT](min: Int, xs: C[E])(fun: E => ASSERTION)(implicit collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAtLeastMacro('{min}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure that at least min
number of elements in a given scala.collection.GenMap
pass the given inspection function.
*
* @param min the minimum number of elements that must pass the inspection function
* @param xs the scala.collection.GenMap
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the scala.collection.GenMap
* @tparam V the type of value in the scala.collection.GenMap
* @tparam MAP subtype of scala.collection.GenMap
*
*/
inline def forAtLeast[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](min: Int, xs: MAP[K, V])(fun: ((K, V)) => ASSERTION)(implicit collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAtLeastForMapMacro('{min}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-START
/**
* Ensure that at least min
number of elements in a given java.util.Map
pass the given inspection function.
*
* @param min the minimum number of elements that must pass the inspection function
* @param xs the java.util.Map
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the java.util.Map
* @tparam V the type of value in the java.util.Map
* @tparam JMAP subtype of java.util.Map
*
*/
inline def forAtLeast[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](min: Int, xs: JMAP[K, V])(fun: org.scalatest.Entry[K, V] => ASSERTION)(implicit collecting: Collecting[org.scalatest.Entry[K, V],JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAtLeastForJMapMacro('{min}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-END
/**
* Ensure that at least min
number of characters in a given String
pass the given inspection function.
*
* @param min the minimum number of characters in String
that must pass the inspection function
* @param xs the String
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
*
*/
inline def forAtLeast[ASSERTION, RESULT](min: Int, xs: String)(fun: Char => ASSERTION)(implicit collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAtLeastForStringMacro('{min}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
private def shouldIncludeIndex[T, R](xs: GenTraversable[T]) = xs.isInstanceOf[GenSeq[T]]
/**
* Ensure that at most max
number of elements of a given collection pass the given inspection function.
*
* @param max the maximum number of elements that must pass the inspection function
* @param xs the collection of elements
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam E the type of element in the collection
* @tparam C the type of collection
*/
inline def forAtMost[E, C[_], ASSERTION, RESULT](max: Int, xs: C[E])(fun: E => ASSERTION)(implicit collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAtMostMacro('{max}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure that at most max
number of elements in a given scala.collection.GenMap
pass the given inspection function.
*
* @param max the maximum number of elements in the scala.collection.GenMap
that must pass the inspection function
* @param xs the scala.collection.GenMap
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the scala.collection.GenMap
* @tparam V the type of value in the scala.collection.GenMap
* @tparam MAP subtype of scala.collection.GenMap
*/
inline def forAtMost[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](max: Int, xs: MAP[K, V])(fun: ((K, V)) => ASSERTION)(implicit collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAtMostForMapMacro('{max}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-START
/**
* Ensure that at most max
number of elements in a given java.util.Map
pass the given inspection function.
*
* @param max the maximum number of elements in the java.util.Map
that must pass the inspection function
* @param xs the java.util.Map
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the java.util.Map
* @tparam V the type of value in the java.util.Map
* @tparam JMAP subtype of java.util.Map
*/
inline def forAtMost[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](max: Int, xs: JMAP[K, V])(fun: org.scalatest.Entry[K, V] => ASSERTION)(implicit collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAtMostForJMapMacro('{max}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-END
/**
* Ensure that at most max
number of characters in a given String
pass the given inspection function.
*
* @param max the maximum number of characters in String
that must pass the inspection function
* @param xs the String
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
*/
inline def forAtMost[ASSERTION, RESULT](max: Int, xs: String)(fun: Char => ASSERTION)(implicit collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forAtMostForStringMacro('{max}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure that exactly succeededCount
number of elements of a given collection pass the given inspection function.
*
* @param succeededCount the number of elements that must pass the inspection function
* @param xs the collection of elements
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam E the type of element in the collection
* @tparam C the type of collection
*/
inline def forExactly[E, C[_], ASSERTION, RESULT](succeededCount: Int, xs: C[E])(fun: E => ASSERTION)(implicit collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forExactlyMacro('{succeededCount}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure that exactly succeededCount
number of elements in a given scala.collection.GenMap
pass the given inspection function.
*
* @param succeededCount the number of entries in the scala.collection.GenMap
that must pass the inspection function
* @param xs the scala.collection.GenMap
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the scala.collection.GenMap
* @tparam V the type of value in the scala.collection.GenMap
* @tparam MAP subtype of scala.collection.GenMap
*/
inline def forExactly[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](succeededCount: Int, xs: MAP[K, V])(fun: ((K, V)) => ASSERTION)(implicit collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forExactlyForMapMacro('{succeededCount}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-START
/**
* Ensure that exactly succeededCount
number of elements in a given java.util.Map
pass the given inspection function.
*
* @param succeededCount the number of elements in the java.util.Map
that must pass the inspection function
* @param xs the java.util.Map
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the java.util.Map
* @tparam V the type of value in the java.util.Map
* @tparam JMAP subtype of java.util.Map
*/
inline def forExactly[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](succeededCount: Int, xs: JMAP[K, V])(fun: org.scalatest.Entry[K, V] => ASSERTION)(implicit collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forExactlyForJMapMacro('{succeededCount}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-END
/**
* Ensure that exactly succeededCount
number of characters in a given String
pass the given inspection function.
*
* @param succeededCount the number of characters in the String
that must pass the inspection function
* @param xs the String
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
*/
inline def forExactly[ASSERTION, RESULT](succeededCount: Int, xs: String)(fun: Char => ASSERTION)(implicit collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forExactlyForStringMacro('{succeededCount}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
private[scalatest] inline def forNo[E, C[_], ASSERTION, RESULT](xs: C[E])(fun: E => ASSERTION)(implicit collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forNoMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
private[scalatest] inline def forNo[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](xs: MAP[K, V])(fun: ((K, V)) => ASSERTION)(implicit collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forNoForMapMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-START
private[scalatest] inline def forNo[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](xs: JMAP[K, V])(fun: org.scalatest.Entry[K, V] => ASSERTION)(implicit collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forNoForJMapMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-END
private[scalatest] inline def forNo[ASSERTION, RESULT](xs: String)(fun: Char => ASSERTION)(implicit collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forNoForStringMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure the number of elements of a given collection that pass the given inspection function is between from
and upTo
.
*
* @param from the minimum number of elements that must pass the inspection number
* @param upTo the maximum number of elements that must pass the inspection number
* @param xs the collection of elements
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam E the type of element in the collection
* @tparam C the type of collection
*/
inline def forBetween[E, C[_], ASSERTION, RESULT](from: Int, upTo: Int, xs: C[E])(fun: E => ASSERTION)(implicit collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forBetweenMacro('{from}, '{upTo}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure the number of elements in a given scala.collection.GenMap
that pass the given inspection function is between from
and upTo
.
*
* @param from the minimum number of elements in the scala.collection.GenMap
that must pass the inspection number
* @param upTo the maximum number of elements in the scala.collection.GenMap
that must pass the inspection number
* @param xs the scala.collection.GenMap
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the scala.collection.GenMap
* @tparam V the type of value in the scala.collection.GenMap
* @tparam MAP subtype of scala.collection.GenMap
*/
inline def forBetween[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](from: Int, upTo: Int, xs: MAP[K, V])(fun: ((K, V)) => ASSERTION)(implicit collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forBetweenForMapMacro('{from}, '{upTo}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-START
/**
* Ensure the number of elements in a given java.util.Map
that pass the given inspection function is between from
and upTo
.
*
* @param from the minimum number of elements in the java.util.Map
that must pass the inspection number
* @param upTo the maximum number of elements in the java.util.Map
that must pass the inspection number
* @param xs the java.util.Map
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the java.util.Map
* @tparam V the type of value in the java.util.Map
* @tparam JMAP subtype of java.util.Map
*/
inline def forBetween[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](from: Int, upTo: Int, xs: JMAP[K, V])(fun: org.scalatest.Entry[K, V] => ASSERTION)(implicit collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forBetweenForJMapMacro('{from}, '{upTo}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-END
/**
* Ensure the number of characters of a given String
that pass the given inspection function is between from
and upTo
.
*
* @param from the minimum number of characters in the String
that must pass the inspection number
* @param upTo the maximum number of characters in the String
that must pass the inspection number
* @param xs the String
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
*/
inline def forBetween[ASSERTION, RESULT](from: Int, upTo: Int, xs: String)(fun: Char => ASSERTION)(implicit collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forBetweenForStringMacro('{from}, '{upTo}, '{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure that every element in a given collection passes the given inspection function, where "pass" means returning normally from the function (i.e.,
* without throwing an exception).
*
*
* The difference between forEvery
and forAll
is that
* forEvery
will continue to inspect all elements after first failure, and report all failures,
* whereas forAll
will stop on (and only report) the first failure.
*
*
* @param xs the collection of elements
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam E the type of element in the collection
* @tparam C the type of collection
*/
inline def forEvery[E, C[_], ASSERTION, RESULT](xs: C[E])(fun: E => ASSERTION)(implicit collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forEveryMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
/**
* Ensure that every element in a given scala.collection.GenMap
passes the given inspection function, where "pass" means returning normally
* from the function (i.e., without throwing an exception).
*
*
* The difference between forEvery
and forAll
is that
* forEvery
will continue to inspect all entries in the scala.collection.GenMap
after first failure, and report all failures,
* whereas forAll
will stop on (and only report) the first failure.
*
*
* @param xs the scala.collection.GenMap
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the scala.collection.GenMap
* @tparam V the type of value in the scala.collection.GenMap
* @tparam MAP subtype of scala.collection.GenMap
*/
inline def forEvery[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](xs: MAP[K, V])(fun: ((K, V)) => ASSERTION)(implicit collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forEveryForMapMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-START
/**
* Ensure that every element in a given java.util.Map
passes the given inspection function, where "pass" means returning normally
* from the function (i.e., without throwing an exception).
*
*
* The difference between forEvery
and forAll
is that
* forEvery
will continue to inspect all elements in the java.util.Map
after first failure, and report all failures,
* whereas forAll
will stop on (and only report) the first failure.
*
*
* @param xs the java.util.Map
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
* @tparam K the type of key in the java.util.Map
* @tparam V the type of value in the java.util.Map
* @tparam JMAP subtype of java.util.Map
*/
inline def forEvery[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](xs: JMAP[K, V])(fun: org.scalatest.Entry[K, V] => ASSERTION)(implicit collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forEveryForJMapMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
// SKIP-SCALATESTJS,NATIVE-END
/**
* Ensure that every character in a given String
passes the given inspection function, where "pass" means returning normally from the function (i.e.,
* without throwing an exception).
*
*
* The difference between forEvery
and forAll
is that
* forEvery
will continue to inspect all characters in the String
after first failure, and report all failures,
* whereas forAll
will stop on (and only report) the first failure.
*
*
* @param xs the String
* @param fun the inspection function
* @param collecting the implicit Collecting
that can transform xs
into a scala.collection.GenTraversable
*/
inline def forEvery[ASSERTION, RESULT](xs: String)(fun: Char => ASSERTION)(implicit collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier): RESULT = {
${ Inspectors.forEveryForStringMacro('{xs})('{fun}, '{collecting}, '{asserting}, '{prettifier}) }
}
}
/**
* Companion object that facilitates the importing of Inspectors
members as
* an alternative to mixing it in. One use case is to import Inspectors
's members so you can use
* them in the Scala interpreter.
*/
object Inspectors extends Inspectors {
import scala.quoted._
def forAllImpl[E, C[_], ASSERTION, RESULT](xs: C[E], fun: E => ASSERTION, collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAll(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAllMacro[E, C[_], ASSERTION, RESULT](xs: Expr[C[E]])(fun: Expr[E => ASSERTION], collecting: Expr[Collecting[E, C[E]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeE: Type[E], typeC: Type[C], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAllImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAllForMapImpl[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](xs: MAP[K, V], fun: ((K, V)) => ASSERTION, collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAll(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAllForMapMacro[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](xs: Expr[MAP[K, V]])(fun: Expr[((K, V)) => ASSERTION], collecting: Expr[Collecting[(K, V), scala.collection.GenTraversable[(K, V)]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[MAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAllForMapImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAllForJMapImpl[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](xs: JMAP[K, V], fun: org.scalatest.Entry[K, V] => ASSERTION, collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAll(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAllForJMapMacro[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](xs: Expr[JMAP[K, V]])(fun: Expr[org.scalatest.Entry[K, V] => ASSERTION], collecting: Expr[Collecting[org.scalatest.Entry[K, V], JMAP[K, V]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[JMAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAllForJMapImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAllForStringImpl[ASSERTION, RESULT](xs: String, fun: Char => ASSERTION, collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAll(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAllForStringMacro[ASSERTION, RESULT](xs: Expr[String])(fun: Expr[Char => ASSERTION], collecting: Expr[Collecting[Char, String]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAllForStringImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAtLeastImpl[E, C[_], ASSERTION, RESULT](min: Int, xs: C[E], fun: E => ASSERTION, collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAtLeast(min, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAtLeastMacro[E, C[_], ASSERTION, RESULT](min: Expr[Int], xs: Expr[C[E]])(fun: Expr[E => ASSERTION], collecting: Expr[Collecting[E, C[E]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeE: Type[E], typeC: Type[C], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAtLeastImpl(${min}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAtLeastForMapImpl[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](min: Int, xs: MAP[K, V], fun: ((K, V)) => ASSERTION, collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAtLeast(min, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAtLeastForMapMacro[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](min: Expr[Int], xs: Expr[MAP[K, V]])(fun: Expr[((K, V)) => ASSERTION], collecting: Expr[Collecting[(K, V), scala.collection.GenTraversable[(K, V)]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[MAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAtLeastForMapImpl(${min}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAtLeastForJMapImpl[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](min: Int, xs: JMAP[K, V], fun: org.scalatest.Entry[K, V] => ASSERTION, collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAtLeast(min, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAtLeastForJMapMacro[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](min: Expr[Int], xs: Expr[JMAP[K, V]])(fun: Expr[org.scalatest.Entry[K, V] => ASSERTION], collecting: Expr[Collecting[org.scalatest.Entry[K, V], JMAP[K, V]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[JMAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAtLeastForJMapImpl(${min}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAtLeastForStringImpl[ASSERTION, RESULT](min: Int, xs: String, fun: Char => ASSERTION, collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAtLeast(min, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAtLeastForStringMacro[ASSERTION, RESULT](min: Expr[Int], xs: Expr[String])(fun: Expr[Char => ASSERTION], collecting: Expr[Collecting[Char, String]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAtLeastForStringImpl(${min}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAtMostImpl[E, C[_], ASSERTION, RESULT](max: Int, xs: C[E], fun: E => ASSERTION, collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAtMost(max, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAtMostMacro[E, C[_], ASSERTION, RESULT](max: Expr[Int], xs: Expr[C[E]])(fun: Expr[E => ASSERTION], collecting: Expr[Collecting[E, C[E]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeE: Type[E], typeC: Type[C], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAtMostImpl(${max}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAtMostForMapImpl[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](max: Int, xs: MAP[K, V], fun: ((K, V)) => ASSERTION, collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAtMost(max, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAtMostForMapMacro[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](max: Expr[Int], xs: Expr[MAP[K, V]])(fun: Expr[((K, V)) => ASSERTION], collecting: Expr[Collecting[(K, V), scala.collection.GenTraversable[(K, V)]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[MAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAtMostForMapImpl(${max}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAtMostForJMapImpl[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](max: Int, xs: JMAP[K, V], fun: org.scalatest.Entry[K, V] => ASSERTION, collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAtMost(max, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAtMostForJMapMacro[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](max: Expr[Int], xs: Expr[JMAP[K, V]])(fun: Expr[org.scalatest.Entry[K, V] => ASSERTION], collecting: Expr[Collecting[org.scalatest.Entry[K, V], JMAP[K, V]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[JMAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAtMostForJMapImpl(${max}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forAtMostForStringImpl[ASSERTION, RESULT](max: Int, xs: String, fun: Char => ASSERTION, collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forAtMost(max, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forAtMostForStringMacro[ASSERTION, RESULT](max: Expr[Int], xs: Expr[String])(fun: Expr[Char => ASSERTION], collecting: Expr[Collecting[Char, String]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forAtMostForStringImpl(${max}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forExactlyImpl[E, C[_], ASSERTION, RESULT](succeededCount: Int, xs: C[E], fun: E => ASSERTION, collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forExactly(succeededCount, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forExactlyMacro[E, C[_], ASSERTION, RESULT](succeededCount: Expr[Int], xs: Expr[C[E]])(fun: Expr[E => ASSERTION], collecting: Expr[Collecting[E, C[E]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeE: Type[E], typeC: Type[C], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forExactlyImpl(${succeededCount}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forExactlyForMapImpl[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](succeededCount: Int, xs: MAP[K, V], fun: ((K, V)) => ASSERTION, collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forExactly(succeededCount, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forExactlyForMapMacro[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](succeededCount: Expr[Int], xs: Expr[MAP[K, V]])(fun: Expr[((K, V)) => ASSERTION], collecting: Expr[Collecting[(K, V), scala.collection.GenTraversable[(K, V)]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[MAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forExactlyForMapImpl(${succeededCount}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forExactlyForJMapImpl[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](succeededCount: Int, xs: JMAP[K, V], fun: org.scalatest.Entry[K, V] => ASSERTION, collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forExactly(succeededCount, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forExactlyForJMapMacro[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](succeededCount: Expr[Int], xs: Expr[JMAP[K, V]])(fun: Expr[org.scalatest.Entry[K, V] => ASSERTION], collecting: Expr[Collecting[org.scalatest.Entry[K, V], JMAP[K, V]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[JMAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forExactlyForJMapImpl(${succeededCount}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forExactlyForStringImpl[ASSERTION, RESULT](succeededCount: Int, xs: String, fun: Char => ASSERTION, collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forExactly(succeededCount, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forExactlyForStringMacro[ASSERTION, RESULT](succeededCount: Expr[Int], xs: Expr[String])(fun: Expr[Char => ASSERTION], collecting: Expr[Collecting[Char, String]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forExactlyForStringImpl(${succeededCount}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forNoImpl[E, C[_], ASSERTION, RESULT](xs: C[E], fun: E => ASSERTION, collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forNo(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forNoMacro[E, C[_], ASSERTION, RESULT](xs: Expr[C[E]])(fun: Expr[E => ASSERTION], collecting: Expr[Collecting[E, C[E]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeE: Type[E], typeC: Type[C], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forNoImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forNoForMapImpl[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](xs: MAP[K, V], fun: ((K, V)) => ASSERTION, collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forNo(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forNoForMapMacro[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](xs: Expr[MAP[K, V]])(fun: Expr[((K, V)) => ASSERTION], collecting: Expr[Collecting[(K, V), scala.collection.GenTraversable[(K, V)]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[MAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forNoForMapImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forNoForJMapImpl[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](xs: JMAP[K, V], fun: org.scalatest.Entry[K, V] => ASSERTION, collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forNo(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forNoForJMapMacro[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](xs: Expr[JMAP[K, V]])(fun: Expr[org.scalatest.Entry[K, V] => ASSERTION], collecting: Expr[Collecting[org.scalatest.Entry[K, V], JMAP[K, V]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[JMAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forNoForJMapImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forNoForStringImpl[ASSERTION, RESULT](xs: String, fun: Char => ASSERTION, collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forNo(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forNoForStringMacro[ASSERTION, RESULT](xs: Expr[String])(fun: Expr[Char => ASSERTION], collecting: Expr[Collecting[Char, String]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forNoForStringImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forBetweenImpl[E, C[_], ASSERTION, RESULT](from: Int, upTo: Int, xs: C[E], fun: E => ASSERTION, collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forBetween(from, upTo, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forBetweenMacro[E, C[_], ASSERTION, RESULT](from: Expr[Int], upTo: Expr[Int], xs: Expr[C[E]])(fun: Expr[E => ASSERTION], collecting: Expr[Collecting[E, C[E]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeE: Type[E], typeC: Type[C], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forBetweenImpl(${from}, ${upTo}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forBetweenForMapImpl[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](from: Int, upTo: Int, xs: MAP[K, V], fun: ((K, V)) => ASSERTION, collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forBetween(from, upTo, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forBetweenForMapMacro[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](from: Expr[Int], upTo: Expr[Int], xs: Expr[MAP[K, V]])(fun: Expr[((K, V)) => ASSERTION], collecting: Expr[Collecting[(K, V), scala.collection.GenTraversable[(K, V)]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[MAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forBetweenForMapImpl(${from}, ${upTo}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forBetweenForJMapImpl[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](from: Int, upTo: Int, xs: JMAP[K, V], fun: org.scalatest.Entry[K, V] => ASSERTION, collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forBetween(from, upTo, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forBetweenForJMapMacro[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](from: Expr[Int], upTo: Expr[Int], xs: Expr[JMAP[K, V]])(fun: Expr[org.scalatest.Entry[K, V] => ASSERTION], collecting: Expr[Collecting[org.scalatest.Entry[K, V], JMAP[K, V]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[JMAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forBetweenForJMapImpl(${from}, ${upTo}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forBetweenForStringImpl[ASSERTION, RESULT](from: Int, upTo: Int, xs: String, fun: Char => ASSERTION, collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forBetween(from, upTo, collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forBetweenForStringMacro[ASSERTION, RESULT](from: Expr[Int], upTo: Expr[Int], xs: Expr[String])(fun: Expr[Char => ASSERTION], collecting: Expr[Collecting[Char, String]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forBetweenForStringImpl(${from}, ${upTo}, ${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forEveryImpl[E, C[_], ASSERTION, RESULT](xs: C[E], fun: E => ASSERTION, collecting: Collecting[E, C[E]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forEvery(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forEveryMacro[E, C[_], ASSERTION, RESULT](xs: Expr[C[E]])(fun: Expr[E => ASSERTION], collecting: Expr[Collecting[E, C[E]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeE: Type[E], typeC: Type[C], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forEveryImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forEveryForMapImpl[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](xs: MAP[K, V], fun: ((K, V)) => ASSERTION, collecting: Collecting[(K, V), scala.collection.GenTraversable[(K, V)]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forEvery(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forEveryForMapMacro[K, V, MAP[k, v] <: scala.collection.GenMap[k, v], ASSERTION, RESULT](xs: Expr[MAP[K, V]])(fun: Expr[((K, V)) => ASSERTION], collecting: Expr[Collecting[(K, V), scala.collection.GenTraversable[(K, V)]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[MAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forEveryForMapImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forEveryForJMapImpl[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](xs: JMAP[K, V], fun: org.scalatest.Entry[K, V] => ASSERTION, collecting: Collecting[org.scalatest.Entry[K, V], JMAP[K, V]], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forEvery(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forEveryForJMapMacro[K, V, JMAP[k, v] <: java.util.Map[k, v], ASSERTION, RESULT](xs: Expr[JMAP[K, V]])(fun: Expr[org.scalatest.Entry[K, V] => ASSERTION], collecting: Expr[Collecting[org.scalatest.Entry[K, V], JMAP[K, V]]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeK: Type[K], typeV: Type[V], typeMap: Type[JMAP], typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forEveryForJMapImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
def forEveryForStringImpl[ASSERTION, RESULT](xs: String, fun: Char => ASSERTION, collecting: Collecting[Char, String], asserting: InspectorAsserting[ASSERTION, RESULT], prettifier: Prettifier, pos: source.Position): RESULT = {
asserting.forEvery(collecting.genTraversableFrom(xs), xs, false, prettifier, pos)(fun)
}
private[scalatest] def forEveryForStringMacro[ASSERTION, RESULT](xs: Expr[String])(fun: Expr[Char => ASSERTION], collecting: Expr[Collecting[Char, String]], asserting: Expr[InspectorAsserting[ASSERTION, RESULT]], prettifier: Expr[Prettifier])(using quotes: Quotes, typeAssertion: Type[ASSERTION], typeResult: Type[RESULT]): Expr[RESULT] = {
source.Position.withPosition[RESULT]('{(pos: source.Position) => forEveryForStringImpl(${xs}, ${fun}, ${collecting}, ${asserting}, ${prettifier}, pos) })
}
}
private[scalatest] object InspectorsHelper {
def indentErrorMessages(messages: IndexedSeq[String]) = indentLines(1, messages)
def shouldPropagate(throwable: Throwable): Boolean =
throwable match {
case _: NotAllowedException |
_: TestPendingException |
_: TestCanceledException => true
case _ if Suite.anExceptionThatShouldCauseAnAbort(throwable) => true
case _ => false
}
}