LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
applicativetest.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "applicativetest.h"
10#include <QtTest>
11#include <applicative.h>
12#include <curry.h>
13
15
16namespace LC
17{
18namespace Util
19{
20 void ApplicativeTest::testBoostOptionalPure ()
21 {
22 const auto& pure = Pure<std::optional> (2);
23 QCOMPARE (pure, std::optional<int> { 2 });
24 }
25
26 void ApplicativeTest::testBoostOptionalGSL ()
27 {
28 const auto& pure = Pure<std::optional> ([] (int a) { return ++a; });
29 const auto& app = GSL (pure, Pure<std::optional> (2));
30 QCOMPARE (app, std::optional<int> { 3 });
31 }
32
33 void ApplicativeTest::testBoostOptionalGSLCurry ()
34 {
35 const auto& summer = Pure<std::optional> (Curry ([] (int a, int b) { return a + b; }));
36 const auto& s1 = Pure<std::optional> (1);
37 const auto& s2 = Pure<std::optional> (2);
38 const auto& app = GSL (GSL (summer, s1), s2);
39 QCOMPARE (app, std::optional<int> { 3 });
40 }
41
42 void ApplicativeTest::testBoostOptionalGSLOperatorCurry ()
43 {
44 const auto& summer = Pure<std::optional> (Curry ([] (int a, int b) { return a + b; }));
45 const auto& app = summer * Pure<std::optional> (1) * Pure<std::optional> (2);
46 QCOMPARE (app, std::optional<int> { 3 });
47 }
48}
49}
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118
CurryImpl< std::decay_t< F >, Args... > Curry(F &&f, Args &&... args)
Definition curry.h:72
GSLResult_t< AF, AV > GSL(const AF &af, const AV &av)
Definition applicative.h:37
Definition constants.h:15