mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
move MetaFeature to logic and MetaFeatureOption to APIs
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB.creating.feature
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.creating.feature.MetaFeature
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.feature
|
||||
import ch.tutteli.atrium.creating.ExperimentalComponentFactoryContainer
|
||||
import ch.tutteli.atrium.creating.build
|
||||
import ch.tutteli.atrium.logic._logic
|
||||
import ch.tutteli.atrium.reporting.MethodCallFormatter
|
||||
import kotlin.reflect.*
|
||||
|
||||
class MetaFeatureOption<T>(expect: Expect<T>) {
|
||||
|
||||
@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */)
|
||||
@UseExperimental(ExperimentalComponentFactoryContainer::class)
|
||||
private val methodCallFormatter = expect._logic.components.build<MethodCallFormatter>()
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given [property] => use [p] in case of ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(List<Int>::size)`).
|
||||
* This way we are always able to report the property, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <R> f(property: KProperty0<R>): MetaFeature<R> = p(property)
|
||||
|
||||
//@formatter:off
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] without arguments => use [f0] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <R> f(f: KFunction0<R>): MetaFeature<R> =
|
||||
f0(f)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 1 argument => use [f1] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, R> f(f: KFunction1<A1, R>, a1: A1): MetaFeature<R> =
|
||||
f1(f, a1)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 2 arguments => use [f2] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, R> f(f: KFunction2<A1, A2, R>, a1: A1, a2: A2): MetaFeature<R> =
|
||||
f2(f, a1, a2)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 3 arguments => use [f3] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, R> f(f: KFunction3<A1, A2, A3, R>, a1: A1, a2: A2, a3: A3): MetaFeature<R> =
|
||||
f3(f, a1, a2, a3)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 4 arguments => use [f4] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, A4, R> f(f: KFunction4<A1, A2, A3, A4, R>, a1: A1, a2: A2, a3: A3, a4: A4): MetaFeature<R> =
|
||||
f4(f, a1, a2, a3, a4)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 5 arguments => use [f5] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, A4, A5, R> f(f: KFunction5<A1, A2, A3, A4, A5, R>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): MetaFeature<R> =
|
||||
f5(f, a1, a2, a3, a4, a5)
|
||||
|
||||
//used to distinguish property/functions
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given property [property].
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(List<Int>::size)`).
|
||||
* This way we are always able to report the property, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <R> p(property: KProperty0<R>): MetaFeature<R> =
|
||||
MetaFeature(property.name, property.invoke())
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] without arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <R> f0(f: KFunction0<R>): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf()), f.invoke())
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 1 argument.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, R> f1(f: KFunction1<A1, R>, a1: A1): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf<Any?>(a1)), f.invoke(a1))
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 2 arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, R> f2(f: KFunction2<A1, A2, R>, a1: A1, a2: A2): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf(a1, a2)), f.invoke(a1, a2))
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 3 arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, R> f3(f: KFunction3<A1, A2, A3, R>, a1: A1, a2: A2, a3: A3): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf(a1, a2, a3)), f.invoke(a1, a2, a3))
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 4 arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, A4, R> f4(f: KFunction4<A1, A2, A3, A4, R>, a1: A1, a2: A2, a3: A3, a4: A4): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf(a1, a2, a3, a4)), f.invoke(a1, a2, a3, a4))
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 5 arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, A4, A5, R> f5(f: KFunction5<A1, A2, A3, A4, A5, R>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf(a1, a2, a3, a4, a5)), f.invoke(a1, a2, a3, a4, a5))
|
||||
//@formatter:on
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.creating.feature.MetaFeatureOption
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.creating.ExperimentalComponentFactoryContainer
|
||||
import ch.tutteli.atrium.creating.FeatureExpect
|
||||
import ch.tutteli.atrium.creating.build
|
||||
import ch.tutteli.atrium.domain.builders.creating.MetaFeatureOption
|
||||
import ch.tutteli.atrium.domain.creating.MetaFeature
|
||||
import ch.tutteli.atrium.logic.*
|
||||
import ch.tutteli.atrium.creating.feature.FeatureInfo
|
||||
import ch.tutteli.atrium.logic.creating.feature.MetaFeature
|
||||
import kotlin.reflect.*
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.feature
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.creating.feature.MetaFeature
|
||||
import ch.tutteli.atrium.api.infix.en_GB.feature
|
||||
import ch.tutteli.atrium.creating.ExperimentalComponentFactoryContainer
|
||||
import ch.tutteli.atrium.creating.build
|
||||
import ch.tutteli.atrium.logic._logic
|
||||
import ch.tutteli.atrium.reporting.MethodCallFormatter
|
||||
import kotlin.reflect.*
|
||||
|
||||
class MetaFeatureOption<T>(expect: Expect<T>) {
|
||||
|
||||
@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */)
|
||||
@UseExperimental(ExperimentalComponentFactoryContainer::class)
|
||||
private val methodCallFormatter = expect._logic.components.build<MethodCallFormatter>()
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given [property] => use [p] in case of ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(List<Int>::size)`).
|
||||
* This way we are always able to report the property, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <R> f(property: KProperty0<R>): MetaFeature<R> = p(property)
|
||||
|
||||
//@formatter:off
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] without arguments => use [f0] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <R> f(f: KFunction0<R>): MetaFeature<R> =
|
||||
f0(f)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 1 argument => use [f1] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, R> f(f: KFunction1<A1, R>, a1: A1): MetaFeature<R> =
|
||||
f1(f, a1)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 2 arguments => use [f2] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, R> f(f: KFunction2<A1, A2, R>, a1: A1, a2: A2): MetaFeature<R> =
|
||||
f2(f, a1, a2)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 3 arguments => use [f3] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, R> f(f: KFunction3<A1, A2, A3, R>, a1: A1, a2: A2, a3: A3): MetaFeature<R> =
|
||||
f3(f, a1, a2, a3)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 4 arguments => use [f4] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, A4, R> f(f: KFunction4<A1, A2, A3, A4, R>, a1: A1, a2: A2, a3: A3, a4: A4): MetaFeature<R> =
|
||||
f4(f, a1, a2, a3, a4)
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 5 arguments => use [f5] in case of
|
||||
* ambiguity issues.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, A4, A5, R> f(f: KFunction5<A1, A2, A3, A4, A5, R>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): MetaFeature<R> =
|
||||
f5(f, a1, a2, a3, a4, a5)
|
||||
|
||||
//used to distinguish property/functions
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given property [property].
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(List<Int>::size)`).
|
||||
* This way we are always able to report the property, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <R> p(property: KProperty0<R>): MetaFeature<R> =
|
||||
MetaFeature(property.name, property.invoke())
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] without arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <R> f0(f: KFunction0<R>): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf()), f.invoke())
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 1 argument.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, R> f1(f: KFunction1<A1, R>, a1: A1): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf<Any?>(a1)), f.invoke(a1))
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 2 arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, R> f2(f: KFunction2<A1, A2, R>, a1: A1, a2: A2): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf(a1, a2)), f.invoke(a1, a2))
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 3 arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, R> f3(f: KFunction3<A1, A2, A3, R>, a1: A1, a2: A2, a3: A3): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf(a1, a2, a3)), f.invoke(a1, a2, a3))
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 4 arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, A4, R> f4(f: KFunction4<A1, A2, A3, A4, R>, a1: A1, a2: A2, a3: A3, a4: A4): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf(a1, a2, a3, a4)), f.invoke(a1, a2, a3, a4))
|
||||
|
||||
/**
|
||||
* Creates a [MetaFeature] for the given function [f] which expects 5 arguments.
|
||||
*
|
||||
* Notice for assertion function writers: you should use [feature] and pass a
|
||||
* class reference instead of using this convenience function (e.g. `feature(MyClass::fun, ...)`).
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
fun <A1, A2, A3, A4, A5, R> f5(f: KFunction5<A1, A2, A3, A4, A5, R>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): MetaFeature<R> =
|
||||
MetaFeature(methodCallFormatter.formatCall(f.name, arrayOf(a1, a2, a3, a4, a5)), f.invoke(a1, a2, a3, a4, a5))
|
||||
//@formatter:on
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.feature
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.creating.MetaFeatureOption
|
||||
import ch.tutteli.atrium.domain.creating.MetaFeature
|
||||
import ch.tutteli.atrium.logic.creating.feature.MetaFeature
|
||||
|
||||
/**
|
||||
* Parameter object which combines a lambda with a [MetaFeatureOption] receiver (called [provider])
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.feature.ExtractorWithCreator
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.feature.Feature
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.feature.FeatureWithCreator
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.feature.MetaFeatureOptionWithCreator
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.feature.*
|
||||
import ch.tutteli.atrium.creating.*
|
||||
import ch.tutteli.atrium.creating.feature.FeatureInfo
|
||||
import ch.tutteli.atrium.domain.builders.creating.MetaFeatureOption
|
||||
import ch.tutteli.atrium.domain.creating.MetaFeature
|
||||
import ch.tutteli.atrium.logic.*
|
||||
import ch.tutteli.atrium.logic.creating.feature.MetaFeature
|
||||
import ch.tutteli.atrium.reporting.MethodCallFormatter
|
||||
import kotlin.reflect.*
|
||||
|
||||
|
||||
@@ -17,5 +17,6 @@ dependencies {
|
||||
//TODO 0.17.0 or 0.18.0 should not be necessary https://youtrack.jetbrains.com/issue/KT-27797
|
||||
compileTestKotlin2Js.dependsOn(
|
||||
prefixedProject('core-robstoll-js').jar,
|
||||
prefixedProject('domain-robstoll-js').jar
|
||||
prefixedProject('domain-robstoll-js').jar,
|
||||
prefixedProject('domain-builders-js').jar
|
||||
)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
//TODO remove file with 1.0.0
|
||||
@file:Suppress("DEPRECATION")
|
||||
import ch.tutteli.atrium.core.robstoll.dependOn_atrium_core_robstoll
|
||||
import ch.tutteli.atrium.domain.builders.dependOn_domain_builders
|
||||
import ch.tutteli.atrium.domain.robstoll.dependOn_atrium_domain_robstoll
|
||||
|
||||
private val currentSetupWorkaround = dep()
|
||||
private fun dep() {
|
||||
dependOn_atrium_domain_robstoll()
|
||||
dependOn_atrium_core_robstoll()
|
||||
dependOn_domain_builders()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package ch.tutteli.atrium.logic.creating.feature
|
||||
|
||||
import ch.tutteli.atrium.core.None
|
||||
import ch.tutteli.atrium.core.Option
|
||||
import ch.tutteli.atrium.core.Some
|
||||
import ch.tutteli.atrium.reporting.translating.Translatable
|
||||
import ch.tutteli.atrium.reporting.translating.Untranslatable
|
||||
|
||||
/**
|
||||
* Represents an extracted feature of type [T] defined by the given [maybeSubject] including a [description]
|
||||
* and a [representation]
|
||||
*
|
||||
* @property description Will be used in reporting to describe the feature extraction - e.g. the name of a property,
|
||||
* a method call etc.
|
||||
* @property representation The representation of the feature, in most cases the value behind the feature.
|
||||
* @property maybeSubject The feature as such where it is [Some] in case the extraction was successful or [None] if it
|
||||
* was not.
|
||||
*/
|
||||
data class MetaFeature<T>(val description: Translatable, val representation: Any?, val maybeSubject: Option<T>) {
|
||||
constructor(description: String, representation: Any?, maybeSubject: Option<T>) :
|
||||
this(Untranslatable(description), representation, maybeSubject)
|
||||
|
||||
constructor(description: String, subject: T) : this(description, subject, Some(subject))
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package ch.tutteli.atrium.logic
|
||||
import ch.tutteli.atrium.core.ExperimentalNewExpectTypes
|
||||
import ch.tutteli.atrium.core.None
|
||||
import ch.tutteli.atrium.creating.AssertionContainer
|
||||
import ch.tutteli.atrium.domain.creating.MetaFeature
|
||||
import ch.tutteli.atrium.logic.creating.feature.MetaFeature
|
||||
import ch.tutteli.atrium.logic.creating.transformers.FeatureExtractorBuilder
|
||||
import ch.tutteli.atrium.reporting.Text
|
||||
import ch.tutteli.atrium.reporting.translating.Untranslatable
|
||||
@@ -19,7 +19,6 @@ fun <T, R> AssertionContainer<T>.manualFeature(
|
||||
provider: T.() -> R
|
||||
): FeatureExtractorBuilder.ExecutionStep<T, R> = manualFeature(Untranslatable(description), provider)
|
||||
|
||||
//TODO use MetaFeature from logic with 0.16.0
|
||||
fun <T, R> AssertionContainer<T>.genericSubjectBasedFeature(
|
||||
provider: (T) -> MetaFeature<R>
|
||||
): FeatureExtractorBuilder.ExecutionStep<T, R> =
|
||||
|
||||
@@ -13,6 +13,8 @@ module ch.tutteli.atrium.logic {
|
||||
exports ch.tutteli.atrium.logic.creating.charsequence.contains.searchbehaviours;
|
||||
exports ch.tutteli.atrium.logic.creating.charsequence.contains.steps;
|
||||
|
||||
exports ch.tutteli.atrium.logic.creating.feature;
|
||||
|
||||
exports ch.tutteli.atrium.logic.creating.iterable.contains;
|
||||
exports ch.tutteli.atrium.logic.creating.iterable.contains.checkers;
|
||||
exports ch.tutteli.atrium.logic.creating.iterable.contains.creators;
|
||||
|
||||
@@ -18,6 +18,7 @@ import ch.tutteli.atrium.reporting.translating.Untranslatable
|
||||
* @property maybeSubject The feature as such where it is [Some] in case the extraction was successful or [None] if it
|
||||
* was not.
|
||||
*/
|
||||
@Deprecated("Use MetaFeature from atrium-logic; will be removed with 0.17.0")
|
||||
data class MetaFeature<T>(val description: Translatable, val representation: Any?, val maybeSubject: Option<T>) {
|
||||
constructor(description: String, representation: Any?, maybeSubject: Option<T>) :
|
||||
this(Untranslatable(description), representation, maybeSubject)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//TODO remove file with 0.17.0
|
||||
@file:Suppress("DEPRECATION", "OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE")
|
||||
@file:Suppress("DEPRECATION", "OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE", "DeprecatedCallableAddReplaceWith")
|
||||
|
||||
package ch.tutteli.atrium.domain.builders.creating
|
||||
|
||||
@@ -16,8 +16,7 @@ import kotlin.reflect.*
|
||||
* into an overload ambiguity, then either [p] (for property) or one of the `fN` functions (e.g. [f2] for
|
||||
* a function which expects 2 arguments).
|
||||
*/
|
||||
//TODO move to API, this could potentially be different per API
|
||||
//TODO deprecate in 0.16.0
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
|
||||
/**
|
||||
@@ -28,6 +27,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the property, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <R> f(property: KProperty0<R>): MetaFeature<R> = p(property)
|
||||
|
||||
//@formatter:off
|
||||
@@ -40,6 +40,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <R> f(f: KFunction0<R>): MetaFeature<R> =
|
||||
f0(f)
|
||||
|
||||
@@ -52,6 +53,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, R> f(f: KFunction1<A1, R>, a1: A1): MetaFeature<R> =
|
||||
f1(f, a1)
|
||||
|
||||
@@ -64,6 +66,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, A2, R> f(f: KFunction2<A1, A2, R>, a1: A1, a2: A2): MetaFeature<R> =
|
||||
f2(f, a1, a2)
|
||||
|
||||
@@ -76,6 +79,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, A2, A3, R> f(f: KFunction3<A1, A2, A3, R>, a1: A1, a2: A2, a3: A3): MetaFeature<R> =
|
||||
f3(f, a1, a2, a3)
|
||||
|
||||
@@ -88,6 +92,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, A2, A3, A4, R> f(f: KFunction4<A1, A2, A3, A4, R>, a1: A1, a2: A2, a3: A3, a4: A4): MetaFeature<R> =
|
||||
f4(f, a1, a2, a3, a4)
|
||||
|
||||
@@ -100,6 +105,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, A2, A3, A4, A5, R> f(f: KFunction5<A1, A2, A3, A4, A5, R>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): MetaFeature<R> =
|
||||
f5(f, a1, a2, a3, a4, a5)
|
||||
|
||||
@@ -113,6 +119,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the property, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <R> p(property: KProperty0<R>): MetaFeature<R> =
|
||||
MetaFeatureBuilder.property(property)
|
||||
|
||||
@@ -124,6 +131,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <R> f0(f: KFunction0<R>): MetaFeature<R> =
|
||||
MetaFeatureBuilder.f0(expect, f)
|
||||
|
||||
@@ -135,6 +143,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, R> f1(f: KFunction1<A1, R>, a1: A1): MetaFeature<R> =
|
||||
MetaFeatureBuilder.f1(expect, f, a1)
|
||||
|
||||
@@ -146,6 +155,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, A2, R> f2(f: KFunction2<A1, A2, R>, a1: A1, a2: A2): MetaFeature<R> =
|
||||
MetaFeatureBuilder.f2(expect, f, a1, a2)
|
||||
|
||||
@@ -157,6 +167,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, A2, A3, R> f3(f: KFunction3<A1, A2, A3, R>, a1: A1, a2: A2, a3: A3): MetaFeature<R> =
|
||||
MetaFeatureBuilder.f3(expect, f, a1, a2, a3)
|
||||
|
||||
@@ -168,6 +179,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, A2, A3, A4, R> f4(f: KFunction4<A1, A2, A3, A4, R>, a1: A1, a2: A2, a3: A3, a4: A4): MetaFeature<R> =
|
||||
MetaFeatureBuilder.f4(expect, f, a1, a2, a3, a4)
|
||||
|
||||
@@ -179,6 +191,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* This way we are always able to report the function name, even if the subject is not defined which occurs if a
|
||||
* previous transformation of the subject could not be carried out.
|
||||
*/
|
||||
@Deprecated("Use the MetaFeatureOption of your API; will be removed with 0.17.0")
|
||||
fun <A1, A2, A3, A4, A5, R> f5(f: KFunction5<A1, A2, A3, A4, A5, R>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): MetaFeature<R> =
|
||||
MetaFeatureBuilder.f5(expect, f, a1, a2, a3, a4, a5)
|
||||
|
||||
@@ -190,6 +203,7 @@ class MetaFeatureOption<T>(private val expect: Expect<T>) {
|
||||
* [Reporter]
|
||||
*/
|
||||
@Suppress("UNUSED_PARAMETER" /* we will need it as soon as methodCallFormatter is taken from the specified Reporter */)
|
||||
@Deprecated("Will be removed with 0.17.0 without replacement")
|
||||
object MetaFeatureBuilder {
|
||||
|
||||
fun <TProperty> property(property: KProperty0<TProperty>) = MetaFeature(property.name, property.invoke())
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package ch.tutteli.atrium.domain.builders
|
||||
|
||||
@Suppress("FunctionName")
|
||||
//TODO 0.17.0 remove with 0.17.0
|
||||
@Deprecated("Don't start to use, only here as workaround and will be removed with 0.17.0")
|
||||
fun dependOn_domain_builders() {
|
||||
}
|
||||
@@ -48,7 +48,9 @@ buildscript {
|
||||
"IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec",
|
||||
"IterableContainsInAnyOrderOnlyEntriesAssertionsSpec",
|
||||
"IterableContainsInOrderOnlyEntriesAssertionsSpec"
|
||||
) + ".*/returnValueOf"
|
||||
) + ".*/returnValueOf",
|
||||
// we moved MetaFeature and MetaFeatureOptions
|
||||
"FeatureAssertions.*(Manual|Reference).*Spec"
|
||||
) + ".*)",
|
||||
// removed overload which expects kClass
|
||||
"ch.tutteli.atrium.api.fluent.en_GB.samples.AnyAssertionSamples#toBeNullIfNullGivenElse"
|
||||
@@ -100,7 +102,9 @@ buildscript {
|
||||
"IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec",
|
||||
"IterableContainsInAnyOrderOnlyEntriesAssertionsSpec",
|
||||
"IterableContainsInOrderOnlyEntriesAssertionsSpec"
|
||||
) + ".*/returnValueOf"
|
||||
) + ".*/returnValueOf",
|
||||
// we moved MetaFeature and MetaFeatureOptions
|
||||
"FeatureAssertions.*(Manual|Reference).*Spec"
|
||||
) + ".*)"
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user