Add Interrupt module

This commit is contained in:
Fabien Freling 2016-02-28 23:41:06 +01:00
parent de755822d3
commit 4df4aea484
4 changed files with 71 additions and 1 deletions

View file

@ -1,7 +1,7 @@
open OUnit2
let test_signed test_ctx =
let test_signed _ =
let n = 0xFA in
let s = Bit.signed_byte n in
assert_equal s (-6)

30
test/test_interrupt.ml Normal file
View file

@ -0,0 +1,30 @@
open OUnit2
let test_interrupt _ =
let input_refs = [
( 0b00000000, [] );
( 0b00000001, [ Interrupt.V_Blank ] );
( 0b00000010, [ Interrupt.LCD_Stat ] );
( 0b00000100, [ Interrupt.Timer ] );
( 0b00001000, [ Interrupt.Serial ] );
( 0b00010000, [ Interrupt.Joypad ] );
] in
let test =
function ( byte, ref_flags ) ->
let computed_flags = Interrupt.get_flags byte in
List.iter2 (fun f1 f2 -> assert_equal f1 f2) ref_flags computed_flags in
List.iter test input_refs
(* Name the test cases and group them together *)
let suite =
"suite">:::
[
"test interrupt parsing">:: test_interrupt
]
let () =
run_test_tt_main suite