mirror of
https://github.com/CatalaLang/catala.git
synced 2024-09-07 10:35:56 +03:00
tests: check the generated C code
(and update for new errors)
This commit is contained in:
parent
9af7548bf0
commit
081605d04d
4
dune
4
dune
@ -1,6 +1,6 @@
|
|||||||
(dirs runtimes compiler build_system)
|
(dirs runtimes compiler build_system tests)
|
||||||
|
|
||||||
(data_only_dirs tests syntax_highlighting)
|
(data_only_dirs syntax_highlighting)
|
||||||
|
|
||||||
(vendored_dirs catala-examples.tmp french-law.tmp)
|
(vendored_dirs catala-examples.tmp french-law.tmp)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
(documentation
|
(documentation
|
||||||
(package catala))
|
(package catala))
|
||||||
|
|
||||||
(dirs jsoo ocaml python r rescript)
|
(dirs jsoo ocaml python r rescript c)
|
||||||
|
|
||||||
; Installation is done as source under catala lib directory
|
; Installation is done as source under catala lib directory
|
||||||
; For dev version this makes it easy to install the proper runtime with just
|
; For dev version this makes it easy to install the proper runtime with just
|
||||||
|
@ -52,25 +52,31 @@ int main()
|
|||||||
{
|
{
|
||||||
char *error_kind;
|
char *error_kind;
|
||||||
switch (catala_fatal_error_raised.code)
|
switch (catala_fatal_error_raised.code)
|
||||||
{
|
{
|
||||||
case catala_no_value_provided:
|
case catala_assertion_failed:
|
||||||
error_kind = "No value provided";
|
error_kind = "an assertion doesn't hold";
|
||||||
break;
|
break;
|
||||||
case catala_conflict:
|
case catala_no_value:
|
||||||
error_kind = "Conflict between exceptions";
|
error_kind = "no applicable rule to define this variable in this situation";
|
||||||
break;
|
break;
|
||||||
case catala_crash:
|
case catala_conflict:
|
||||||
error_kind = "Crash";
|
error_kind = "conflict between multiple valid consequences for assigning the same variable";
|
||||||
break;
|
break;
|
||||||
case catala_empty:
|
case catala_division_by_zero:
|
||||||
error_kind = "Empty error not caught";
|
error_kind = "a value is being used as denominator in a division and it computed to zero";
|
||||||
break;
|
break;
|
||||||
case catala_assertion_failure:
|
case catala_not_same_length:
|
||||||
error_kind = "Asssertion failure";
|
error_kind = "traversing multiple lists of different lengths";
|
||||||
break;
|
break;
|
||||||
case catala_malloc_error:
|
case catala_uncomparable_durations:
|
||||||
|
error_kind = "ambiguous comparison between durations in different units (e.g. months vs. days)";
|
||||||
|
break;
|
||||||
|
case catala_indivisible_durations:
|
||||||
|
error_kind = "dividing durations that are not in days";
|
||||||
|
break;
|
||||||
|
case catala_malloc_error:
|
||||||
error_kind = "Malloc error";
|
error_kind = "Malloc error";
|
||||||
}
|
};
|
||||||
printf("\033[1;31m[ERROR]\033[0m %s in file %s:%d.%d-%d.%d\n",
|
printf("\033[1;31m[ERROR]\033[0m %s in file %s:%d.%d-%d.%d\n",
|
||||||
error_kind,
|
error_kind,
|
||||||
catala_fatal_error_raised.position.filename,
|
catala_fatal_error_raised.position.filename,
|
||||||
|
@ -388,6 +388,18 @@ baz_struct baz_func(baz_in_struct baz_in) {
|
|||||||
temp_c_2.code = option_3_enum_none_3_cons;
|
temp_c_2.code = option_3_enum_none_3_cons;
|
||||||
temp_c_2.payload.none_3_cons = NULL;
|
temp_c_2.payload.none_3_cons = NULL;
|
||||||
}
|
}
|
||||||
|
option_3_enum temp_c_5;
|
||||||
|
if (1 /* TRUE */) {
|
||||||
|
array_3_struct temp_c_6;
|
||||||
|
temp_c_6.content_field = catala_malloc(sizeof(array_3_struct));
|
||||||
|
|
||||||
|
option_3_enum temp_c_7 = {option_3_enum_some_3_cons,
|
||||||
|
{some_3_cons: temp_c_6}};
|
||||||
|
temp_c_5 = temp_c_7;
|
||||||
|
} else {
|
||||||
|
temp_c_5.code = option_3_enum_none_3_cons;
|
||||||
|
temp_c_5.payload.none_3_cons = NULL;
|
||||||
|
}
|
||||||
option_3_enum exception_acc_5 = {option_3_enum_none_3_cons,
|
option_3_enum exception_acc_5 = {option_3_enum_none_3_cons,
|
||||||
{none_3_cons: NULL}};
|
{none_3_cons: NULL}};
|
||||||
option_3_enum exception_current_5;
|
option_3_enum exception_current_5;
|
||||||
@ -400,6 +412,14 @@ baz_struct baz_func(baz_in_struct baz_in) {
|
|||||||
exception_acc_5 = exception_current_5;
|
exception_acc_5 = exception_current_5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
exception_current_5 = temp_c_5;
|
||||||
|
if (exception_current_5.code == option_3_enum_some_3_cons) {
|
||||||
|
if (exception_acc_5.code == option_3_enum_some_3_cons) {
|
||||||
|
exception_conflict_5 = 1;
|
||||||
|
} else {
|
||||||
|
exception_acc_5 = exception_current_5;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (exception_conflict_5) {
|
if (exception_conflict_5) {
|
||||||
catala_fatal_error_raised.code = catala_conflict;
|
catala_fatal_error_raised.code = catala_conflict;
|
||||||
catala_fatal_error_raised.position.filename = "tests/backends/simple.catala_en";
|
catala_fatal_error_raised.position.filename = "tests/backends/simple.catala_en";
|
||||||
@ -413,9 +433,9 @@ baz_struct baz_func(baz_in_struct baz_in) {
|
|||||||
temp_c_1 = exception_acc_5;
|
temp_c_1 = exception_acc_5;
|
||||||
} else {
|
} else {
|
||||||
if (0 /* FALSE */) {
|
if (0 /* FALSE */) {
|
||||||
option_3_enum temp_c_5 = {option_3_enum_none_3_cons,
|
option_3_enum temp_c_8 = {option_3_enum_none_3_cons,
|
||||||
{none_3_cons: NULL}};
|
{none_3_cons: NULL}};
|
||||||
temp_c_1 = temp_c_5;
|
temp_c_1 = temp_c_8;
|
||||||
} else {
|
} else {
|
||||||
temp_c_1.code = option_3_enum_none_3_cons;
|
temp_c_1.code = option_3_enum_none_3_cons;
|
||||||
temp_c_1.payload.none_3_cons = NULL;
|
temp_c_1.payload.none_3_cons = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user