text stringlengths 0 601k |
|---|
let test_check_noreturn context = let assert_type_errors = assert_type_errors ~ context in assert_type_errors { | import typing def no_return ( ) -> typing . NoReturn : return 0 } | [ " Incompatible return type [ 7 ] : Expected ` NoReturn ` but got ` int ` . " ] ; assert_type_errors { | import typing def no_return ( ) ... |
let test_check_return_unimplemented context = let assert_strict_type_errors = assert_strict_type_errors ~ context in let assert_default_type_errors = assert_default_type_errors ~ context in assert_strict_type_errors { | def f ( ) -> int : pass } | [ " Incompatible return type [ 7 ] : Expected ` int ` but got implicit r... |
let ( ) = " return " >::: [ " check_return " >:: test_check_return ; " check_return_control_flow " >:: test_check_return_control_flow ; " check_collections " >:: test_check_collections ; " check_meta_annotations " >:: test_check_meta_annotations ; " check_noreturn " >:: test_check_noreturn ; " check_return_unimplemente... |
let test dom = let elem = dom |> getElementById " haha " in match elem with | None -> 1 | Some ui -> Js . log ui ; 2 |
let f_undefined xs i = match get_undefined xs i with | None -> assert false | Some k -> k |
let f_escaped_not xs i = let x = get_undefined xs i in Js . log " hei " ; match x with | Some k -> k | None -> 1 |
let f_escaped_1 xs i = let x = get_undefined xs i in fun ( ) -> match x with | Some k -> k | None -> 1 |
let f_escaped_2 xs i = Js . log ( get_undefined xs i ) |
let f_null xs i = match get_null xs i with | None -> assert false | Some k -> k |
let f_null_undefined xs i = match get_null_undefined xs i with | None -> assert false | Some k -> k |
let test_reveal_locals context = let assert_type_errors = assert_type_errors ~ context in let assert_default_type_errors = assert_default_type_errors ~ context in assert_type_errors { | def f ( a : int , b : int ) -> int : c = a + b reveal_locals ( ) return c } | [ { | Revealed locals [ - 2 ] : Revealed local types are... |
let ( ) = " revealLocals " >::: [ " reveal_locals " >:: test_reveal_locals ] |> Test . run |
let test_reveal_type context = let assert_type_errors = assert_type_errors ~ context in let assert_default_type_errors = assert_default_type_errors ~ context in assert_type_errors { | def foo ( x : str ) -> None : reveal_type ( x ) } | [ " Revealed type [ - 1 ] : Revealed type for ` x ` is ` str ` . " ] ; assert_type_e... |
let ( ) = " revealType " >::: [ " reveal_type " >:: test_reveal_type ] |> Test . run |
let rec print_args list = match list with [ ] -> ( ) | x :: tail -> |
let enter name list = if verbose then begin Printf . fprintf stderr " % s " : name ; print_args list ; Printf . fprintf stderr " \ n " %! end |
let arch64 = match Sys . word_size with 32 -> false | 64 -> true | _ -> assert false |
module LineReader : sig val read : Unix . file_descr -> int -> ( string -> int -> int -> unit ) -> unit let read ic maxlen handler = let s = String . create maxlen in let rec iter begin_pos pos = let to_read = maxlen - pos in and iter2 begin_pos pos end_pos = if pos = end_pos then else in iter 0 0 end |
let t = String . make 256 ' ' |
let b = String . make 61 ' \ n ' |
let bi = ref 1 |
let _ = String . blit " TVGHEFCDIJMLKNOPQYSAABWXRZ " 0 t 65 26 ; String . blit t 65 t 97 26 ; ; |
let t = let s = Array . create 256 ' ' in for i = 0 to 255 do s . ( i ) <- t . [ i ] done ; s ; ; |
module Fasta : sig val clear : unit -> unit val flush : unit -> unit val print : string -> int -> int -> unit let printed = ref 0 let clear ( ) = printed := 0 let flush ( ) = if ! printed > 0 then print_newline ( ) ; printed := 0 let rec print s pos len = if len > 60 then begin output stdout s pos 60 ; output_char stdo... |
module IMPLEMENTATION32 : sig val main : unit -> unit |
module BigRevBuffer : sig val clear : unit -> unit val length : unit -> int val add : string -> int -> int -> unit val reverse_iter : unit -> unit let nbuffers = if arch64 then 0 else 256 let buffer_len = 1_000_000 let buffers = Array . init nbuffers ( fun _ -> String . create buffer_len ) let buffer_pos = Array . crea... |
let reverse ( ) = if BigRevBuffer . length ( ) > 0 then begin Fasta . clear ( ) ; BigRevBuffer . reverse_iter ( ) ; BigRevBuffer . clear ( ) ; Fasta . flush ( ) end |
let main ( ) = try LineReader . read Unix . stdin 1_000_000 ( fun s pos len -> ) with End_of_file -> reverse ( ) | e -> end |
module IMPLEMENTATION64 : sig val main : unit -> unit let buffer_len = 150_000_000 let buffer = if arch64 then String . create buffer_len else " " let buffer_pos = ref buffer_len let wait_for = ref None let reverse ( ) = begin match ! wait_for with end ; let len = buffer_len - ! buffer_pos in if len > 0 then begin end ... |
let rec iter1 begin_pos ( ) pos = let to_read = maxlen - pos in if to_read < 32_000 then begin let len = pos - begin_pos in end else let nread = Unix . read Unix . stdin inbuf pos to_read in if pos = end_pos then iter1 begin_pos ( ) end_pos else match inbuf . [ pos ] with | ' ' > -> | c -> let to_read = maxlen - pos in... |
let read ( ) = iter1 0 ( ) 0 |
let main ( ) = enter " main64 " [ ] ; try read ( ) with End_of_file -> reverse ( ) | e -> end |
let _ = if arch64 then IMPLEMENTATION64 . main ( ) else IMPLEMENTATION32 . main ( ) |
let complement = let cplt = Array . init 256 ( fun i -> Char . chr i ) in List . iter ( fun ( c1 , c2 ) -> [ ( ' A ' , ' T ' ) ; ( ' C ' , ' G ' ) ; ( ' B ' , ' V ' ) ; ( ' D ' , ' H ' ) ; ( ' K ' , ' M ' ) ; ( ' R ' , ' Y ' ) ] ; cplt |
let reverse s = let rec rev i j = if i < j then ( let si = s . [ i ] in s . [ i ] <- complement . ( Char . code s . [ j ] ) ; s . [ j ] <- complement . ( Char . code si ) ; rev ( i + 1 ) ( j - 1 ) ) in rev 0 ( String . length s - 1 ) ; s |
let print_fasta = let rec print60 pos len dna = if len > 60 then ( output stdout dna pos 60 ; print_string " \ n " ; print60 ( pos + 60 ) ( len - 60 ) dna ) else ( output stdout dna pos len ; print_string " \ n " ) in fun dna -> print60 0 ( String . length dna ) dna |
let ( ) = Gc . set { ( Gc . get ( ) ) with Gc . max_overhead = - 1 ; space_overhead = 100 } ; let buf = Buffer . create 4096 in try while true do let line = input_line stdin in if String . length line > 0 && line . [ 0 ] = ' ' > then ( if Buffer . length buf > 0 then print_fasta ( reverse ( Buffer . contents buf ) ) ; ... |
let rec print_args list = match list with [ ] -> ( ) | x :: tail -> |
let enter name list = if verbose then begin Printf . fprintf stderr " % s " : name ; print_args list ; Printf . fprintf stderr " \ n " %! end |
let arch64 = match Sys . word_size with 32 -> false | 64 -> true | _ -> assert false |
module LineReader : sig val read : Unix . file_descr -> int -> ( string -> int -> int -> unit ) -> unit let read ic maxlen handler = let s = String . create maxlen in let rec iter begin_pos pos = let to_read = maxlen - pos in and iter2 begin_pos pos end_pos = if pos = end_pos then else in iter 0 0 end |
let t = String . make 256 ' ' |
let b = String . make 61 ' \ n ' |
let bi = ref 1 |
let _ = String . blit " TVGHEFCDIJMLKNOPQYSAABWXRZ " 0 t 65 26 ; String . blit t 65 t 97 26 ; ; |
let t = let s = Array . create 256 ' ' in for i = 0 to 255 do s . ( i ) <- t . [ i ] done ; s ; ; |
module Fasta : sig val clear : unit -> unit val flush : unit -> unit val print : string -> int -> int -> unit let printed = ref 0 let clear ( ) = printed := 0 let flush ( ) = if ! printed > 0 then print_newline ( ) ; printed := 0 let rec print s pos len = if len > 60 then begin output stdout s pos 60 ; output_char stdo... |
module IMPLEMENTATION32 : sig val main : unit -> unit |
module BigRevBuffer : sig val clear : unit -> unit val length : unit -> int val add : string -> int -> int -> unit val reverse_iter : unit -> unit let nbuffers = if arch64 then 0 else 256 let buffer_len = 1_000_000 let buffers = Array . init nbuffers ( fun _ -> String . create buffer_len ) let buffer_pos = Array . crea... |
let reverse ( ) = if BigRevBuffer . length ( ) > 0 then begin Fasta . clear ( ) ; BigRevBuffer . reverse_iter ( ) ; BigRevBuffer . clear ( ) ; Fasta . flush ( ) end |
let main ( ) = try LineReader . read Unix . stdin 1_000_000 ( fun s pos len -> ) with End_of_file -> reverse ( ) | e -> end |
module IMPLEMENTATION64 : sig val main : unit -> unit let buffer_len = 150_000_000 let buffer = if arch64 then String . create buffer_len else " " let buffer_pos = ref buffer_len let wait_for = ref None let reverse ( ) = begin match ! wait_for with end ; let len = buffer_len - ! buffer_pos in if len > 0 then begin end ... |
let rec iter1 begin_pos ( ) pos = let to_read = maxlen - pos in if to_read < 32_000 then begin let len = pos - begin_pos in end else let nread = Unix . read Unix . stdin inbuf pos to_read in if pos = end_pos then iter1 begin_pos ( ) end_pos else match inbuf . [ pos ] with | ' ' > -> | c -> let to_read = maxlen - pos in... |
let read ( ) = iter1 0 ( ) 0 |
let main ( ) = enter " main64 " [ ] ; try read ( ) with End_of_file -> reverse ( ) | e -> end |
let _ = if arch64 then IMPLEMENTATION64 . main ( ) else IMPLEMENTATION32 . main ( ) |
type t = Path . t option |
let equal a b = match ( a , b ) with | Some a , Some b -> Path . equal a b | None , None -> true | _ , _ -> false |
let pp = Fmt . option Path . pp |
module Decoder = struct open Angstrom let reverse_path = Path . Decoder . path >>| ( fun t -> Some t ) <|> string " " <> *> return None let esmtp_keyword = satisfy Domain . Decoder . ( is_alpha or is_digit ) >>= fun pre -> take_while Domain . Decoder . ( is_alpha or is_digit or is_dash ) >>| fun lst -> String . concat ... |
module Encoder = struct let to_string = function | None -> " " <> | Some path -> Path . Encoder . to_string path end |
type t = { rev : string ; date : float ; comment : string ; author : string ; filename : file ; } |
let cols = new GTree . column_list |
let col_rev = cols # add Gobject . Data . string |
let col_date = cols # add Gobject . Data . string |
let col_comment = cols # add Gobject . Data . string |
let col_author = cols # add Gobject . Data . string |
let col_filename = ( cols # add Gobject . Data . caml : file GTree . column ) |
let print_time tm = sprintf " % 4d -% d -% d % 02d :% 02d :% 02d " ( tm . Unix . tm_year + 1900 ) ( tm . Unix . tm_mon + 1 ) tm . Unix . tm_mday tm . Unix . tm_hour tm . Unix . tm_min tm . Unix . tm_sec |
let get_filename_extension ~ dir_sep filename = let len = String . length filename in let pos = String . rindex filename ' . ' in let re = Str . regexp_string dir_sep in let pos_sep = try Str . search_backward re filename len with Not_found -> - 1 in if pos < pos_sep then " " else String . sub filename pos ( len - pos ... |
let is_ocaml_filename filename = filename ^^^ " . ml " || filename ^^^ " . mli " || filename ^^^ " . mll " || filename ^^^ " . mly " let sw = GBin . scrolled_window ~ shadow_type ` : IN ? packing ( ) in let buffer = new Ocaml_text . buffer ( ) in let view = new Ocaml_text . view ~ buffer ( ) in let _ = Preferences_appl... |
let create ~ page = let widget = new widget ~ page ( ) in widget |
let time ( ) = None |
let ca_exts ? pathlen ( ) = let ku = [ ` Key_cert_sign ; ` CRL_sign ; ` Digital_signature ; ` Content_commitment ] in Extension . ( add Basic_constraints ( true , ( true , pathlen ) ) ( singleton Key_usage ( true , ku ) ) ) |
let key_ids exts subject_pubkey issuer_pubkey = let subject_key_id = false , Public_key . id subject_pubkey and authority_key_id = let cs = Public_key . id issuer_pubkey in false , ( Some cs , General_name . empty , None ) in Extension . ( add Subject_key_id subject_key_id ( add Authority_key_id authority_key_id exts )... |
let leaf_exts = Extension . ( add Key_usage ( true , [ ` Digital_signature ; ` Key_encipherment ] ) ( add Ext_key_usage ( true , [ ` Server_auth ] ) ( singleton Basic_constraints ( true , ( false , None ) ) ) ) ) |
let validity now = match Ptime . add_span now ( Ptime . Span . of_int_s 3600 ) with | Some fut -> ( now , fut ) | None -> invalid_arg " couldn ' t add 3600 seconds to now " |
let key ( ) = let key = Mirage_crypto_pk . Rsa . generate ~ bits : 1024 ( ) in ( ` RSA ( Mirage_crypto_pk . Rsa . pub_of_priv key ) , ` RSA key ) |
let selfsigned ( ? name = " test " ) now = let pub , priv = key ( ) in let name = [ Distinguished_name . ( Relative_distinguished_name . singleton ( CN name ) ) ] in match Signing_request . create name priv with | Error _ -> assert false | Ok req -> let valid_from , valid_until = validity now in match X509 . Signing_re... |
let cert ? serial ( ? name = " sub " ) now ca pubca privca issuer = let pub , priv = key ( ) in let name = [ Distinguished_name . ( Relative_distinguished_name . singleton ( CN name ) ) ] in match Signing_request . create name priv with | Error _ -> assert false | Ok req -> let valid_from , valid_until = validity now i... |
let verify ( ) = let now = Ptime_clock . now ( ) in let ca , capub , capriv = selfsigned now in let cert , _ , _ = cert now false capub capriv ( Certificate . subject ca ) in match Validation . verify_chain ~ host : None ~ time ~ anchors [ : ca ] [ cert ] with | Ok _ -> ( ) | Error _ -> Alcotest . fail " expected verif... |
let crl ( ) = let now = Ptime_clock . now ( ) in let ca , capub , capriv = selfsigned now in let serial = Z . of_int 42 in let issuer = Certificate . subject ca in let cert , _ , _ = cert ~ serial now false capub capriv issuer in let revoked = { CRL . serial ; date = now ; extensions = Extension . empty } in let extens... |
let verify ' ( ) = let now = Ptime_clock . now ( ) in let ca , capub , capriv = selfsigned now in let serial = Z . of_int 42 in let issuer = Certificate . subject ca in let ica , ipub , ipriv = cert ~ name " : subCA " ~ serial now true capub capriv issuer in let cert , _pub , _priv = cert now false ipub ipriv ( Certifi... |
let crl ' ( ) = let now = Ptime_clock . now ( ) in let ca , capub , capriv = selfsigned now in let serial = Z . of_int 42 in let issuer = Certificate . subject ca in let ica , ipub , ipriv = cert ~ name " : subCA " ~ serial now true capub capriv issuer in let cert , _pub , _priv = cert now false ipub ipriv ( Certificat... |
let crl ' leaf ( ) = let now = Ptime_clock . now ( ) in let ca , capub , capriv = selfsigned now in let serial = Z . of_int 42 in let ica , ipub , ipriv = cert ~ name " : subCA " now true capub capriv ( Certificate . subject ca ) in let issuer = Certificate . subject ica in let cert , _pub , _priv = cert ~ serial now f... |
let crl ' leaf ' wrong ( ) = let now = Ptime_clock . now ( ) in let ca , capub , capriv = selfsigned now in let serial = Z . of_int 42 in let issuer = Certificate . subject ca in let ica , ipub , ipriv = cert ~ name " : subCA " now true capub capriv issuer in let cert , _pub , _priv = cert ~ serial now false ipub ipriv... |
let verify ' ' ( ) = let now = Ptime_clock . now ( ) in let ca , capub , capriv = selfsigned now in let serial = Z . of_int 42 in let issuer = Certificate . subject ca in let ica , ipub , ipriv = cert ~ name " : subCA " now true capub capriv issuer in let cert , _pub , _priv = cert now false ipub ipriv ( Certificate . ... |
let crl ' ' ( ) = let now = Ptime_clock . now ( ) in let ca , capub , capriv = selfsigned now in let serial = Z . of_int 42 in let issuer = Certificate . subject ca in let ica , ipub , ipriv = cert ~ name " : subCA " ~ serial now true capub capriv issuer in let cert , _pub , _priv = cert now false ipub ipriv ( Certific... |
let revoke_tests = [ " Verify with a chain works " , ` Quick , verify ; " Verify with a revoked leaf fails " , ` Quick , crl ; " Verify with a longer chain works " , ` Quick , verify ' ; " Verify with a revoked intermediate fails " , ` Quick , crl ' ; " Verify with a longer chain works , even if some random serial is r... |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2015 - 02 - 02 " ] ) ; ( " Action " , [ " RevokeCacheSecurityGroupIngress " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RevokeCacheSecurityGroupIngressResponse " ( snd xml ) ) ( Xml . member " RevokeCacheSecurityGroupIngressResult " ) in try Util . or_error ( Util . option_bind resp RevokeCacheSecurityGroupIngressResult . parse )... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2016 - 11 - 15 " ] ) ; ( " Action " , [ " RevokeClientVpnIngress " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query .... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " RevokeClientVpnIngressResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp RevokeClientVpnIngressResult . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed RevokeClientVpnIngr... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " RevokeDBSecurityGroupIngress " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Q... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RevokeDBSecurityGroupIngressResponse " ( snd xml ) ) ( Xml . member " RevokeDBSecurityGroupIngressResult " ) in try Util . or_error ( Util . option_bind resp RevokeDBSecurityGroupIngressResult . parse ) ( let op... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2016 - 11 - 15 " ] ) ; ( " Action " , [ " RevokeSecurityGroupEgress " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Quer... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " RevokeSecurityGroupEgressResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp RevokeSecurityGroupEgressResult . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed RevokeSecurit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.