Hash :
b6f02530
Author :
Thomas de Grivel
Date :
2023-11-09T21:26:09
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/* c3
* Copyright 2022,2023 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#include <string.h>
#include "../libc3/fn.h"
#include "test.h"
#define FN_TEST_INIT_1(test) \
do { \
TEST_EQ(fn_init_1(&f, (test)), &f); \
fn_clean(&f); \
} while (0)
TEST_CASE_PROTOTYPE(fn_init_1);
void fn_test (void);
void fn_test (void)
{
TEST_CASE_RUN(fn_init_1);
}
TEST_CASE(fn_init_1)
{
s_fn f;
FN_TEST_INIT_1("fn (x) { x }");
FN_TEST_INIT_1("fn (x) { x * 2 }");
FN_TEST_INIT_1("fn (x, y) { x + y }");
FN_TEST_INIT_1("fn { (x) { x } (x, y) { x + y } }");
FN_TEST_INIT_1("fn { ([]) { :error } ([x | _y]) { x } (_) { :error } }");
}
TEST_CASE_END(fn_init_1)