Skip to content

Commit

Permalink
a test case about unhandled cases(show buggy compiler impl)
Browse files Browse the repository at this point in the history
  • Loading branch information
butterunderflow committed Aug 23, 2024
1 parent 07a3744 commit da9b3d9
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/cram/test_dirs/match.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,65 @@

$ ./test_match.fun.out
19981022

$ $FF test_unhandled.fun

$ cat test_unhandled.fun.cpp

#include "fun_rt.hpp"
#include <stdio.h>
#include <stdexcept>

ff_obj_t main_1__fn(ff_fvs_t fvs_1);

ff_obj_t main_1__fn(ff_fvs_t fvs_1)
{
ff_obj_t mod_11;
ff_obj_t __10;
ff_obj_t is_true_9;
ff_obj_t temp_8;
ff_obj_t __7;
ff_obj_t temp_6;
ff_obj_t app_res_5;
ff_obj_t constr0_4;
ff_obj_t match_res_3;
ff_obj_t println_str_2;
println_str_2 = ff_builtin_println_str;
do
{
constr0_4 = ff_make_constr_no_payload(0);
if(ff_match_constr(1, constr0_4))
{
temp_6 =
ff_make_str("internal error, this should never matched")
;
app_res_5 = ff_apply_generic(println_str_2, temp_6);
match_res_3 = app_res_5;
break;
}
}
while(0);
__7 = match_res_3;
temp_8 = ff_make_int(0);
is_true_9 = ff_assert(temp_8);
__10 = is_true_9;
mod_11 = ff_make_mod_obj(3, {"println_str", "_", "_"}, {println_str_2,
__7, __10});
return mod_11;
}


int main()
{
try
{
main_1__fn(nullptr);
}
catch (const std::runtime_error& error)
{
printf("Runtime error: %s", error.what());
}
}

$ ./test_unhandled.fun.out
Runtime error: Assertion failed!
11 changes: 11 additions & 0 deletions tests/cram/test_dirs/match.t/test_unhandled.fun
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
external println_str : string -> unit = "ff_builtin_println_str"

type t =
| Cons1
| Cons2

let _ =
match Cons1 with
| Cons2 -> println_str "internal error, this should never matched"

let _ = assert false

0 comments on commit da9b3d9

Please sign in to comment.