diff --git a/m-core.h b/m-core.h index 40c125d5..5bfb7986 100644 --- a/m-core.h +++ b/m-core.h @@ -2143,10 +2143,11 @@ m_core_hash (const void *str, size_t length) // 5b. Define with arguments ==> use INIT_SET (INIT_WITH support pending) #define M_LETI_SINGLE2_SET(cont, oplist, name, ...) \ for(M_GET_TYPE oplist name; \ - cont && (M_GET_INIT_SET oplist (name, __VA_ARGS__), true); \ + cont && (M_LETI_SINGLE2_INIT(oplist, name, __VA_ARGS__), true); \ (M_GET_CLEAR oplist (name), cont = false)) \ for(;cont;cont = false) - +#define M_LETI_SINGLE2_INIT(oplist, name, ...) \ + M_IF_METHOD(INIT_WITH,oplist)(M_GET_INIT_WITH oplist (name, __VA_ARGS__), M_GET_INIT_SET oplist (name, __VA_ARGS__)) /* Transform the va list by adding their number as the first argument of the list. diff --git a/tests/test-mcore.c b/tests/test-mcore.c index 09350a76..d4b6b224 100644 --- a/tests/test-mcore.c +++ b/tests/test-mcore.c @@ -171,14 +171,20 @@ static void test_map(void) static void test_let(void) { + bool b = false; M_LET(z, M_CLASSIC_OPLIST(testobj)) { - testobj_add(z,z,z); + testobj_set_ui(z, 12); M_LET((zz,z), M_CLASSIC_OPLIST(testobj)) { - testobj_add(zz,zz,z); + assert( testobj_cmp_ui(zz, 12) == 0); } + M_LET((zz,42), M_OPEXTEND(M_CLASSIC_OPLIST(testobj), INIT_WITH(testobj_init_set_ui))) { + assert( testobj_cmp_ui(zz, 42) == 0); + } + b = true; break; assert(0); } + assert(b); } static void test_va(void)