text stringlengths 12 786k |
|---|
let _ = U . print_header " Queue18 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 in let q1 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 in let q2 = M . empty |> M . add 4 |> M . add 5 |> M . add 6 in let edit_seq_prin... |
let _ = U . print_header " Queue19 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 in let q1 = M . empty |> M . add 2 |> M . add 3 |> M . add 1 in let q2 = M . empty |> M . add 1 |> M . add 5 |> M . add 6 in let edit_seq_prin... |
let _ = U . print_header " Queue20 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 in let q1 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 in let q2 = M . empty |> M . add 4 |> M . add 5 |> M . add 1 in let edit_seq_prin... |
let _ = U . print_header " Queue21 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 in let q1 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 4 in let q2 = M . empty |> M . add 4 |> M . add 5 |> M . add 6 in ... |
let _ = U . print_header " Queue22 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 in let q1 = M . empty |> M . add 2 |> M . add 3 |> M . add 1 in let q2 = M . empty |> M . add 1 |> M . add 4 |> M . add 5 |> M . add 3 in ... |
let _ = U . print_header " Queue23 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty in let q1 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 in let q2 = M . empty |> M . add 4 |> M . add 5 |> M . add 1 in let edit_seq_printer = U . stri... |
let _ = U . print_header " Queue24 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 in let q1 = M . empty |> M . add 2 |> M . add 3 |> M . add 1 |> M . add 4 in let q2 = M . empty |> M . add 1 |> M . add 4 |> M . add 5 in ... |
let _ = U . print_header " Queue " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty in let q1 = original |> M . add 5 in let q2 = original |> M . add 5 |> M . add 6 in let edit_seq_printer = U . string_of_list ( M . edit_to_string IntAtom . to_string )... |
let _ = U . print_header " Queue " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty in let q1 = M . empty in let q2 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 4 |> M . add 5 in let edit_seq_printer = U . string_of_list ( M . ... |
let _ = U . print_header " Queue " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 |> M . add 2 in let q1 = M . empty in let q2 = M . q_after_take original in let edit_seq_printer = U . string_of_list ( M . edit_to_string IntAtom . to_str... |
let _ = U . print_header " Queue " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty in let q1 = original |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 4 in let q2 = original |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 5 in let edit... |
let _ = U . print_header " Queue " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 4 in let q1 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 5 in let q2 = M . empty |> M... |
let _ = U . print_header " Queue1 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty in let q1 = original |> M . add 5 in let q2 = original |> M . add 5 |> M . add 6 in let edit_seq_printer = U . string_of_list ( M . edit_to_string IntAtom . to_string ... |
let _ = U . print_header " Queue2 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty in let q1 = M . empty in let q2 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 4 |> M . add 5 in let edit_seq_printer = U . string_of_list ( M .... |
let _ = U . print_header " Queue3 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 |> M . add 2 in let q1 = M . empty in let q2 = M . q_after_take original in let edit_seq_printer = U . string_of_list ( M . edit_to_string IntAtom . to_st... |
let _ = U . print_header " Queue4 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty in let q1 = original |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 4 in let q2 = original |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 5 in let edi... |
let _ = U . print_header " Queue5 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 4 in let q1 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 |> M . add 5 in let q2 = M . empty |> ... |
let _ = U . print_header " Queue6 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty in let q1 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 in let q2 = M . empty |> M . add 4 |> M . add 5 |> M . add 6 in let edit_seq_printer = U . strin... |
let _ = U . print_header " Queue7 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty in let q1 = M . empty |> M . add 1 |> M . add 2 in let q2 = M . empty |> M . add 1 |> M . add 2 in let edit_seq_printer = U . string_of_list ( M . edit_to_string... |
let _ = U . print_header " Queue8 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 |> M . add 2 in let q1 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 in let q2 = M . empty |> M . add 2 in let edit_seq_printer = U . strin... |
let _ = U . print_header " Queue9 " ; let module M = Queue_imp . Make ( IntAtom ) in let original = M . empty |> M . add 1 |> M . add 2 in let q1 = M . empty |> M . add 2 in let q2 = M . empty |> M . add 1 |> M . add 2 |> M . add 3 in let edit_seq_printer = U . strin... |
let rstate = ref None |
let set_seed seed = log " [ RANDOM ] Using random seed % d " seed ; rstate := Some ( Random . State . make [ | seed ] ) ; | ( ) |
let rec get_state ( ) = match ! rstate with let s = Random . State . make_self_init ( ) in set_seed ( Random . State . bits s ) ; get_state ( ) |
let float_stamp_range min max = let bound = max . - min in fun ( ) -> let r = Random . State . float ( get_state ( ) ) bound in let stamp = min . + r in match Ptime . ( of_float_s stamp ) with | None -> failwith ( strf " cannot convert valid random stamp % f " stamp ) | Some... |
let float_stamp_32bits = let min_stamp = Int32 . ( to_float min_int ) in let max_stamp = Int32 . ( to_float max_int ) in float_stamp_range min_stamp max_stamp |
let float_stamp : unit -> Ptime . t = let min_stamp = Ptime . ( to_float_s min ) in let max_stamp = Ptime . ( to_float_s max ) in float_stamp_range min_stamp max_stamp |
let date : unit -> ( int * int * int ) = let month_len = [ | 31 ; 28 ; 31 ; 30 ; 31 ; 30 ; 31 ; 31 ; 30 ; 31 ; 30 ; 31 ] | in let is_leap y = ( y mod 4 = 0 ) && ( y mod 100 <> 0 || y mod 400 = 0 ) in fun ( ) -> let rstate = get_state ( ) in... |
let tz_interval_s = ( 1 lsl 30 - 1 ) |
let tz_offset_s : unit -> int = fun ( ) -> let rstate = get_state ( ) in ( Random . State . int rstate tz_interval_s ) - ( tz_interval_s / 2 ) |
let min_tz_offset_s : unit -> int = fun ( ) -> let rstate = get_state ( ) in ( ( Random . State . int rstate min_tz_interval_s ) - ( min_tz_interval_s / 2 ) ) * 60 |
let time : unit -> ( int * int * int ) = fun ( ) -> let rstate = get_state ( ) in let rint bound = Random . State . int rstate bound in let hh = rint 24 in let mm = rint 60 in let ss = rint 61 in ( hh , mm , ss ) |
let loop_len = ref 100_000 |
let set_loop_len len = log " [ LOOP ] Loop iterations : % d " len ; loop_len := len |
let loop_len ( ) = ! loop_len |
let seed_opt = " - seed " , Arg . Int set_seed , " < nat > random seed to use ( auto - seeded by default ) . " |
let loop_len_opt = " - loop " , Arg . Int set_loop_len , " < nat > iterations to perform in random run loop tests ( defaults to 100_000 ) . " |
let cmdline ( ? opts = [ ] ) ( ) = let exec = Filename . basename Sys . executable_name in let usage = Printf . sprintf " Usage : % s < options >\ nOptions " : exec in let anon _ = raise ( Arg . Bad " positional arguments unsupported " ) in Arg . parse ( opts @ [ seed_... |
let test_random_double test_ctxt = let rdouble = GLib . Core . random_double ( ) in assert_equal ~ printer true ( rdouble >= 0 . 0 ) ; assert_equal ~ printer true ( rdouble <= 1 . 0 ) |
let test_random_double_range test_ctxt = let start = 5 . 0 in let stop = 6 . 0 in let rdouble = GLib . Core . random_double_range start stop in assert_equal ~ printer true ( rdouble >= start ) ; assert_equal ~ printer true ( rdouble <= stop ) |
let test_random_int test_ctxt = let open Unsigned in let rint = GLib . Core . random_int ( ) in assert_equal ~ printer true UInt32 . ( ( compare rint zero ) >= 0 ) ; assert_equal ~ printer true UInt32 . ( ( compare rint GLib . Core . c_MAXUINT32 ) <= 0 ) |
let test_random_int_range test_ctxt = let open Unsigned in let start = Int32 . of_int 10 in let stop = Int32 . of_int 21 in let rint = GLib . Core . random_int_range start stop in assert_equal ~ printer true Int32 . ( ( compare rint start ) >= 0 ) ; assert_equal ~ printer true Int32 . ( ... |
let tests = " Random functions test " >::: [ " test random double " >:: test_random_double ; " test random double range " >:: test_random_double_range ; " test random int " >:: test_random_int ; " test random int range " >:: test_random_int_range ; ] |
let ecb_selftest ( m : ( module Cipher_block . S . ECB ) ) n = let module C = ( val m ) in " selftest " >:: times ~ n @@ fun _ -> let data = Mirage_crypto_rng . generate ( C . block_size * 8 ) and key = C . of_secret @@ Mirage_crypto_rng . generate ( sample C . key_sizes... |
let cbc_selftest ( m : ( module Cipher_block . S . CBC ) ) n = let module C = ( val m ) in " selftest " >:: times ~ n @@ fun _ -> let data = Mirage_crypto_rng . generate ( C . block_size * 8 ) and iv = Mirage_crypto_rng . generate C . block_size and key = C . of_secret @@... |
let ctr_selftest ( m : ( module Cipher_block . S . CTR ) ) n = let module M = ( val m ) in let bs = M . block_size in " selftest " >:: times ~ n @@ fun _ -> let key = M . of_secret @@ Mirage_crypto_rng . generate ( sample M . key_sizes ) and ctr = Mirage_crypto_rng . genera... |
let ctr_offsets ( type c ) ~ zero ( m : ( module Cipher_block . S . CTR with type ctr = c ) ) n = let module M = ( val m ) in " offsets " >:: fun _ -> let key = M . of_secret @@ Mirage_crypto_rng . generate M . key_sizes . ( 0 ) in for i = 0 to n - 1 do let ctr = matc... |
let xor_selftest n = " selftest " >:: times ~ n @@ fun _ -> let n = Randomconv . int ~ bound : 30 Mirage_crypto_rng . generate in let ( x , y , z ) = Mirage_crypto_rng . ( generate n , generate n , generate n ) in let xyz = Uncommon . Cs . ( xor ( xor x y ) z ) and xyz ... |
let suite = " All " >::: [ " XOR " >::: [ xor_selftest 300 ] ; " 3DES - ECB " >::: [ ecb_selftest ( module Cipher_block . DES . ECB ) 100 ] ; " 3DES - CBC " >::: [ cbc_selftest ( module Cipher_block . DES . CBC ) 100 ] ; " 3DES - CTR " >::: Cipher_b... |
let ( ) = Mirage_crypto_rng_unix . initialize ( ) ; run_test_tt_main suite |
let infinite_failure = " infinite or undefined rational number " ; ; ; ; |
let r = create_ratio ( big_int_of_int 1 ) ( big_int_of_int ( - 2 ) ) in ; ; |
let r = create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) in ; ; ; ; |
let r = create_ratio ( big_int_of_int 12 ) ( big_int_of_int ( - 16 ) ) in ; ; ; ; |
let r = create_ratio ( big_int_of_int 0 ) ( big_int_of_int 0 ) in ; ; ; ; |
let r = create_normalized_ratio ( big_int_of_int 1 ) ( big_int_of_int ( - 2 ) ) in ; ; |
let r = create_normalized_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) in ; ; ; ; |
let r = create_normalized_ratio ( big_int_of_int 12 ) ( big_int_of_int ( - 16 ) ) in ; ; ; ; |
let r = create_normalized_ratio ( big_int_of_int 1 ) ( big_int_of_int 0 ) in ; ; |
let r = create_normalized_ratio ( big_int_of_int 0 ) ( big_int_of_int 0 ) in ; ; ; ; eq ( null_denominator ( create_ratio ( big_int_of_int 1 ) ( big_int_of_int ( - 2 ) ) ) , false ) ; ; ( null_denominator ( create_ratio ( big_int_of_int 1 ) zero_big_int ) , t... |
let r = create_ratio ( big_int_of_int 12 ) ( big_int_of_int ( - 16 ) ) in ; ; |
let r = create_ratio ( big_int_of_int ( - 1 ) ) zero_big_int in ; ; ; ; ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int ( - 3 ) ) ) ( big_int_of_int 1 ) , big_int_of_int ( - 1 ) ) ; ; ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) (... |
let r = add_ratio ( create_ratio ( big_int_of_int 1 ) ( big_int_of_int 2 ) ) ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) in ; ; |
let r = add_ratio ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) ( create_ratio ( big_int_of_int 1 ) ( big_int_of_int ( - 2 ) ) ) in ; ; |
let r = add_ratio ( create_ratio ( big_int_of_int 2 ) zero_big_int ) ( create_ratio ( big_int_of_int 1 ) ( big_int_of_int ( - 2 ) ) ) in ; ; |
let r = add_ratio ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) ( create_ratio ( big_int_of_int 1 ) zero_big_int ) in ; ; |
let r = add_ratio ( create_ratio ( big_int_of_int 2 ) zero_big_int ) ( create_ratio ( big_int_of_int 1 ) zero_big_int ) in ; ; |
let r = add_ratio ( create_ratio ( big_int_of_string " 12724951 " ) ( big_int_of_string " 26542080 " ) ) ( create_ratio ( big_int_of_string " - 1 " ) ( big_int_of_string " 81749606400 " ) ) in big_int_of_string " 1040259735682744320 " ) && big_int_of_string " 2169... |
let r1 , r2 = ( create_ratio ( big_int_of_string " 12724951 " ) ( big_int_of_string " 26542080 " ) , create_ratio ( big_int_of_string " - 1 " ) ( big_int_of_string " 81749606400 " ) ) in |
let bi1 = mult_big_int ( numerator_ratio r1 ) ( denominator_ratio r2 ) in big_int_of_string " 1040259735709286400 " ) && big_int_of_string " - 26542080 " ) big_int_of_string " 2169804593037312000 " ) big_int_of_string " 1040259735682744320 " ) ; ; ; ; |
let r = sub_ratio ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) ( create_ratio ( big_int_of_int 1 ) ( big_int_of_int 2 ) ) in ; ; |
let r = sub_ratio ( create_ratio ( big_int_of_int 2 ) zero_big_int ) ( create_ratio ( big_int_of_int 1 ) ( big_int_of_int ( - 2 ) ) ) in ; ; |
let r = sub_ratio ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) ( create_ratio ( big_int_of_int 1 ) zero_big_int ) in ; ; |
let r = sub_ratio ( create_ratio ( big_int_of_int 2 ) zero_big_int ) ( create_ratio ( big_int_of_int 1 ) zero_big_int ) in ; ; ; ; |
let r = mult_ratio ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) ( create_ratio ( big_int_of_int 7 ) ( big_int_of_int 5 ) ) in ; ; |
let r = mult_ratio ( create_ratio ( big_int_of_int 2 ) zero_big_int ) ( create_ratio ( big_int_of_int 1 ) ( big_int_of_int ( - 2 ) ) ) in ; ; |
let r = mult_ratio ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) ( create_ratio ( big_int_of_int 1 ) zero_big_int ) in ; ; |
let r = mult_ratio ( create_ratio ( big_int_of_int 2 ) zero_big_int ) ( create_ratio ( big_int_of_int 1 ) zero_big_int ) in ; ; ; ; |
let r = div_ratio ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) ( create_ratio ( big_int_of_int 5 ) ( big_int_of_int 7 ) ) in ; ; |
let r = div_ratio ( create_ratio ( big_int_of_int 2 ) zero_big_int ) ( create_ratio ( big_int_of_int 1 ) ( big_int_of_int ( - 2 ) ) ) in ; ; |
let r = div_ratio ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) ( create_ratio ( big_int_of_int 1 ) zero_big_int ) in ; ; |
let r = div_ratio ( create_ratio ( big_int_of_int 2 ) zero_big_int ) ( create_ratio ( big_int_of_int 1 ) zero_big_int ) in ; ; ; ; ( create_ratio ( big_int_of_int 5 ) ( big_int_of_int 3 ) ) , big_int_of_int 1 ) ; ; ( create_ratio ( big_int_of_int 5 ) ( big_int_... |
let neq_ratio x y = not ( eq_ratio x y ) ; ; create_ratio ( big_int_of_int ( - 1 ) ) zero_big_int ) ; ; create_ratio zero_big_int zero_big_int ) ; ; create_ratio zero_big_int zero_big_int ) ; ; ; ; ( create_ratio ( big_int_of_int 0 ) ( big_int_of_int 0 ) ) , 0 )... |
let nat1 = nat_of_ratio ( create_ratio ( big_int_of_int 3 ) ( big_int_of_int 1 ) ) ; ; ; ; ; ; ; ; ; ; create_ratio ( big_int_of_int 3 ) ( big_int_of_int 1 ) ) ; ; ; ; ( create_ratio ( big_int_of_int 3 ) ( big_int_of_int 1 ) ) , big_int_of_int 3 ) ... |
let s = Bytes . of_string " + 123456 " in false ) && ; ; |
let s = Bytes . of_string " 123456 " in ; ; |
let s = Bytes . of_string " - 123456 " in false ) && ; ; |
let s = Bytes . of_string " + 123496 " in false ) && ; ; |
let s = Bytes . of_string " 123496 " in ; ; |
let s = Bytes . of_string " - 123496 " in false ) && ; ; |
let s = Bytes . of_string " + 996 " in true ) && ; ; |
let s = Bytes . of_string " 996 " in ; ; |
let s = Bytes . of_string " - 996 " in true ) && ; ; |
let s = Bytes . of_string " + 6666666 " in false ) && ; ; |
let s = Bytes . of_string " 6666666 " in ; ; |
let s = Bytes . of_string " - 6666666 " in false ) && ; ; ; ; |
let s = approx_ratio_fix 5 ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 3 ) ) in ; ; ( create_ratio ( big_int_of_int 20 ) ( big_int_of_int 3 ) ) , " + 6 . 66667 " ) ; ; ( create_ratio ( big_int_of_int 2 ) ( big_int_of_int 30 ) ) , " + 0 . ... |
let ok = ref true in let p = Random . int64 0x20000000000000L and pexp = Random . int 100 and q = Random . int64 0x20000000000000L and qexp = Random . int 100 in if not ( eq_float ( float_of_ratio ( create_ratio ( shift_left_big_int ( big_int_of_int64 p ) pexp ) ( shift_left_big_int ( ... |
let make_unmanaged ~ reftyp p = Ctypes_ptr . Fat . make ~ managed : None ~ reftyp p |
let test_fabs _ = Ctypes_ffi_stubs . ( let double_ffitype = primitive_ffitype Ctypes_primitive_types . Double in let callspec = allocate_callspec ~ check_errno : false ~ runtime_lock : false ~ thread_registration : false in let arg_1_offset = add_argument callspec double_ffitype in let ( ) = prep_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.