Add 20+ new modules with tests: Pipeline, Matrix, Tokenizer, ScopeGuard, Bitset, Optional, Counted, Curry, TypeMap, Bench, DisjointSet, Histogram, StopWatch, and more
Also fixes Diff/Memo/PriorityQueue from previous session: LineDiff is now an alias for Edit<string> so count_op/apply work on line diffs; Memoized uses std::apply instead of type-based get to handle duplicate arg types. 874/877 tests pass (3 are platform-gated plugin tests). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb4dd58500
commit
58ff7b38a0
65 files changed
+8987
-37
No files matched your search
@@ -0,0 +1,66 @@
|
||||
#include <Void/Curry/Curry.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace Void::Curry;
|
||||
|
||||
// ── curry ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test curry_binary_full_apply()
|
||||
{
|
||||
auto add = curry([](int a, int b) { return a + b; });
|
||||
Void::Testing::expect_eq(add(3)(4), 7);
|
||||
}
|
||||
|
||||
Void::Testing::Test curry_binary_partial_then_complete()
|
||||
{
|
||||
auto add = curry([](int a, int b) { return a + b; });
|
||||
auto add10 = add(10);
|
||||
Void::Testing::expect_eq(add10(5), 15);
|
||||
Void::Testing::expect_eq(add10(20), 30);
|
||||
}
|
||||
|
||||
Void::Testing::Test curry_ternary()
|
||||
{
|
||||
auto sum3 = curry([](int a, int b, int c) { return a + b + c; });
|
||||
Void::Testing::expect_eq(sum3(1)(2)(3), 6);
|
||||
}
|
||||
|
||||
Void::Testing::Test curry_ternary_partial_twice()
|
||||
{
|
||||
auto sum3 = curry([](int a, int b, int c) { return a + b + c; });
|
||||
const auto sum3_with_1 = sum3(1);
|
||||
const auto sum3_with_1_2 = sum3_with_1(2);
|
||||
Void::Testing::expect_eq(sum3_with_1_2(10), 13);
|
||||
}
|
||||
|
||||
Void::Testing::Test curry_type_change()
|
||||
{
|
||||
auto prefix = curry([](std::string p, std::string s) { return p + s; });
|
||||
const auto add_hello = prefix(std::string{"hello "});
|
||||
Void::Testing::expect_eq(add_hello(std::string{"world"}), std::string{"hello world"});
|
||||
}
|
||||
|
||||
Void::Testing::Test curry_unary_invokes_immediately()
|
||||
{
|
||||
auto square = curry([](int x) { return x * x; });
|
||||
Void::Testing::expect_eq(square(5), 25);
|
||||
}
|
||||
|
||||
Void::Testing::Test curry_reuse_partial()
|
||||
{
|
||||
auto mul = curry([](int a, int b) { return a * b; });
|
||||
const auto triple = mul(3);
|
||||
Void::Testing::expect_eq(triple(4), 12);
|
||||
Void::Testing::expect_eq(triple(5), 15);
|
||||
Void::Testing::expect_eq(triple(6), 18);
|
||||
}
|
||||
|
||||
Void::Testing::Test curry_with_lambda_capture()
|
||||
{
|
||||
int offset = 100;
|
||||
auto add_offset = curry([&](int a, int b) { return a + b + offset; });
|
||||
Void::Testing::expect_eq(add_offset(1)(2), 103);
|
||||
}
|
||||
Reference in new issue
Block a user