text
stringlengths
12
786k
let test_int64 n bits = [ % test_result : int ] ( Int64 . popcount n ) ~ expect : bits
let test_nativeint n bits = [ % test_result : int ] ( Nativeint . popcount n ) ~ expect : bits for i = 0 to Int . num_bits - 1 do let n = 1 lsl i in test_int n 1 ; test_int ( lnot n ) ( Int . num_bits - 1 ) done ; ; for i = 0 to 31 do let n = Int32 . shift_left 1l i in t...
let does_not_allocate f = let test ( ) = let len = 100 in let inputs = ArrayLabels . init len ~ f ( : fun _ -> Random . bits ( ) ) in let minor_before = Gc . minor_words ( ) in for i = 0 to len - 1 do ignore ( f inputs . ( i ) : int ) done ; let minor_after = Gc . min...
let cases = [ " " ; " . " ; " 1 . " ; " 12 . " ; " 123 . " ; " 1234 . " ; " 12345 . " ; " 123456 . " ; " . \ n " ; " \ n . " ; " \ n \ n \ n " ; " . . . xxxxx \ nxxxx . xxx . xxx \ n " ; " . . . ....
let build_positions s = let builder = Positions . Builder . create ( ) in for i = 0 to String . length s - 1 do match s . [ i ] with | ' \ n ' -> Positions . Builder . add_newline builder ~ offset : i | ' . ' -> Positions . Builder . add builder ~ offset : i | ' ' ...
let build_positions_simple s = let rec loop i ( pos : Positions . pos ) = if i = String . length s then [ ] else ( let offset = pos . offset + 1 in match s . [ i ] with | ' \ n ' -> loop ( i + 1 ) { line = pos . line + 1 ; col = 0 ; offset } | ' . ' -> po...
let check_all_subsexps_map_to_their_position s sexps positions = let check_subsexp subsexp = match Positions . find_sub_sexp_in_list_phys positions sexps ~ sub : subsexp with | None -> failwith " not found " | Some range -> assert ( Sexp . ( = ) ( Single . parse_string_exn ( String . sub ...
let cases_for_find_sub_sexp = [ " ( ( ( abc ) ( + 1 2 ) ) ) " ]
module Annotated = struct type t = | Atom of Positions . range * Sexp . t | List of Positions . range * Sexp . t * t list let of_sexp_and_positions = let rec loop ( sexp : Sexp . t ) ( positions : Positions . pos list ) = match sexp , positions with | Atom _ , start_pos :: last_pos...
module Req = struct include Caqti_type . Std include Caqti_request . Infix end
let bad_select_req = Req . ( unit -->! unit @:- " SELECT not_defined " )
let test_error ( module C : Caqti_blocking . CONNECTION ) = ( match C . find bad_select_req ( ) with | Ok ( ) -> Alcotest . fail " unexpected ok from bad_select " | Error ( ` Request_failed { msg = Caqti_driver_postgresql . Result_error_msg { sqlstate ; _ } ; _ } ) -...
let test_cases_on_connection = [ " test_error " , ` Quick , test_error ; ]
let mk_test ( name , pool ) = let pass_conn ( name , speed , f ) = let f ' ( ) = Caqti_blocking . Pool . use ( fun c -> Ok ( f c ) ) pool |> function | Ok ( ) -> ( ) | Error err -> Alcotest . failf " % a " Caqti_error . pp err in ( name , speed , f ' ) ...
let mk_tests { uris ; tweaks_version } = let connect_pool uri = ( match Caqti_blocking . connect_pool uri ~ max_size : 1 ? tweaks_version with | Ok pool -> ( test_name_of_uri uri , pool ) | Error err -> raise ( Caqti_error . Exn err ) ) in let is_postgresql uri = Uri . scheme uri =...
let ( ) = Alcotest_cli . run_with_args_dependency " test_postgresql " common_args mk_tests
let init_dbh dbh = let ( ) = [ % pgsql dbh " execute " " create temporary table employees ( userid serial primary key , name text not null , salary int not null , email text ) ] " in let ( ) = [ % pgsql dbh " execute " " DO $$ BEGIN CREATE DOMAIN cash_money AS float ; EXCEP...
module Userid : sig type t val to_string : t -> string val from_string : string -> t val to_int : t -> int type t = int let to_string = string_of_int let from_string = int_of_string let to_int x = x end
let employee_exists dbh ? email n = [ % pgsql dbh " SELECT EXISTS ( SELECT 1 FROM employees WHERE name = $ n AND email = $? email ) email ] "
let ( ) = let dbh = PGOCaml . connect ( ) in init_dbh dbh ; let insert name pay email = [ % pgsql dbh " insert into employees ( name , salary , email ) email values ( $ name , $ pay , $? email ) email ] " in insert " Ann " 10_000_l None ; insert " Bob " 45_000_l Non...
module Unit = struct type t = unit [ @@ deriving compare , sexp_of ] end
module type T = sig type t [ @@ deriving compare , sexp_of ] end
let test ( type a ) ( module T : T with type t = a ) ordered = List . iteri ordered ~ f ( : fun i ti -> List . iteri ordered ~ f ( : fun j tj -> require [ % here ] ( Ordering . equal ( Ordering . of_int ( T . compare ti tj ) ) ( Ordering . of_int ( Int . compare i j...
module type Min_zero_max = sig include T val min_value : t val max_value : t val zero : t end
let test_min_zero_max ( type a ) ( module T : Min_zero_max with type t = a ) = test ( module T ) [ T . min_value ; T . zero ; T . max_value ] ; ; test_min_zero_max ( module Float ) ; test_min_zero_max ( module Int ) ; test_min_zero_max ( module Int32 ) ; test_min_zero_...
module type Sequence = sig type ' a t [ @@ deriving compare , sexp_of ] val of_list : ' a list -> ' a t end
let test_sequence ( module T : Sequence ) ordered = test ( module struct type t = int T . t [ @@ deriving compare , sexp_of ] end ) ( ordered |> List . map ~ f : T . of_list ) ; ; test_sequence ( module Array ) [ [ ] ; [ 1 ] ; [ 2 ] ; [ 1 ; 2 ] ; [ ...
let cmd_test_case ~ term ~ argv ~ expected ~ pprinter what = let info = Cmdliner . Term . info " cmd " in Alcotest . ( check ( of_pp pprinter ) ) what expected ( match Cmdliner . Term . eval ~ argv ( term , info ) with | ` Error msg -> assert false | ` Ok actual -> actual |...
type common_types = { a1 : string ; b1 : int ; c1 : float ; d1 : string option ; e1 : string list ; f1 : int array ; g1 : int list ; h1 : bool ; i1 : bytes ; j1 : string list option ; k1 : int list option }
let simple ( ) = let argv = [ | " cmd " ; " -- a1 " ; " apple " ; " -- b1 " ; " 123 " ; " -- c1 " ; " 1 . 20 " ; " -- d1 " ; " yes " ; " -- e1 " ; " apple , banana , pear " ; " -- f1 " ; " 1 , 2 , 3 , 4 , 5 " ...
type default_types = { a1 : string [ @ default " apple " ] ; b1 : int [ @ default 10 ] ; c1 : float [ @ default 1 . 20 ] ; e1 : string list [ @ default [ ] ] ; f1 : int array [ @ default [ | 1 ; 2 ; 3 ] ] | ; g1 : int list [ @ default [ 1 ; 2...
let defaults ( ) = let argv = [ " | cmd " ] | in let expected = { a1 = " apple " ; b1 = 10 ; c1 = 1 . 20 ; e1 = [ ] ; f1 = [ | 1 ; 2 ; 3 ] | ; g1 = [ 1 ; 2 ; 3 ] ; h1 = true } in cmd_test_case " expected defaults to work " ~ term ( : d...
type env_types = { a1 : string [ @ env " A_ONE_ENV " ] } [ @@ deriving cmdliner , show ]
let env ( ) = let argv = [ " | cmd " ] | in let expected = { a1 = " foobar " } in Unix . putenv " A_ONE_ENV " " foobar " ; cmd_test_case " expected env variables to work " ~ term ( : env_types_cmdliner_term ( ) ) ~ argv ~ expected ~ pprinter : pp_env_types
type list_sep_types = { a1 : int list [ @ sep ' ' ] ; @ b1 : string array [ @ sep ' ' ] } *
let list_sep ( ) = let argv = [ " | cmd " ; " -- a1 " ; " 1 @ 9 @ 3 @ 5 " ; " -- b1 " ; " foo * bar * baz " ] | in let expected = { a1 = [ 1 ; 9 ; 3 ; 5 ] ; b1 = [ " | foo " ; " bar " ; " baz " ] } | in cmd_test_case " exp...
type pos_types = { a1 : string [ @ pos 1 ] ; b1 : int [ @ pos 0 ] }
let positional ( ) = let argv = [ " | cmd " ; " 1 " ; " second - pos " ] | in let expected = { a1 = " second - pos " ; b1 = 1 } in cmd_test_case " expected positional args to work " ~ term ( : pos_types_cmdliner_term ( ) ) ~ argv ~ expected ~ pprinter : pp_...
type enum_types = { a1 : int list [ @ enum [ ( " one " , 1 ) ; ( " two " , 2 ) ; ( " three " , 3 ) ; ( " four " , 4 ) ] ] ; b1 : [ ` A | ` B | ` C ] [ @ enum [ ( " a " , ` A ) ; ( " b " , ` B ) ; ( " c " ...
let enums ( ) = let argv = [ " | cmd " ; " -- a1 " ; " one , two " ; " -- b1 " ; " b " ] | in let expected = { a1 = [ 1 ; 2 ] ; b1 = ` B } in cmd_test_case " expected enum args to work " ~ term ( : enum_types_cmdliner_term ( ) ) ~ argv ~ exp...
module M = struct type t = int * int [ @@ deriving show ] let fst ( f , _ ) = f let snd ( _ , s ) = s let of_string s = try let sepi = String . index s ' ' | in let fst = String . sub s 0 sepi in let snd = String . sub s ( sepi + 1 ) ( String . length s - sepi - 1 ) ...
type custom_types = { foo : M . t [ @ conv M . cmdliner_converter ] ; bar : M . t }
let customs ( ) = let argv = [ " | cmd " ; " -- foo " ; " 11 | 200 " ; " -- bar " ; " 0 | 13 " ] | in let expected = { foo = ( 11 , 200 ) ; bar = ( 0 , 13 ) } in cmd_test_case " expected custom type converter to work " ~ term ( : custom_ty...
type opt_all_types = { foo : string list [ @ opt_all ] } [ @@ deriving cmdliner , show ]
let opt_all ( ) = let argv = [ " | cmd " ; " -- foo " ; " test " ; " -- foo " ; " foo " ] | in let expected = { foo = [ " test " ; " foo " ] } in cmd_test_case " expected opt_all list to work " ~ term ( : opt_all_types_cmdliner_term ( ) ) ~ ar...
type foo = { a1 : string ; b1 : string } [ @@ deriving cmdliner , show ]
type terms_types = { foo : foo [ @ term foo_cmdliner_term ( ) ] }
let terms ( ) = let argv = [ " | cmd " ; " -- a1 " ; " apple " ; " -- b1 " ; " pie " ] | in let expected = { foo = { a1 = " apple " ; b1 = " pie " } } in cmd_test_case " expected custom @ term to work " ~ term ( : terms_types_cmdliner_term ( ) ...
type misc_types = { a1 : string [ @ name " renamed " ] ; b1 : bool [ @ enum [ ( " true " , true ) ; ( " false " , false ) ] ] ; c1 : bool [ @ enum [ ( " true " , true ) ; ( " false " , false ) ] ] [ @ default true ] ; d1 : bool [ ...
let miscs ( ) = let argv = [ | " cmd " ; " -- renamed " ; " test " ; " -- b1 " ; " true " ; " -- d1 " ; " false " ; " -- e1 " ; " a , b " ; " -- f1 " ; " a , b , 1 " ; " -- g1 " ; " 1 . 1 , bar , 100 , c " ] ...
let test_set = [ ( " simple types " , ` Quick , simple ) ; ( " default types " , ` Quick , defaults ) ; ( " ENV types " , ` Quick , env ) ; ( " list sep types " , ` Quick , list_sep ) ; ( " positional types " , ` Quick , positional ) ; (...
let ( ) = Alcotest . run " Ppx_deriving_cmdliner " [ ( " " , **** test_set ) ]
module Helpers = struct module type S = sig type t val quickcheck_generator : t Generator . t val quickcheck_observer : t Observer . t val quickcheck_shrinker : t Shrinker . t end let test ( type a ) ? config ? cr ? generator ? observer ? shrinker q m = let ( module Q : S with type t = a ) =...
module Nonrec_reference = Nonrec_reference test ~ shrinker ` : atomic ( module Simple_reference ) m_bool ; [ % expect { | ( generator exhaustive ) ( observer transparent ) ( shrinker atomic ) } ] ; | test ~ shrinker ` : atomic ( module Dotted_reference ) m_bool ; [ % exp...
module Application_of_polymorphic_type = Application_of_polymorphic_type test ( module Application_of_polymorphic_type ) ( m_option m_bool ) ; [ % expect { | ( generator exhaustive ) ( observer transparent ) ( shrinker ( ( ( false ) => ( ) ) ( ( true ) => ( ) ) ) ...
module Tuple = Tuple test ( module Tuple ) ( m_pair m_bool ( m_option m_unit ) ) ; [ % expect { | ( generator exhaustive ) ( observer transparent ) ( shrinker ( ( ( false ( ( ) ) ) => ( false ( ) ) ) ( ( true ( ( ) ) ) => ( true ( ) ) ) ...
module Inherit_poly_variant = Inherit_poly_variant let module Poly_variant ' = struct type t = [ ` A | ` B | ` C of bool | ` D of bool | ` E of bool * unit option | ` F of bool * unit option ] [ @@ deriving compare , enumerate , sexp_of ] end in test ( module Poly_variant ) ( ...
module Record_type = Record_type let module Record_type ' = struct type t = Record_type . t = { x : bool ; y : unit option } [ @@ deriving compare , enumerate , sexp_of ] end in test ( module Record_type ) ( m_all ( module Record_type ' ) ) ; [ % expect { | ( generator e...
module Binary_and_record_variant = Binary_and_record_variant let module Nullary_and_unary_variant ' = struct type t = Nullary_and_unary_variant . t = | A | B | C of unit | D of unit [ @@ deriving compare , enumerate , sexp_of ] end in test ~ shrinker ` : atomic ( module Nullary_and_unary_vari...
module Curried_arrow = Curried_arrow let config = { Test . default_config with test_count = 1_000 } in let test ? cr ( ? config = config ) m = test ? cr ~ config ~ shrinker ` : atomic m in test ( module Simple_arrow ) ( m_arrow ( m_option m_unit ) m_bool ) ; [ % expect { | ( ...
module Optional_higher_order = Optional_higher_order let config = { Test . default_config with test_count = 100 } in let test m = test ~ config ~ shrinker ` : atomic m in test ( module Simple_higher_order ) ( m_arrow ( m_arrow ( m_option m_unit ) ( m_option m_bool ) ) m_bool ) ; [ ...
module Instance_with_phantom = Instance_with_phantom test ( module Instance_of_unary ) ( m_list m_bool ) ; [ % expect { | ( generator " generated 2_248 distinct values in 10_000 iterations " ) ( observer transparent ) ( shrinker ( ( ( false ) => ( ) ) ( ( true ) =>...
module Recursive = Recursive let module Recursive ' = struct type t = Recursive . t = | Leaf | Node of t * t [ @@ deriving compare , hash , sexp_of ] let rec create = function | 0 -> Leaf | n -> let t = create ( n - 1 ) in Node ( t , t ) ; ; let examples = List . init 3 ~...
module Recursive_with_indirect_base_case = Recursive_with_indirect_base_case let module Recursive_with_indirect_base_case ' = struct type t = Recursive_with_indirect_base_case . t = { children : t list } [ @@ deriving compare , hash , sexp_of ] let examples = List . init 3 ~ f ( : fun n -...
module Mutually_recursive = Mutually_recursive let module Mutually_recursive ' = struct type expr = Mutually_recursive . expr = | Constant of int64 | Operator of op | Application of expr * args and op = [ ` plus | ` minus | ` abs ] and args = expr list [ @@ deriving compare , hash , sex...
module Extensions = Extensions let module Extensions ' = struct type t = [ ` A | ` B of bool * unit option ] [ @@ deriving compare , enumerate , sexp_of ] end in test ( module Extensions ) ( m_all ( module Extensions ' ) ) ; [ % expect { | ( generator exhaustive ) ( o...
module Escaped = Escaped let module Escaped ' = struct type t = int * char * bool option [ @@ deriving compare , sexp_of ] let examples = List . concat_map [ 1 ; 2 ] ~ f ( : fun int -> List . concat_map [ ' a ' ; ' b ' ] ~ f ( : fun string -> List . concat_map [ No...
module Wildcard = Wildcard let module Instance = struct include Wildcard ( ( val m_bool ) ) let compare = [ % compare : bool list ] let sexp_of_t = [ % sexp_of : bool list ] let examples = let module T = ( val m_list m_bool ) in T . examples ; ; end in test ~ cr : Comment ( modul...
module Attribute_override = Attribute_override let module Attribute_override ' = struct type t = Attribute_override . t = | Null | Text of string | Number of float [ @@ deriving compare , sexp_of ] let examples = [ Null ; Text " a " ; Number 1 . ] end in test ( module Attribute_overr...
module Attribute_override_recursive = Attribute_override_recursive let module Attribute_override_recursive ' = struct type t = Attribute_override_recursive . t = | Leaf | Node1 of t * int64 * t | Node2 of t * int64 * t * int64 * t [ @@ deriving compare , sexp_of ] let examples = [ Leaf ; No...
module Deriving_from_wildcard = Deriving_from_wildcard let module Transparent = struct type t = int Deriving_from_wildcard . transparent [ @@ deriving quickcheck ] let compare = [ % compare : string ] let sexp_of_t = [ % sexp_of : string ] let examples = [ " " ; " a " ] end in tes...
let ( ) = ( match % pcre " " % with _ -> ( ) ) ; ( match % pcre " " % with s -> assert ( s = " " ) ) ; % ( function % pcre _ -> ( ) ) " " ; % ( function % pcre s -> assert ( s = " " ) ) % " " %
let test1 = ( function % pcre | { ( |^?< k . ) >*: ( *?< v . ) } >+?$| -> ` Attr ( k , v ) | { |^# ( ?< comment . ) } >+$| -> ` Comment comment | { ( ( |^?< last [ ] ) { >@% 2 } ) { 0 , 2 } } $| -> ` Even_sigils last | { [ ] }...
let ( ) = assert ( test1 " x : 1 " = ` Attr ( " x " , Some " 1 " ) ) ; assert ( test1 " # Kommentar " = ` Comment " Kommentar " ) ; assert ( test1 " " = ` Even_sigils None ) ; assert ( test1 " " %%%@ = ` Even_sigils ( Some " " ) ) ; ...
let last_elt s = let n = String . length s in assert ( s . [ n - 1 ] = ' ; ' ) ; let i = try String . rindex_from s ( n - 2 ) ' ; ' + 1 with Not_found -> 0 in String . sub s i ( n - i - 1 )
let rec test2 s = ( match % pcre s with | { } |^<>$| -> assert ( s = " " ) <> | { ( |^<?< x [ ] ) } >^<>+>$| -> assert ( s = " " < ^ x ^ " " ) > | { ( |^<?< x [ ] ) ( >^<>+><?< y [ ] ) } >^<>+>$| -> assert ( s = " " < ^ x ^ " " ...
let test3 s = ( match % pcre s with | { | no ( is ) ( ( e ) ) ( ?< is > is ) ( g ( oo ) d ) } | -> assert ( is = " is " ) | { |?< s ' ( ) [ >& a - zA - Z0 - 9_ ] ( ; ) } -+| -> let i , j = String . index s ' ' , & String . rindex ...
let test4 = function % pcre | { ( |?< x [ ] [ [ >-+?: digit ] ] . [ [ :+: digit ] ] ) } :*| -> [ x ] | { ( |?< x ( > abc ) ) [ [ : space ] ] ( :*?< y ( > xyz ) ) } | -> [ x ; y ] | _ -> assert false
let test5 = function % pcre | { . ( |^?< x . ) } >+| -> ( match % pcre x with | { . ( |^?< y . ) } >+| -> ( match % pcre y with | { . ( |^?< z . ) } >+| -> ( x , y , z ) | _ -> assert false ) | _ -> assert false ) | _ -> assert false
let ( ) = test2 " " ; <> test2 " < a " ; > test2 " < ab " ; > test2 " < a >< b " ; > test2 " < ab >< cde " ; > test2 " a ; " ; test2 " a ; b ; c ; d ; " ; test2 " < a ; b " ; > test2 " Xx { { -- a ; b ; c ; } } -- yY . " ...
module F ( M : Map . OrderedType ) = struct let f x = ( match % pcre x with | { ( |#?< space >\ s ) ( ??< comment . ) } >*| -> Some ( space <> None , comment ) | _ -> None ) end
let r = ref false | { } |^$| -> r := true | _ -> assert false )
module Util = struct [ %% declare_roles a , b , c , d ] [ %% declare_labels msg , left , right , middle , ping , pong , fini ] end
let test_projection_success ( ) = assert_equal ( ) @@ ignore @@ extract @@ ( a --> b ) msg finish ; assert_equal ~ msg " : simple " ( ) @@ ignore @@ extract @@ [ % choice_at a ( [ % choice_at a ( ( a --> b ) left finish , ( a --> b ) right finish ) ] , [ % ...
let test_failfast_bottom ( ) = let bottom ( ) = loop_with [ a ; b ; c ] ( fun t -> t ) in assert_raises UnguardedLoop ~ msg " : bottom " ( fun _ -> ignore @@ extract @@ bottom ( ) ) ; assert_raises UnguardedLoop ~ msg " : bottom after comm " ( fun _ -> ignore @@ ext...
let test_failfast_loop_roles ( ) = assert_raises UnguardedLoop ~ msg " : declared roles absent in the loop " ( fun _ -> ignore @@ extract @@ loop_with [ a ; b ; c ] @@ fun t -> [ % choice_at c ( ( c --> b ) left t ) ( ( c --> b ) right t ) ] ) ; assert_raises Unguar...
let test_loop_merge ( ) = assert_raises UnguardedLoop ~ msg " : loop merge " ( fun _ -> ignore @@ extract @@ let g = [ % choice_at a ( ( a --> b ) left @@ loop_with [ a ; b ; c ] ( fun t -> [ % choice_at a ( ( a --> b ) left t , ( a --> b ) right t ) ] ) , ...
let suite = " Protcol combinators expected " >::: [ " test_failfast_loop_roles " >:: test_failfast_loop_roles ; " test_loop_merge " >:: test_loop_merge ; ] ; ;
let _results = run_test_tt_main suite in ( )
let test re s = match Tyre . exec re s with | Ok b -> b | Error e -> Format . eprintf " Error : % a . " @ Tyre . pp_error e ; assert false
let ( ) %%% a b = assert ( a %% b )
let ( ) = ( function % tyre _ -> true ) %%% " " ; % ( function % tyre s -> s = " " ) % " " %%%%
type t = [ | ` Attr of string * string option | ` Comment of string | ` Even_sigils of string option | ` Odd_sigils | ` Id of string * int * string | ` Unknown ]
let test1 : t Tyre . re = ( function % tyre | { ( |^?< k . ) >*: ( *?< v . ) } >+?$| -> ` Attr ( k , v ) | { |^# ( ?< comment . ) } >+$| -> ` Comment comment | { ( |^?< sigil ( [ ] { >@% 2 } ) ) } +?$| -> ` Even_sigils sigil | { [ ] ...
let ( ) = assert ( test1 %% " x : 1 " = ` Attr ( " x " , Some " 1 " ) ) ; assert ( test1 %% " # Kommentar " = ` Comment " Kommentar " ) ; assert ( test1 %% " " = ` Even_sigils None ) ; assert ( test1 %% " " %%%@ = ` Even_sigils ( Some " ...
let concat_seq sep seq = let rec f seq = match seq ( ) with | Seq . Nil -> " " | Cons ( s , seq ) -> s ^ sep ^ f seq in f seq
let test2 = function % tyre | { } |^<>$| -> ( ) = " " <> | { ( |^<?< x [ ] ) } >^<>+>$| -> fun s -> s = " " < ^ x ^ " " > | { ( |^<?< x [ ] ) ( >^<>+><?< y [ ] ) } >^<>+>$| -> fun s -> s = " " < ^ x ^ " " >< ^ y ^ " " > | { ...
let ( ) %%%% re s = ( re %% s ) s
let ( ) = assert ( test2 " " ) ; %%%%<> assert ( test2 " %%%%< a " ) ; > assert ( test2 " %%%%< ab " ) ; > assert ( test2 " %%%%< a >< b " ) ; > assert ( test2 " %%%%< ab >< cde " ) ; > assert ( test2 " %%%% a ; " ) ; assert ( test2 " %...
module F ( M : Map . OrderedType ) = struct let f = function % tyre | { ( |#?< space >\ s ) ( ??< comment . ) } >*| -> Some ( space <> None , comment ) | _ -> None end