Skip to content

Commit 228386f

Browse files
committed
Replace trivial true/true assertions in test_function_pointers.ml with meaningful checks
Signed-off-by: Cong Wang <cwang@multikernel.io>
1 parent 6e5f0a1 commit 228386f

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

tests/test_function_pointers.ml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,22 @@ fn test_function() -> i32 {
109109
(* Check EventHandler type alias *)
110110
let event_handler = List.find (fun (name, _) -> name = "EventHandler") type_aliases in
111111
(match snd event_handler with
112-
| Function ([U32; Pointer U8], I32) -> check bool "EventHandler type correct" true true
112+
| Function ([U32; Pointer U8], I32) -> ()
113113
| _ -> fail "EventHandler should be fn(u32, *u8) -> i32");
114114

115115
(* Check SimpleCallback type alias *)
116116
let simple_callback = List.find (fun (name, _) -> name = "SimpleCallback") type_aliases in
117117
(match snd simple_callback with
118-
| Function ([], Void) -> check bool "SimpleCallback type correct" true true
118+
| Function ([], Void) -> ()
119119
| _ -> fail "SimpleCallback should be fn() -> void");
120120

121121
(* Test that type checking succeeds *)
122122
let symbol_table = build_symbol_table ast in
123123
try
124-
let _typed_ast = type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
125-
check bool "Type checking should succeed" true true
124+
let (typed_ast, _) = type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
125+
check bool "Type checking should succeed" true (List.length typed_ast > 0)
126126
with
127-
| _ -> fail "Type checking should not raise an exception"
127+
| e -> fail ("Type checking failed: " ^ Printexc.to_string e)
128128

129129
(** Test function pointer call parsing *)
130130
let test_function_pointer_call_parsing () =
@@ -156,7 +156,6 @@ fn test_function() -> i32 {
156156
| Call (callee_expr, args) ->
157157
(match callee_expr.expr_desc with
158158
| Identifier "handler" ->
159-
check bool "Function call parsed correctly" true true;
160159
check int "arg count" 1 (List.length args)
161160
| _ -> fail "Expected handler identifier")
162161
| _ -> fail "Expected function call (parser treats function pointer calls as function calls)")
@@ -177,10 +176,10 @@ fn test_function() -> i32 {
177176

178177
(* This should not raise an exception *)
179178
try
180-
let _typed_ast = type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
181-
check bool "Type checking should succeed" true true
179+
let (typed_ast, _) = type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
180+
check bool "Type checking should succeed" true (List.length typed_ast > 0)
182181
with
183-
| _ -> fail "Type checking should not raise an exception"
182+
| e -> fail ("Type checking failed: " ^ Printexc.to_string e)
184183

185184
(** Test function pointer type mismatch errors *)
186185
let test_function_pointer_type_errors () =
@@ -269,8 +268,8 @@ fn setup_network() -> i32 {
269268

270269
(* This should not raise an exception *)
271270
try
272-
let _typed_ast = type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
273-
check bool "Complex function pointer type checking should succeed" true true
271+
let (typed_ast, _) = type_check_and_annotate_ast ~symbol_table:(Some symbol_table) ast in
272+
check bool "Complex function pointer type checking should succeed" true (List.length typed_ast > 0)
274273
with
275274
| e ->
276275
let msg = Printexc.to_string e in
@@ -363,7 +362,7 @@ fn main() -> i32 {
363362
let has_function_pointer_calls = try ignore (Str.search_forward (Str.regexp "var_\\(add_op\\|mul_op\\)(") c_code 0); true with Not_found -> false in
364363
check bool "C code should contain function pointer calls" true has_function_pointer_calls;
365364

366-
check bool "Test passed - function pointer calls generate correct IR" true true
365+
()
367366

368367
with
369368
| exn ->

0 commit comments

Comments
 (0)