From af801d86e84ab2e4fca588f684af46c9e505964b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tau=20G=C3=A4rtli?= Date: Fri, 24 Jan 2025 13:41:14 +0100 Subject: [PATCH] Add unit test for Apply --- Funcky.Test/FunctionalClass/ApplyTest.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Funcky.Test/FunctionalClass/ApplyTest.cs diff --git a/Funcky.Test/FunctionalClass/ApplyTest.cs b/Funcky.Test/FunctionalClass/ApplyTest.cs new file mode 100644 index 00000000..6aae2e35 --- /dev/null +++ b/Funcky.Test/FunctionalClass/ApplyTest.cs @@ -0,0 +1,23 @@ +using static Funcky.Discard; + +namespace Funcky.Test.FunctionalClass; + +public class ApplyTest +{ + [Fact] + public void CanApplyParametersInAnyOrder() + { + var func = Linear0; + var f1 = Fn(Linear0).Apply(__, __, 10); + var f2 = func.Apply(2, __, 7); + var f3 = Apply(Fn(Linear0), 42, __, __); + Assert.Equal(Linear0(10, 2, 10), f1(10, 2)); + Assert.Equal(Linear0(2, 10, 7), f2(10)); + Assert.Equal(Linear0(42, 10, 2), f3(10, 2)); + } + + public static T Fn(T value) => value; + + private static int Linear0(int a, int b, int c) + => a + (b * c); +}