From 7c9c0df5689c8b7ab025bc637e3819cf9387904d Mon Sep 17 00:00:00 2001 From: njlr Date: Wed, 24 Oct 2018 17:28:51 +0100 Subject: [PATCH 01/24] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RIP CodeSponsor 💀 --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 3ca1c4a..dd8d7bf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ - Sponsor - # neither A functional implementation of Either in C++14. @@ -155,5 +153,3 @@ Alternatively you can copy & paste the headers to your include path: ``` cp neither/include/*.hpp $InstallPath/include/neither ``` - - Sponsor From 3ca550ed15a3e7e6e4840a88dd9a38dd99847bd0 Mon Sep 17 00:00:00 2001 From: rvarago Date: Mon, 5 Nov 2018 19:46:02 +0100 Subject: [PATCH 02/24] Maybe: Treat hasValue with true/false instead of 1/0 Avoiding the implicit conversion from uint to bool and more clearly expressing the code intentions. Also remove the unnecessary initialization to false, because all constructor overloads already do it. --- neither/include/maybe.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neither/include/maybe.hpp b/neither/include/maybe.hpp index a4c347b..16b4e47 100644 --- a/neither/include/maybe.hpp +++ b/neither/include/maybe.hpp @@ -17,14 +17,14 @@ template struct Maybe { T value; }; - bool const hasValue = 0; + bool const hasValue; - constexpr Maybe() : hasValue{0} {} + constexpr Maybe() : hasValue{false} {} - constexpr Maybe(T const& value) : value{value}, hasValue{1} {} - constexpr Maybe(T&& value) : value{std::move(value)}, hasValue{1} {} + constexpr Maybe(T const& value) : value{value}, hasValue{true} {} + constexpr Maybe(T&& value) : value{std::move(value)}, hasValue{true} {} - constexpr Maybe(Maybe) : hasValue{0} {} + constexpr Maybe(Maybe) : hasValue{false} {} constexpr Maybe(Maybe const &o) : hasValue{o.hasValue} { if (o.hasValue) { From caf2e653c8bbc93f3b0a64e737cb3a2cdbe488ad Mon Sep 17 00:00:00 2001 From: rvarago Date: Sun, 4 Nov 2018 16:43:07 +0100 Subject: [PATCH 03/24] Maybe: Add STL compatible size() (>= C++11) Added neither::maybe::size that is compatible with std::vector::size constexpr maybe::size_type maybe::size() const noexcept See: http://www.cplusplus.com/reference/vector/vector/size --- neither/include/maybe.hpp | 5 +++++ neither/tests/maybe.cpp | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/neither/include/maybe.hpp b/neither/include/maybe.hpp index 16b4e47..5ec2448 100644 --- a/neither/include/maybe.hpp +++ b/neither/include/maybe.hpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace neither { @@ -13,6 +14,8 @@ template <> struct Maybe {}; template struct Maybe { + using size_type = std::size_t; + union { T value; }; @@ -47,6 +50,8 @@ template struct Maybe { return value; } + constexpr size_type size() const noexcept { return hasValue ? 1: 0; } + template constexpr auto map(F const &f) const& -> Maybe { diff --git a/neither/tests/maybe.cpp b/neither/tests/maybe.cpp index 10456b8..b4bb4e3 100644 --- a/neither/tests/maybe.cpp +++ b/neither/tests/maybe.cpp @@ -53,3 +53,12 @@ TEST(neither, maybe_comparison) { EXPECT_TRUE(d == d); EXPECT_TRUE(d == e); } + +TEST(neither, maybe_size) { + + auto none = maybe(); + auto some = maybe(1); + + EXPECT_EQ(none.size(), 0); + EXPECT_EQ(some.size(), 1); +} From 286f7cd5ec026aa653c874cb9d4677de8f36651f Mon Sep 17 00:00:00 2001 From: rvarago Date: Mon, 5 Nov 2018 20:03:49 +0100 Subject: [PATCH 04/24] Maybe: Add STL compatible empty() (>= C++11) Added neither::maybe::empty that is compatible with std::vector::empty constexpr bool maybe::empty() const noexcept See: http://www.cplusplus.com/reference/vector/vector/empty --- neither/include/maybe.hpp | 2 ++ neither/tests/maybe.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/neither/include/maybe.hpp b/neither/include/maybe.hpp index 5ec2448..05ce27b 100644 --- a/neither/include/maybe.hpp +++ b/neither/include/maybe.hpp @@ -52,6 +52,8 @@ template struct Maybe { constexpr size_type size() const noexcept { return hasValue ? 1: 0; } + constexpr bool empty() const noexcept { return !hasValue; } + template constexpr auto map(F const &f) const& -> Maybe { diff --git a/neither/tests/maybe.cpp b/neither/tests/maybe.cpp index b4bb4e3..dc804ed 100644 --- a/neither/tests/maybe.cpp +++ b/neither/tests/maybe.cpp @@ -62,3 +62,12 @@ TEST(neither, maybe_size) { EXPECT_EQ(none.size(), 0); EXPECT_EQ(some.size(), 1); } + +TEST(neither, maybe_empty) { + + auto none = maybe(); + auto some = maybe(1); + + EXPECT_TRUE(none.empty()); + EXPECT_FALSE(some.empty()); +} From 44a4e6ff97c55586320f8c6b2d3de4dd530cb64e Mon Sep 17 00:00:00 2001 From: Gaetano Checinski Date: Mon, 5 Nov 2018 20:02:56 +0000 Subject: [PATCH 05/24] updates buck and travis.yml --- .buckconfig | 1 + .travis.yml | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.buckconfig b/.buckconfig index 5274f36..0833408 100644 --- a/.buckconfig +++ b/.buckconfig @@ -1,4 +1,5 @@ [project] + should_remap_host_platform = true ignore = .git, .buckd [cxx] diff --git a/.travis.yml b/.travis.yml index d7e3caa..0e62bfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,19 +7,24 @@ addons: sources: - ubuntu-toolchain-r-test packages: - - g++-5 + - g++-6 + - gcc-6 before_install: - - cd /usr/bin/ && sudo rm g++ && sudo ln -s g++-5 g++ && cd - - - g++ --version - - sudo apt-get install default-jdk - - wget -O buck.deb https://github.com/facebook/buck/releases/download/v2017.09.04.02/buck-2017.09.04.02_all.deb - - sudo dpkg -i buck.deb - - wget -O buckaroo.deb https://github.com/LoopPerfect/buckaroo/releases/download/v1.3.1/buckaroo_1.3.1_amd64.deb - - sudo dpkg -i buckaroo.deb +- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90 +- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 90 +- sudo apt-get install -y equivs openjdk-8-jdk +- wget -O buck.deb https://github.com/facebook/buck/releases/download/v2018.08.27.01/buck.2018.08.27.01_all.deb +- sudo dpkg -i buck.deb +- buck --version +- wget -O buckaroo.deb https://github.com/LoopPerfect/buckaroo/releases/download/v1.4.1/buckaroo.deb +- sudo dpkg -i buckaroo.deb +- buckaroo version +- c++ --version +- g++ --version +- gcc --version script: - - buckaroo install - - buck build //:neither - - buck build //:test#linux-x86_64 - - buck run //:test#linux-x86_64 +- buckaroo install +- buck build :neither +- buck test :test From 14fa8ca53ccec18329b0357e0840392c6c4a5475 Mon Sep 17 00:00:00 2001 From: njlr Date: Mon, 5 Nov 2018 21:26:09 +0000 Subject: [PATCH 06/24] * Fixes tests --- .buckconfig | 7 +++++-- buckaroo.lock.json | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.buckconfig b/.buckconfig index 0833408..f9b66bd 100644 --- a/.buckconfig +++ b/.buckconfig @@ -1,7 +1,10 @@ [project] - should_remap_host_platform = true ignore = .git, .buckd [cxx] - cxxflags = -std=c++14 gtest_dep = google.gtest//:gtest + cxxflags = -std=c++14 + should_remap_host_platform = true + +[repositories] + google.gtest = buckaroo/official/google/gtest diff --git a/buckaroo.lock.json b/buckaroo.lock.json index 5ae8232..56173ba 100644 --- a/buckaroo.lock.json +++ b/buckaroo.lock.json @@ -6,8 +6,8 @@ "subPath": "googletest-ec44c6c1675c25b9827aacd08c02433cccde7780" }, "buck": { - "url": "https://raw.githubusercontent.com/nikhedonia/googletest/665327f0141d4a4fc4f2496e781dce436d742645/BUCK", - "sha256": "d976069f5b47fd8fc57201f47026a70dee4e47b3141ac23567b8a0c56bf9288c" + "url": "https://raw.githubusercontent.com/buckaroo-pm/google-googletest/8d62cdaa27d589789d6de0a2d507ded8f7946969/BUCK", + "sha256": "abda4caaaf855e192efddd066df0440228f35296811e4f76abf6c424d2b33f84" } } } \ No newline at end of file From 3b6ca6ee267b0bb329ca43a22444793386ed8bf4 Mon Sep 17 00:00:00 2001 From: rvarago Date: Sun, 11 Nov 2018 16:56:07 +0100 Subject: [PATCH 07/24] Maybe: Add static const object none That is an instance of type Maybe, used to represent the absence of a value. Additionally, added support for operator== and operator!= for Maybe, hence none, with the semantics: Maybe x; Maybe y; x == y => true x != y => false Given that it doesn't hold a value. Therefore, none will be always equal to itself. --- neither/include/maybe.hpp | 24 ++++++++++++++++++++---- neither/tests/maybe.cpp | 12 ++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/neither/include/maybe.hpp b/neither/include/maybe.hpp index 05ce27b..76d1e7a 100644 --- a/neither/include/maybe.hpp +++ b/neither/include/maybe.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include namespace neither { @@ -106,12 +107,25 @@ auto maybe(T value) -> Maybe { return {value}; } template auto maybe() -> Maybe { return {}; } +namespace { + + template::value>* = nullptr> + bool equal(Maybe const &a, Maybe const &b) { + if (a.hasValue) { + return b.hasValue && a.value == b.value; + } + return !b.hasValue; + } + + template ::value>* = nullptr> + bool equal(Maybe const&, Maybe const&) { + return true; + } +} + template bool operator == (Maybe const& a, Maybe const& b) { - if (a.hasValue) { - return b.hasValue && a.value == b.value; - } - return !b.hasValue; + return equal(a, b); } template @@ -119,6 +133,8 @@ bool operator != (Maybe const& a, Maybe const& b) { return !(a == b); } +static const auto none = maybe(); + } #endif diff --git a/neither/tests/maybe.cpp b/neither/tests/maybe.cpp index dc804ed..54b5120 100644 --- a/neither/tests/maybe.cpp +++ b/neither/tests/maybe.cpp @@ -55,7 +55,7 @@ TEST(neither, maybe_comparison) { } TEST(neither, maybe_size) { - + auto none = maybe(); auto some = maybe(1); @@ -64,10 +64,18 @@ TEST(neither, maybe_size) { } TEST(neither, maybe_empty) { - + auto none = maybe(); auto some = maybe(1); EXPECT_TRUE(none.empty()); EXPECT_FALSE(some.empty()); } + +TEST(neither, maybe_none) { + auto none1 = none; + auto none2 = none; + + EXPECT_TRUE(none1 == none2); + EXPECT_FALSE(none1 != none2); +} From 833a7a3c6275749725ddf83b17084a6d18508b8d Mon Sep 17 00:00:00 2001 From: njlr Date: Mon, 19 Nov 2018 17:38:39 +0000 Subject: [PATCH 08/24] Create buckaroo.toml --- buckaroo.toml | 1 + 1 file changed, 1 insertion(+) create mode 100644 buckaroo.toml diff --git a/buckaroo.toml b/buckaroo.toml new file mode 100644 index 0000000..d4bbbb8 --- /dev/null +++ b/buckaroo.toml @@ -0,0 +1 @@ +targets = [ "//:neither" ] From 0e00b01b59496d639d7a744f83851b0dbcc1266c Mon Sep 17 00:00:00 2001 From: njlr Date: Mon, 19 Nov 2018 17:54:15 +0000 Subject: [PATCH 09/24] * Moves gtest to submodule --- .buckconfig | 2 +- .gitmodules | 3 +++ BUCK | 4 ---- buckaroo.json | 1 - buckaroo.lock.json | 11 ----------- external/google-googletest | 1 + 6 files changed, 5 insertions(+), 17 deletions(-) create mode 100644 .gitmodules create mode 160000 external/google-googletest diff --git a/.buckconfig b/.buckconfig index f9b66bd..3356396 100644 --- a/.buckconfig +++ b/.buckconfig @@ -7,4 +7,4 @@ should_remap_host_platform = true [repositories] - google.gtest = buckaroo/official/google/gtest + google.gtest = external/google-googletest diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..56f06eb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/google-googletest"] + path = external/google-googletest + url = git@github.com:buckaroo-pm/google-googletest.git diff --git a/BUCK b/BUCK index 43f2bb3..f1be0f8 100644 --- a/BUCK +++ b/BUCK @@ -18,10 +18,6 @@ cxx_test( srcs = glob([ 'neither/tests/**/*.cpp', ]), - platform_linker_flags = [ - ('^linux.*', [ '-lpthread', ]), - ], - link_style = 'shared', deps = [ ':neither', ], diff --git a/buckaroo.json b/buckaroo.json index c9b34eb..22dc0b4 100644 --- a/buckaroo.json +++ b/buckaroo.json @@ -1,6 +1,5 @@ { "name": "neither", "dependencies": { - "google/gtest": "1.8.0" } } diff --git a/buckaroo.lock.json b/buckaroo.lock.json index 56173ba..7a73a41 100644 --- a/buckaroo.lock.json +++ b/buckaroo.lock.json @@ -1,13 +1,2 @@ { - "google/gtest": { - "source": { - "url": "https://github.com/google/googletest/archive/ec44c6c1675c25b9827aacd08c02433cccde7780.zip", - "sha256": "bc258fff04a6511e7106a1575bb514a185935041b2c16affb799e0567393ec30", - "subPath": "googletest-ec44c6c1675c25b9827aacd08c02433cccde7780" - }, - "buck": { - "url": "https://raw.githubusercontent.com/buckaroo-pm/google-googletest/8d62cdaa27d589789d6de0a2d507ded8f7946969/BUCK", - "sha256": "abda4caaaf855e192efddd066df0440228f35296811e4f76abf6c424d2b33f84" - } - } } \ No newline at end of file diff --git a/external/google-googletest b/external/google-googletest new file mode 160000 index 0000000..8d62cda --- /dev/null +++ b/external/google-googletest @@ -0,0 +1 @@ +Subproject commit 8d62cdaa27d589789d6de0a2d507ded8f7946969 From 51608cc0571fe15940452cc2d775111e42777d2c Mon Sep 17 00:00:00 2001 From: njlr Date: Mon, 19 Nov 2018 17:59:53 +0000 Subject: [PATCH 10/24] Update .gitmodules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 56f06eb..2344aac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "external/google-googletest"] path = external/google-googletest - url = git@github.com:buckaroo-pm/google-googletest.git + url = https://github.com/buckaroo-pm/google-googletest.git From b433263e4775287e5b020666fb28691aa6c10345 Mon Sep 17 00:00:00 2001 From: Gaetano Checinski Date: Sun, 2 Dec 2018 13:24:04 +0000 Subject: [PATCH 11/24] chore: make equals simpler --- neither/include/maybe.hpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/neither/include/maybe.hpp b/neither/include/maybe.hpp index 76d1e7a..b43f6f7 100644 --- a/neither/include/maybe.hpp +++ b/neither/include/maybe.hpp @@ -109,18 +109,17 @@ auto maybe() -> Maybe { return {}; } namespace { - template::value>* = nullptr> - bool equal(Maybe const &a, Maybe const &b) { - if (a.hasValue) { - return b.hasValue && a.value == b.value; - } - return !b.hasValue; - } + bool equal(Maybe const&, Maybe const&) { + return true; + } - template ::value>* = nullptr> - bool equal(Maybe const&, Maybe const&) { - return true; + template + bool equal(Maybe const &a, Maybe const &b) { + if (a.hasValue) { + return b.hasValue && a.value == b.value; } + return !b.hasValue; + } } template From b4121ee3d20f9e5cc4c13003c6b8377f93a10aa2 Mon Sep 17 00:00:00 2001 From: Wojciech Migda Date: Tue, 4 Dec 2018 20:42:01 +0100 Subject: [PATCH 12/24] Replace uniform initialization with copy construction --- neither/include/either.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/neither/include/either.hpp b/neither/include/either.hpp index 1ea7c1a..e656a6a 100644 --- a/neither/include/either.hpp +++ b/neither/include/either.hpp @@ -58,22 +58,22 @@ struct Either { bool const isLeft = 0; constexpr Either( Left const& l ) - : leftValue{l.value} + : leftValue(l.value) , isLeft(1) {} constexpr Either( Right const& r ) - : rightValue{r.value} + : rightValue(r.value) , isLeft(0) {} Either(Left && l ) - : leftValue{std::move(l.value)} + : leftValue(std::move(l.value)) , isLeft(1) {} Either( Right && r ) - : rightValue{std::move(r.value)} + : rightValue(std::move(r.value)) , isLeft(0) {} @@ -116,19 +116,19 @@ struct Either { } static constexpr auto leftOf( L const& l ) { - return Either{ neither::left(l) }; + return Either( neither::left(l) ); } static constexpr auto rightOf( R const& r ) { - return Either{ neither::right(r) }; + return Either( neither::right(r) ); } static constexpr auto leftOf( L && l ) { - return Either{ neither::left(std::move(l)) }; + return Either( neither::left(std::move(l)) ); } static constexpr auto rightOf( R && r ) { - return Either{ neither::right(std::move(r)) }; + return Either( neither::right(std::move(r)) ); } template< From 8256df40a69d86ec61f3ef8d93485d6391a3eae9 Mon Sep 17 00:00:00 2001 From: Wojciech Migda Date: Sun, 9 Dec 2018 15:54:30 +0100 Subject: [PATCH 13/24] Silence 'defined but not used' warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compilation of maybe.hpp with g++ 7.3 results in the following warning being emmitted (here with -Werror enabled): neither/maybe.hpp:112:8: error: ‘bool neither::{anonymous}::equal(const neither::Maybe&, const neither::Maybe&)’ defined but not used [-Werror=unused-function] bool equal(Maybe const&, Maybe const&) { --- neither/include/maybe.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/neither/include/maybe.hpp b/neither/include/maybe.hpp index b43f6f7..9078e14 100644 --- a/neither/include/maybe.hpp +++ b/neither/include/maybe.hpp @@ -109,6 +109,7 @@ auto maybe() -> Maybe { return {}; } namespace { + inline bool equal(Maybe const&, Maybe const&) { return true; } From e1d480a75e55c321323b979ffab6d9f0084db8e5 Mon Sep 17 00:00:00 2001 From: Wojciech Migda Date: Mon, 10 Dec 2018 20:20:48 +0100 Subject: [PATCH 14/24] Remove copy construction from argument to std::move in rightMap && When `rightMap` is applied to `Either` containing non-copyable type instance, such as `std::unique_ptr`, then the compiler will hard fail trying to deduce types (`rightMap &&` should be picked) because there is `(R2)` cast applied to `std::move` argument, thus forcing copy construction. `leftMap` works because it does not have such cast. --- neither/include/either.hpp | 2 +- neither/tests/either.cpp | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/neither/include/either.hpp b/neither/include/either.hpp index e656a6a..af91e5d 100644 --- a/neither/include/either.hpp +++ b/neither/include/either.hpp @@ -182,7 +182,7 @@ struct Either { } template - auto rightMap(F const& rightCase)&& -> Either { + auto rightMap(F const& rightCase)&& -> Either { using NextEither = Either; return isLeft ? NextEither::leftOf( std::move(leftValue) ) : diff --git a/neither/tests/either.cpp b/neither/tests/either.cpp index 105c09e..294549d 100644 --- a/neither/tests/either.cpp +++ b/neither/tests/either.cpp @@ -97,7 +97,7 @@ TEST(neither, either_flatMapToUnique) { } -TEST(neither, either_mapToUnique) { +TEST(neither, either_leftMapToUnique) { neither::Either e = left(1); auto u = e.leftFlatMap([](auto x) { return @@ -112,3 +112,20 @@ TEST(neither, either_mapToUnique) { ASSERT_TRUE(*u == 1); } + + +TEST(neither, either_rightMapToUnique) { + neither::Either e = right(1); + + auto u = e.rightFlatMap([](auto x) { return + Either>::rightOf( + std::make_unique(x)); + }).rightMap([](auto&& x) { + return std::move(x); + }).leftFlatMap([](auto&& x) { + return Either, std::unique_ptr>::leftOf( + std::make_unique(2)); + }).join(); + + ASSERT_TRUE(*u == 1); +} From c33420742a9f9d061677c20d999837dbb06267d4 Mon Sep 17 00:00:00 2001 From: njlr Date: Wed, 9 Jan 2019 16:43:17 +0000 Subject: [PATCH 15/24] * Migrates to Buckaroo Redux * Adds Travis build matrix --- .buckconfig | 6 +-- .gitignore | 2 + .gitmodules | 3 -- .travis.yml | 33 +++++++------- BUCK | 10 +++-- README.md | 32 ++++++------- buckaroo.json | 5 --- buckaroo.lock.json | 2 - buckaroo.lock.toml | 9 ++++ buckaroo.toml | 5 +++ external/google-googletest | 1 - subdir_glob.bzl | 82 ++++++++++++++++++++++++++++++++++ travis/before-install-linux.sh | 18 ++++++++ travis/before-install-osx.sh | 3 ++ 14 files changed, 163 insertions(+), 48 deletions(-) delete mode 100644 .gitmodules delete mode 100644 buckaroo.json delete mode 100644 buckaroo.lock.json create mode 100644 buckaroo.lock.toml delete mode 160000 external/google-googletest create mode 100644 subdir_glob.bzl create mode 100755 travis/before-install-linux.sh create mode 100755 travis/before-install-osx.sh diff --git a/.buckconfig b/.buckconfig index 3356396..ff80363 100644 --- a/.buckconfig +++ b/.buckconfig @@ -2,9 +2,7 @@ ignore = .git, .buckd [cxx] - gtest_dep = google.gtest//:gtest - cxxflags = -std=c++14 should_remap_host_platform = true -[repositories] - google.gtest = external/google-googletest +[cxx#linux-x86_64] + cxxflags = -std=c++14 diff --git a/.gitignore b/.gitignore index 6fb2d9d..dc2d1d2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ buckaroo buck-out .buckd .buckconfig.local +.buckconfig.d BUCKAROO_DEPS +buckaroo_macros.bzl diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 2344aac..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "external/google-googletest"] - path = external/google-googletest - url = https://github.com/buckaroo-pm/google-googletest.git diff --git a/.travis.yml b/.travis.yml index 0e62bfc..4781394 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,22 +9,25 @@ addons: packages: - g++-6 - gcc-6 + homebrew: + taps: + - facebook/fb + packages: + - buck + +os: + - linux + - osx + +env: + - BUCKAROO_VERSION=buckaroo-redux-alpha-8 + +osx_image: xcode9.3 before_install: -- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90 -- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 90 -- sudo apt-get install -y equivs openjdk-8-jdk -- wget -O buck.deb https://github.com/facebook/buck/releases/download/v2018.08.27.01/buck.2018.08.27.01_all.deb -- sudo dpkg -i buck.deb -- buck --version -- wget -O buckaroo.deb https://github.com/LoopPerfect/buckaroo/releases/download/v1.4.1/buckaroo.deb -- sudo dpkg -i buckaroo.deb -- buckaroo version -- c++ --version -- g++ --version -- gcc --version + - ./travis/before-install-$TRAVIS_OS_NAME.sh script: -- buckaroo install -- buck build :neither -- buck test :test + - ./buckaroo-client install + - buck build :neither + - buck test //... diff --git a/BUCK b/BUCK index f1be0f8..7f16be3 100644 --- a/BUCK +++ b/BUCK @@ -1,3 +1,6 @@ +load('//:subdir_glob.bzl', 'subdir_glob') +load('//:buckaroo_macros.bzl', 'buckaroo_deps_from_package') + prebuilt_cxx_library( name = 'neither', header_only = True, @@ -18,7 +21,8 @@ cxx_test( srcs = glob([ 'neither/tests/**/*.cpp', ]), - deps = [ - ':neither', - ], + deps = buckaroo_deps_from_package('github.com/buckaroo-pm/google-googletest') + \ + [ + ':neither', + ], ) diff --git a/README.md b/README.md index dd8d7bf..27fdb12 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A functional implementation of Either in C++14. [![Travis](https://img.shields.io/travis/LoopPerfect/neither.svg)](https://travis-ci.org/LoopPerfect/neither) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/LoopPerfect/neither/master/license) ``` -buckaroo install loopperfect/neither +buckaroo add github.com/loopperfect/neither ``` ## Examples @@ -24,15 +24,15 @@ auto unsafe = [] { // a function that throws, sometimes we can't avoid it... Either e = Try(unsafe); // let's lift the exception into the typesystem e.left() - .map([](auto const& e) { - return std::cerr << e.what() << std::endl; + .map([](auto const& e) { + return std::cerr << e.what() << std::endl; }); // print error if available int result = e .leftMap([](auto) { return 42; }) // do nothing with exception and map to 42 .rightMap([](auto x) { return x * 2; }) // do further computation if value available .join() // join both sides of either - + ASSERT_TRUE(result == 42); ``` @@ -51,7 +51,7 @@ std::string resultString = compute(5) [](auto errorStr) { return "compute said: " + errorStr; }, // error-case [](auto x) { return "compute said: " + std::to_string(x); } // success-case ); - + std::cout << resultString << std::endl; ``` @@ -91,11 +91,11 @@ Maybe compute(float x) { Maybe x = compute(-4) .map([](auto x){ return x*x;}) .map([](auto x){ return x+1 }); - + if(!x.hasValue) { std::cerr << "error occured" << std::endl; } - + ``` ### Monadic Lifting @@ -110,12 +110,12 @@ auto monadicSum = lift(sum); // transforms sum to: Maybe MonadicSum(Maybe don't use output parameters + - => don't use output parameters - Exceptions are 2-3 orders of magnitude slower if exceptions are thrown - => avoid throwing exceptions - not always possible - Overhead of exceptions grows linear with the callstack - => catch exceptions early - Exceptions are not part of the type-system - - annotating function signatures with `throw` and `noexcept` is not helpful; + - annotating function signatures with `throw` and `noexcept` is not helpful; contract breaches are not detected in compile-time but call `std::terminate` in run-time - handling exceptions is error prone and requires documentation - => encode errors in the types to enforce propper handling by the API consumer @@ -142,14 +142,16 @@ Some useful references: This library requires a C++ 14 compiler. -Install with [Buckaroo](https://buckaroo.pm): +Install with [Buckaroo](https://buckaroo.pm): + ``` -buckaroo install loopperfect/neither +buckaroo add github.com/loopperfect/neither ``` -The [Buck](https://www.buckbuild.com) target is `:neither` +The [Buck](https://www.buckbuild.com) target is `:neither` + +Alternatively you can copy & paste the headers to your include path: -Alternatively you can copy & paste the headers to your include path: ``` cp neither/include/*.hpp $InstallPath/include/neither ``` diff --git a/buckaroo.json b/buckaroo.json deleted file mode 100644 index 22dc0b4..0000000 --- a/buckaroo.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "neither", - "dependencies": { - } -} diff --git a/buckaroo.lock.json b/buckaroo.lock.json deleted file mode 100644 index 7a73a41..0000000 --- a/buckaroo.lock.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/buckaroo.lock.toml b/buckaroo.lock.toml new file mode 100644 index 0000000..0b3cb74 --- /dev/null +++ b/buckaroo.lock.toml @@ -0,0 +1,9 @@ +manifest = "eaaa6562a921b2d40d31aed0f4b442994cb5a3135397b66bbff0d1fd868b4abc" + +[[dependency]] +package = "github.com/buckaroo-pm/google-googletest" +target = "//:googletest" + +[lock."github.com/buckaroo-pm/google-googletest"] +versions = [ "branch=master" ] +revision = "cb8d2c1a2fcd344953e6c129a1a699a2c230551d" diff --git a/buckaroo.toml b/buckaroo.toml index d4bbbb8..2a1effa 100644 --- a/buckaroo.toml +++ b/buckaroo.toml @@ -1 +1,6 @@ targets = [ "//:neither" ] + +[[dependency]] +package = "github.com/buckaroo-pm/google-googletest" +version = "branch=master" +private = true diff --git a/external/google-googletest b/external/google-googletest deleted file mode 160000 index 8d62cda..0000000 --- a/external/google-googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8d62cdaa27d589789d6de0a2d507ded8f7946969 diff --git a/subdir_glob.bzl b/subdir_glob.bzl new file mode 100644 index 0000000..97950bf --- /dev/null +++ b/subdir_glob.bzl @@ -0,0 +1,82 @@ +"""Provides utility macros for working with globs.""" + +def _paths_join(path, *others): + """Joins one or more path components.""" + result = path + + for p in others: + if p.startswith("/"): # absolute + result = p + elif not result or result.endswith("/"): + result += p + else: + result += "/" + p + + return result + +def subdir_glob(glob_specs, exclude = None, prefix = ""): + """Returns a dict of sub-directory relative paths to full paths. + + The subdir_glob() function is useful for defining header maps for C/C++ + libraries which should be relative the given sub-directory. + Given a list of tuples, the form of (relative-sub-directory, glob-pattern), + it returns a dict of sub-directory relative paths to full paths. + + Please refer to native.glob() for explanations and examples of the pattern. + + Args: + glob_specs: The array of tuples in form of + (relative-sub-directory, glob-pattern inside relative-sub-directory). + type: List[Tuple[str, str]] + exclude: A list of patterns to identify files that should be removed + from the set specified by the first argument. Defaults to []. + type: Optional[List[str]] + prefix: If is not None, prepends it to each key in the dictionary. + Defaults to None. + type: Optional[str] + + Returns: + A dict of sub-directory relative paths to full paths. + """ + if exclude == None: + exclude = [] + + results = [] + + for dirpath, glob_pattern in glob_specs: + results.append( + _single_subdir_glob(dirpath, glob_pattern, exclude, prefix), + ) + + return _merge_maps(*results) + +def _merge_maps(*file_maps): + result = {} + for file_map in file_maps: + for key in file_map: + if key in result and result[key] != file_map[key]: + fail( + "Conflicting files in file search paths. " + + "\"%s\" maps to both \"%s\" and \"%s\"." % + (key, result[key], file_map[key]), + ) + + result[key] = file_map[key] + + return result + +def _single_subdir_glob(dirpath, glob_pattern, exclude = None, prefix = None): + if exclude == None: + exclude = [] + results = {} + files = native.glob([_paths_join(dirpath, glob_pattern)], exclude = exclude) + for f in files: + if dirpath: + key = f[len(dirpath) + 1:] + else: + key = f + if prefix: + key = _paths_join(prefix, key) + results[key] = f + + return results diff --git a/travis/before-install-linux.sh b/travis/before-install-linux.sh new file mode 100755 index 0000000..5fe565e --- /dev/null +++ b/travis/before-install-linux.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90 +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 90 + +c++ --version +g++ --version +gcc --version + +sudo apt-get install -y equivs openjdk-8-jdk + +wget -O buck.deb https://github.com/facebook/buck/releases/download/v2018.08.27.01/buck.2018.08.27.01_all.deb +sudo dpkg -i buck.deb +buck --version + +wget https://github.com/LoopPerfect/buckaroo/releases/download/$BUCKAROO_VERSION/buckaroo-linux -O buckaroo-client +chmod +x ./buckaroo-client +./buckaroo-client version diff --git a/travis/before-install-osx.sh b/travis/before-install-osx.sh new file mode 100755 index 0000000..c68151a --- /dev/null +++ b/travis/before-install-osx.sh @@ -0,0 +1,3 @@ +wget https://github.com/LoopPerfect/buckaroo/releases/download/$BUCKAROO_VERSION/buckaroo-macos -O buckaroo-client +chmod +x ./buckaroo-client +./buckaroo-client version From 4c3c4f2ef69e92b5080d628b2afbf3c20659c824 Mon Sep 17 00:00:00 2001 From: njlr Date: Wed, 9 Jan 2019 16:47:08 +0000 Subject: [PATCH 16/24] * Disables superconsole for Travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4781394..1a51c48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,5 +29,5 @@ before_install: script: - ./buckaroo-client install - - buck build :neither - - buck test //... + - buck build -c ui.superconsole=DISABLED :neither + - buck test -c ui.superconsole=DISABLED //... From 713c3e35f946e4d6ecc5b9156d78280c34de3ead Mon Sep 17 00:00:00 2001 From: njlr Date: Wed, 9 Jan 2019 16:49:20 +0000 Subject: [PATCH 17/24] * Migrates to SKYLARK --- .buckconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.buckconfig b/.buckconfig index ff80363..de5975b 100644 --- a/.buckconfig +++ b/.buckconfig @@ -1,6 +1,9 @@ [project] ignore = .git, .buckd +[parser] + default_build_file_syntax = SKYLARK + [cxx] should_remap_host_platform = true From f6e8b3b76dbed2159747502275826ce8035092e9 Mon Sep 17 00:00:00 2001 From: njlr Date: Wed, 9 Jan 2019 16:50:30 +0000 Subject: [PATCH 18/24] * C++ 14 for macOS --- .buckconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.buckconfig b/.buckconfig index de5975b..8debfd6 100644 --- a/.buckconfig +++ b/.buckconfig @@ -9,3 +9,6 @@ [cxx#linux-x86_64] cxxflags = -std=c++14 + +[cxx#macosx-x86_64] + cxxflags = -std=c++14 From 95c855c60c3bdab04b9d909d5b358581a8eef2d3 Mon Sep 17 00:00:00 2001 From: njlr Date: Wed, 9 Jan 2019 17:00:47 +0000 Subject: [PATCH 19/24] * Upgrades to newer Buck --- travis/before-install-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/before-install-linux.sh b/travis/before-install-linux.sh index 5fe565e..e9fbbd7 100755 --- a/travis/before-install-linux.sh +++ b/travis/before-install-linux.sh @@ -9,7 +9,7 @@ gcc --version sudo apt-get install -y equivs openjdk-8-jdk -wget -O buck.deb https://github.com/facebook/buck/releases/download/v2018.08.27.01/buck.2018.08.27.01_all.deb +wget -O buck.deb https://github.com/facebook/buck/releases/download/v2018.10.29.01/buck.2018.10.29.01_all.deb sudo dpkg -i buck.deb buck --version From 90ce0f2d25a9941be0ba294c3e8fe5955f1ca89d Mon Sep 17 00:00:00 2001 From: Ingve Vormestrand Date: Fri, 18 Jan 2019 16:40:58 +0100 Subject: [PATCH 20/24] Fix typo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 27fdb12..8c07885 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Some useful references: - annotating function signatures with `throw` and `noexcept` is not helpful; contract breaches are not detected in compile-time but call `std::terminate` in run-time - handling exceptions is error prone and requires documentation - - => encode errors in the types to enforce propper handling by the API consumer + - => encode errors in the types to enforce proper handling by the API consumer ## Installation From 30cffc1167cb628be38d77b5b09cd5400f188d21 Mon Sep 17 00:00:00 2001 From: Tilmann Date: Sat, 26 Oct 2019 21:50:17 +0200 Subject: [PATCH 21/24] all except join are now moving from lvalue --- neither/include/either.hpp | 55 +++++++++++++++++ neither/tests/either.cpp | 118 +++++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+) diff --git a/neither/include/either.hpp b/neither/include/either.hpp index af91e5d..6efebdc 100644 --- a/neither/include/either.hpp +++ b/neither/include/either.hpp @@ -150,6 +150,16 @@ struct Either { return isLeft ? std::move(leftValue) : std::move(rightValue); } + template< + class L2 = L, + class R2 = R, + typename std::enable_if::value && std::is_copy_constructible::value), int>::type = 0 + > + auto join()& + -> std::common_type_t { + return isLeft ? std::move(leftValue) : std::move(rightValue); + } + template constexpr auto join(LeftF const& leftCase, RightF const& rightCase) const -> decltype( isLeft? leftCase( leftValue ) : rightCase( rightValue ) ) { @@ -173,6 +183,16 @@ struct Either { NextEither::rightOf( std::move(rightValue) ); } + + template::value && std::is_copy_constructible::value), int>::type = 0> + auto leftMap(F const& leftCase)& -> Either { + using NextEither = Either; + return isLeft ? + NextEither::leftOf(leftCase(std::move(leftValue))) : + NextEither::rightOf( std::move(rightValue) ); + } + template constexpr auto rightMap(F const& rightCase) const& -> Either { using NextEither = Either; @@ -189,6 +209,15 @@ struct Either { NextEither::rightOf( rightCase( std::move(rightValue) ) ); } + template::value && std::is_copy_constructible::value), int>::type = 0> + auto rightMap(F const& rightCase)& -> Either { + using NextEither = Either; + return isLeft ? + NextEither::leftOf( std::move(leftValue) ) : + NextEither::rightOf( rightCase( std::move(rightValue) ) ); + } + template constexpr auto leftFlatMap(LeftCase const& leftCase) const& -> decltype( ensureEitherRight(leftCase(isCopyable((L2)leftValue)), isCopyable((R2)rightValue))) { @@ -225,6 +254,19 @@ struct Either { return NextEither::rightOf(std::move(rightValue)); } + template::value && std::is_copy_constructible::value), int>::type = 0> + auto leftFlatMap(LeftCase const& leftCase)& + -> decltype( ensureEitherRight(leftCase(std::move(leftValue)), std::move(rightValue))) { + using NextEither = decltype(leftCase(std::move(leftValue))); + + if (!*this) { + return leftCase( std::move(leftValue) ); + } + + return NextEither::rightOf(std::move(rightValue)); + } + template auto rightFlatMap(RightCase const& rightCase)&& -> decltype( ensureEitherLeft(rightCase(std::move(rightValue)), std::move(leftValue))) { @@ -237,6 +279,19 @@ struct Either { return NextEither::leftOf(std::move(leftValue)); } + template::value && std::is_copy_constructible::value), int>::type = 0> + auto rightFlatMap(RightCase const& rightCase)& + -> decltype( ensureEitherLeft(rightCase(std::move(rightValue)), std::move(leftValue))) { + using NextEither = decltype(rightCase(std::move(rightValue))); + + if (*this) { + return rightCase(std::move(rightValue)); + } + + return NextEither::leftOf(std::move(leftValue)); + } + constexpr operator bool()const { return !isLeft; } }; diff --git a/neither/tests/either.cpp b/neither/tests/either.cpp index 294549d..9a6c945 100644 --- a/neither/tests/either.cpp +++ b/neither/tests/either.cpp @@ -12,6 +12,7 @@ using namespace std::literals::string_literals; using IntOrStr = Either; using StrOrInt = Either; using StrOrStr = Either; +using PtrOrPtr = neither::Either, std::unique_ptr>; TEST(neither, either_join_left) { @@ -129,3 +130,120 @@ TEST(neither, either_rightMapToUnique) { ASSERT_TRUE(*u == 1); } + +TEST(neither, either_leftMapFromStoredUnique) +{ + neither::Either, std::unique_ptr> e = left(std::make_unique(1)); + auto u = e.leftMap([](auto x){ + return(std::move(x)); + }).join(); + + ASSERT_TRUE(*u == 1); +} + +TEST(neither, either_rightMapFromStoredUnique) +{ + neither::Either, std::unique_ptr> e = right(std::make_unique(1)); + auto u = e.rightMap([](auto x){ + return(std::move(x)); + }).join(); + + ASSERT_TRUE(*u == 1); +} + +TEST(neither, either_leftMapOfConst) +{ + const auto e = IntOrStr::leftOf(1); + const auto f = e.leftMap([](auto x){return x;}); + const auto ret = f.rightMap([](auto x){return 0;}).join(); + + ASSERT_EQ(ret, 1); +} + +TEST(neither, either_rightMapOfConst) +{ + const auto e = IntOrStr::rightOf("Hello World!"); + const auto f = e.leftMap([](auto x){return std::string("Bye World!");}); + const auto ret = f.rightMap([](auto x){return x;}).join(); + + ASSERT_EQ(ret, "Hello World!"); +} + +TEST(neither, either_leftMapNotAltered) +{ + auto e = IntOrStr::leftOf(1); + e.leftMap([](auto x){return 3;}); + const auto ret = e.rightMap([](auto right){return 0;}).join(); + + ASSERT_EQ(ret, 1); +} + +TEST(neither, either_leftMapOfConstNotAltered) +{ + const auto e = IntOrStr::leftOf(1); + e.leftMap([](auto x){return 3;}); + const auto ret = e.rightMap([](auto right){return 0;}).join(); + + ASSERT_EQ(ret, 1); +} + +TEST(neither, either_rightMapNotAltered) +{ + auto e = IntOrStr::rightOf("Hello World!"); + e.leftMap([](auto left){return "";}); + const auto ret = e.leftMap([](auto x){return std::string("Bye World!");}).join(); + + ASSERT_EQ(ret, "Hello World!"); +} + +TEST(neither, either_rightMapOfConstNotAltered) +{ + const auto e = IntOrStr::rightOf("Hello World!"); + e.leftMap([](auto left){return "";}); + const auto ret = e.leftMap([](auto x){return std::string("Bye World!");}).join(); + + ASSERT_EQ(ret, "Hello World!"); +} + +TEST(neither, either_leftFlatMapFromStoredUnique) +{ + PtrOrPtr e = left(std::make_unique(1)); + auto u = e.leftFlatMap([](auto x){ + return PtrOrPtr::leftOf(std::make_unique(0)); + }).join(); + + ASSERT_TRUE(*u == 0); +} + +TEST(neither, either_rightFlatMapFromStoredUnique) +{ + PtrOrPtr e = right(std::make_unique(1)); + auto u = e.rightFlatMap([](auto x){ + return PtrOrPtr::leftOf(std::make_unique(0)); + }).join(); + + ASSERT_TRUE(*u == 0); +} +/* +TEST(neither, either_joinFromStoredUnique) +{ + PtrOrPtr e = right(std::make_unique(1)); + auto u = e.join( + [](auto left){ + return(std::move(left)); + }, + [](auto right){ + return(std::move(right)); + } + ); + + ASSERT_EQ(*u, 1); +}*/ + +TEST(neither, either_joinFromStoredUniqueNoFunction) +{ + PtrOrPtr e = right(std::make_unique(1)); + auto u = e.join(); + + ASSERT_EQ(*u, 1); +} From 66be8e2d9310804cc095883af6d0adeb5445e05d Mon Sep 17 00:00:00 2001 From: Tilmann Date: Sat, 26 Oct 2019 22:11:53 +0200 Subject: [PATCH 22/24] working join with move --- neither/include/either.hpp | 8 ++++++++ neither/tests/either.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/neither/include/either.hpp b/neither/include/either.hpp index 6efebdc..a6d28f6 100644 --- a/neither/include/either.hpp +++ b/neither/include/either.hpp @@ -166,6 +166,14 @@ struct Either { return isLeft ? leftCase( leftValue ) : rightCase( rightValue ); } + template::value && std::is_copy_constructible::value), int>::type = 0 + > + constexpr auto join(LeftF const& leftCase, RightF const& rightCase)& + -> decltype( isLeft? leftCase(std::move(leftValue)) : rightCase(std::move(rightValue)) ){ + return isLeft ? leftCase(std::move(leftValue)) : rightCase(std::move(rightValue)); + } + template constexpr auto leftMap(F const& leftCase) const& -> Either { diff --git a/neither/tests/either.cpp b/neither/tests/either.cpp index 9a6c945..8a0d87f 100644 --- a/neither/tests/either.cpp +++ b/neither/tests/either.cpp @@ -224,21 +224,21 @@ TEST(neither, either_rightFlatMapFromStoredUnique) ASSERT_TRUE(*u == 0); } -/* + TEST(neither, either_joinFromStoredUnique) { PtrOrPtr e = right(std::make_unique(1)); auto u = e.join( [](auto left){ - return(std::move(left)); + return left; }, [](auto right){ - return(std::move(right)); + return right; } ); ASSERT_EQ(*u, 1); -}*/ +} TEST(neither, either_joinFromStoredUniqueNoFunction) { From 51dca4d781292df86c1e5cfd7ae39cd8c491aec1 Mon Sep 17 00:00:00 2001 From: Tilmann Date: Sat, 26 Oct 2019 22:18:43 +0200 Subject: [PATCH 23/24] smaller cleanup of either.cpp test --- neither/tests/either.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/neither/tests/either.cpp b/neither/tests/either.cpp index 8a0d87f..07461e2 100644 --- a/neither/tests/either.cpp +++ b/neither/tests/either.cpp @@ -133,22 +133,22 @@ TEST(neither, either_rightMapToUnique) { TEST(neither, either_leftMapFromStoredUnique) { - neither::Either, std::unique_ptr> e = left(std::make_unique(1)); + PtrOrPtr e = left(std::make_unique(1)); auto u = e.leftMap([](auto x){ return(std::move(x)); }).join(); - ASSERT_TRUE(*u == 1); + ASSERT_EQ(*u, 1); } TEST(neither, either_rightMapFromStoredUnique) { - neither::Either, std::unique_ptr> e = right(std::make_unique(1)); + PtrOrPtr e = right(std::make_unique(1)); auto u = e.rightMap([](auto x){ return(std::move(x)); }).join(); - ASSERT_TRUE(*u == 1); + ASSERT_EQ(*u, 1); } TEST(neither, either_leftMapOfConst) @@ -212,7 +212,7 @@ TEST(neither, either_leftFlatMapFromStoredUnique) return PtrOrPtr::leftOf(std::make_unique(0)); }).join(); - ASSERT_TRUE(*u == 0); + ASSERT_EQ(*u, 0); } TEST(neither, either_rightFlatMapFromStoredUnique) @@ -222,7 +222,7 @@ TEST(neither, either_rightFlatMapFromStoredUnique) return PtrOrPtr::leftOf(std::make_unique(0)); }).join(); - ASSERT_TRUE(*u == 0); + ASSERT_EQ(*u, 0); } TEST(neither, either_joinFromStoredUnique) From 9f7db873cea4edf9742407e8ea92be2e8136b791 Mon Sep 17 00:00:00 2001 From: njlr Date: Mon, 28 Oct 2019 08:41:48 +0000 Subject: [PATCH 24/24] Update before-install-osx.sh --- travis/before-install-osx.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/travis/before-install-osx.sh b/travis/before-install-osx.sh index c68151a..2e77b82 100755 --- a/travis/before-install-osx.sh +++ b/travis/before-install-osx.sh @@ -1,3 +1,6 @@ +brew tap facebook/fb +brew install buck + wget https://github.com/LoopPerfect/buckaroo/releases/download/$BUCKAROO_VERSION/buckaroo-macos -O buckaroo-client chmod +x ./buckaroo-client ./buckaroo-client version