text stringlengths 0 601k |
|---|
let resolve_all ( defns : Unresolved . t list ) = let names = name_table defns in let defns = String . Map . values names in let rename_change_field = object inherit Unresolved . map as super method ! field x = if x . name = " change " then match x . data with | Single { typ = Ident " number " ; optional = true } -> le... |
let test_snippets s = let fails , succs = List . partition_map s ~ f ( : fun s -> let lexbuf = Lexing . from_string s in try Right ( Ts_parser . main Ts_lexer . token lexbuf ) with | exn -> Left { snippet = s ; loc = lexbuf . lex_curr_p ; exn } ) in ignore ( resolve_all ( List . concat succs ) ) ; fails |
let pp_results ppf tests = List . iteri tests ~ f ( : fun i { snippet ; loc ; exn } -> Format . pp_print_string ppf snippet ; Format . fprintf ppf " line : % d char : % d . " @ loc . pos_lnum ( loc . pos_cnum - loc . pos_bol ) ; Format . fprintf ppf " % d . exn : % s . " @%! ( i + 1 ) ( Printexc . to_string exn ) ; For... |
let of_snippets s = List . concat_map s ~ f ( : fun s -> let lexbuf = Lexing . from_string s in try Ts_parser . main Ts_lexer . token lexbuf with | _exn -> [ ] ) |
module Type_var_names = struct let last_char : char ref = ref ' a ' let table : ( Types . type_expr , char ) Hashtbl . t = Hashtbl . create 1024 let reset ( ) = last_char := ' a ' let find t = match Hashtbl . find_opt table t with | None -> Hashtbl . add table t ! last_char ; let ret = String . make 1 ! last_char in la... |
module Fun = struct let rec mk_type_expr : Types . type_expr -> Erlang . Ast . type_expr = fun type_expr -> match type_expr . desc with | Tarrow ( _ , _ , _ , _ ) -> ( match Uncurry . from_type_expr type_expr with | ` Uncurried ( args , return ) -> let args = List . map mk_type_expr args in let return = mk_type_expr re... |
let rec is_unit ( t : Types . type_expr ) = match t . desc with | Tconstr ( p , _ , _ ) -> Path . same p Predef . path_unit | Tlink t ' -> is_unit ( Btype . repr t ' ) | _ -> false |
let is_opaque_in_signature type_decl signature = match signature with | None -> Type . type_ | Some sign -> List . fold_left ( fun kind sig_item -> match sig_item with | Sig_type ( name , { type_manifest = None ; _ } , _ , _ ) when Ident . name name = Ident . name type_decl . typ_id -> Type . opaque | _ -> kind ) Type ... |
let rec mk_type_expr core_type = match core_type . ctyp_desc with | Ttyp_any -> Some Type . any | Ttyp_var var_name -> Some ( Type . var ( Name . var var_name ) ) | Ttyp_arrow ( _ , param , out ) -> let rec args t acc = match t . ctyp_desc with | Ttyp_arrow ( _ , p , t ' ) -> args t ' ( p :: acc ) | _ -> t :: acc in le... |
let mk_record labels = let mk_field Typedtree . { ld_id ; ld_type ; _ } = let rf_name = Names . atom_of_ident ld_id in let rf_type = match mk_type_expr ld_type with Some t -> t | None -> Type . any in Type . map_field ~ presence : Mandatory ( Type . const ( Const . atom rf_name ) ) rf_type in let fields = List . map mk... |
let mk_abstract name params type_decl core_type signature = match mk_type_expr core_type with | Some expr -> let kind = is_opaque_in_signature type_decl signature in Some ( Type . mk ~ name ~ params ~ expr ~ kind ) | None -> None |
let mk_type_params params = params |> List . filter_map ( fun ( core_type , _ ) -> match core_type . ctyp_desc with | Ttyp_var name -> Some ( Name . var name ) | _ -> None ) |
let mk_type type_decl ~ signature = let name = Names . atom_of_ident type_decl . typ_id in let params = mk_type_params type_decl . typ_params in let params = List . map Type . var params in match type_decl . typ_kind with | Ttype_abstract -> ( match type_decl . typ_manifest with | Some abs -> mk_abstract name params ty... |
let mk_types : Typedtree . structure -> Types . signature option -> Erlang . Ast . type_decl list = fun typedtree signature -> typedtree . str_items |> List . concat_map ( fun item -> match item . str_desc with Tstr_type ( _ , tys ) -> tys | _ -> [ ] ) |> List . filter_map ( mk_type ~ signature ) |
type inner_curve_var = Tick . Field . t Snarky_backendless . Cvar . t * Tick . Field . t Snarky_backendless . Cvar . t |
module Basic = struct type ( ' var , ' value , ' n1 , ' n2 ) ' n2 t = { max_proofs_verified : ( module Nat . Add . Intf with type n = ' n1 ) ' n1 ; value_to_field_elements : ' value -> Impls . Step . Field . Constant . t array ; var_to_field_elements : ' var -> Impls . Step . Field . t array ; typ : ( ' var , ' value )... |
module Side_loaded = struct module Ephemeral = struct type t = { index : [ ` In_circuit of Side_loaded_verification_key . Checked . t | ` In_prover of Side_loaded_verification_key . t ] } end module Permanent = struct type ( ' var , ' value , ' n1 , ' n2 ) ' n2 t = { max_proofs_verified : ( module Nat . Add . Intf with... |
module Compiled = struct type f = Impls . Wrap . field type ( ' a_var , ' a_value , ' max_proofs_verified , ' branches ) ' branches basic = { typ : ( ' a_var , ' a_value ) ' a_value Impls . Step . Typ . t ; proofs_verifieds : ( int , ' branches ) ' branches Vector . t ; var_to_field_elements : ' a_var -> Impls . Step .... |
module For_step = struct type ( ' a_var , ' a_value , ' max_proofs_verified , ' branches ) ' branches t = { branches : ' branches Nat . t ; max_proofs_verified : ( module Nat . Add . Intf with type n = ' max_proofs_verified ) ' max_proofs_verified ; proofs_verifieds : ( Impls . Step . Field . t , ' branches ) ' branche... |
type t = { compiled : Compiled . packed Type_equal . Id . Uid . Table . t ; side_loaded : Side_loaded . packed Type_equal . Id . Uid . Table . t } |
let univ : t = { compiled = Type_equal . Id . Uid . Table . create ( ) ; side_loaded = Type_equal . Id . Uid . Table . create ( ) } |
let find t k = match Hashtbl . find t k with None -> failwith " key not found " | Some x -> x |
let lookup_compiled : type a b n m . ( a , b , n , m ) m Tag . tag -> ( a , b , n , m ) m Compiled . t = fun t -> let ( T ( other_id , d ) d ) d = find univ . compiled ( Type_equal . Id . uid t ) t in let T = Type_equal . Id . same_witness_exn t other_id in d |
let lookup_side_loaded : type a b n m . ( a , b , n , m ) m Tag . tag -> ( a , b , n , m ) m Side_loaded . t = fun t -> let ( T ( other_id , d ) d ) d = find univ . side_loaded ( Type_equal . Id . uid t ) t in let T = Type_equal . Id . same_witness_exn t other_id in d |
let lookup_basic : type a b n m . ( a , b , n , m ) m Tag . t -> ( a , b , n , m ) m Basic . t = fun t -> match t . kind with | Compiled -> Compiled . to_basic ( lookup_compiled t . id ) id | Side_loaded -> Side_loaded . to_basic ( lookup_side_loaded t . id ) id |
let lookup_step_domains : type a b n m . ( a , b , n , m ) m Tag . t -> ( Domain . t , m ) m Vector . t = fun t -> let f = Vector . map ~ f : Domains . h in match t . kind with | Compiled -> f ( lookup_compiled t . id ) id . step_domains | Side_loaded -> ( let t = lookup_side_loaded t . id in match t . ephemeral with |... |
let max_proofs_verified : type n1 . ( _ , _ , n1 , _ ) _ Tag . t -> ( module Nat . Add . Intf with type n = n1 ) n1 = fun tag -> match tag . kind with | Compiled -> ( lookup_compiled tag . id ) id . max_proofs_verified | Side_loaded -> ( lookup_side_loaded tag . id ) id . permanent . max_proofs_verified |
let typ : type var value . ( var , value , _ , _ ) _ Tag . t -> ( var , value ) value Impls . Step . Typ . t = fun tag -> match tag . kind with | Compiled -> ( lookup_compiled tag . id ) id . typ | Side_loaded -> ( lookup_side_loaded tag . id ) id . permanent . typ |
let value_to_field_elements : type a . ( _ , a , _ , _ ) _ Tag . t -> a -> Tick . Field . t array = fun t -> match t . kind with | Compiled -> ( lookup_compiled t . id ) id . value_to_field_elements | Side_loaded -> ( lookup_side_loaded t . id ) id . permanent . value_to_field_elements |
let lookup_map ( type a b c d ) d ( t : ( a , b , c , d ) d Tag . t ) t ~ self ~ default ( ~ f : [ ` Compiled of ( a , b , c , d ) d Compiled . t | ` Side_loaded of ( a , b , c , d ) d Side_loaded . t ] -> _ ) = match Type_equal . Id . same_witness t . id self with | Some _ -> default | None -> ( match t . kind with | ... |
let add_side_loaded ~ name permanent = let id = Type_equal . Id . create ~ name sexp_of_opaque in Hashtbl . add_exn univ . side_loaded ~ key ( : Type_equal . Id . uid id ) id ~ data ( : T ( id , { ephemeral = None ; permanent } ) ) ; { Tag . kind = Side_loaded ; id } |
let set_ephemeral { Tag . kind ; id } eph = ( match kind with Side_loaded -> ( ) | _ -> failwith " Expected Side_loaded ) " ; Hashtbl . update univ . side_loaded ( Type_equal . Id . uid id ) id ~ f ( : function | None -> assert false | Some ( T ( id , d ) d ) d -> T ( id , { d with ephemeral = Some eph } ) ) |
let add_exn ( type a b c d ) d ( tag : ( a , b , c , d ) d Tag . t ) t ( data : ( a , b , c , d ) d Compiled . t ) t = Hashtbl . add_exn univ . compiled ~ key ( : Type_equal . Id . uid tag . id ) id ~ data ( : Compiled . T ( tag . id , data ) data ) data |
let test ( ) = print_endline " Types tests " ; let open EH1 in let open Global in init ( ) ; let bool_t = Type . bool ( ) in let int_t = Type . int ( ) in assert ( not Type . ( equal bool_t int_t ) ) ; let real_t = Type . real ( ) in assert ( not Type . ( equal real_t bool_t ) ) ; assert ( not Type . ( equal real_t int... |
type error = | Unbound_type_var of string | Wrong_number_args of Path . t * int * int | Expected_type_var of type_expr | Constraints_not_satisfied of type_expr * type_decl | Opaque_type_in_prover_mode of type_expr | Convertible_arities_differ of string * int * string * int | GADT_in_nonrec_type | Repeated_row_label of ... |
let type0 { Typedast . type_type ; _ } = type_type |
let unify = ref ( fun ~ loc : _ _env _typ1 _typ2 -> failwith " Undefined " ) |
module Type = struct open Type let opaque = Ident . create ~ mode : Checked " opaque " let mk_poly ~ loc ~ mode vars typ env = { Typedast . type_desc = Ttyp_poly ( vars , typ ) ; type_loc = loc ; type_type = Mk . poly ~ mode ( List . map ~ f : type0 vars ) ( type0 typ ) env } let mk_tuple ~ loc ~ mode typs env = { Type... |
module TypeDecl = struct open TypeDecl let generalise decl = let poly_name = map_loc decl . tdec_ident ~ f ( : fun name -> if name = " t " then " poly " else name ^ " _poly " ) in match decl . tdec_desc with | Pdec_record fields -> let field_vars = List . map fields ~ f ( : fun { fld_ident ; fld_type = _ ; fld_loc } ->... |
let pp_decl_typ ppf decl = pp_typ ppf { type_desc = Ptyp_ctor { var_ident = mk_lid decl . tdec_ident ; var_params = decl . tdec_params } ; type_loc = Location . none } |
let report_error ppf = function | Unbound_type_var name -> let quot = match name with " _ " -> " " | _ -> " ' " in fprintf ppf " [ @< hov > Unbound type parameter @ % s % s . ] " @ quot name | Wrong_number_args ( path , given , expected ) -> fprintf ppf " [ @ The type constructor [ @< h >% a ] @ expects % d argument ( ... |
let ( ) = Location . register_error_of_exn ( function | Error ( loc , err ) -> Some ( Location . error_of_printer ~ loc report_error err ) | _ -> None ) |
let empty_head variable = { Type . Callable . head = [ ] ; variable } |
let ( ! ) concretes = List . map concretes ~ f ( : fun single -> Type . Parameter . Single single ) |
let make_callable_from_arguments annotations = Type . Callable . Defined ( List . mapi ~ f ( : fun index annotation -> Type . Callable . RecordParameter . PositionalOnly { index ; annotation ; default = false } ) annotations ) |
let assert_create ( ? aliases = fun _ -> None ) source annotation = assert_equal ~ printer : Type . show ~ cmp : Type . equal annotation ( Type . create ~ aliases ( : fun ? replace_unbound_parameters_with_any : _ -> aliases ) ( parse_single_expression ~ preprocess : true source ) ) |
let test_create _ = assert_create " foo " ( Type . Primitive " foo " ) ; assert_create " foo . bar " ( Type . Primitive " foo . bar " ) ; assert_create " object " ( Type . Primitive " object " ) ; assert_create " foo [ bar ] " ( Type . parametric " foo " [ ! Type . Primitive " bar " ] ) ; assert_create " foo [ bar , ba... |
let test_create_callable _ = let default_overload = { Type . Callable . annotation = Type . Top ; parameters = Undefined } in let open Type . Callable in assert_create " typing . Callable " ( Type . Primitive " typing . Callable " ) ; assert_create " typing . Callable [ . . . , int ] " ( Type . Callable . create ~ anno... |
let test_create_alias _ = let assert_alias source resolved = let aliases primitive = Identifier . Table . of_alist_exn [ " Alias " , Type . Primitive " Aliased " ; " IntList " , Type . list Type . integer ; ( " _Future " , Type . union [ Type . parametric " Future " [ ! Type . integer ; Type . variable " _T " ] ; Type ... |
let test_create_type_operator _ = let assert_create ( ? aliases = fun _ -> None ) source annotation = assert_equal ~ printer : Type . show ~ cmp : Type . equal annotation ( Type . create ~ aliases ( : fun ? replace_unbound_parameters_with_any : _ -> aliases ) ( parse_single_expression ~ preprocess : true source ) ) in ... |
let test_create_variadic_tuple _ = let assert_create ( ? aliases = fun _ -> None ) source annotation = assert_equal ~ printer : Type . show ~ cmp : Type . equal annotation ( Type . create ~ aliases ( : fun ? replace_unbound_parameters_with_any : _ -> aliases ) ( parse_single_expression ~ preprocess : true source ) ) in... |
let test_resolve_aliases _ = let assert_resolved ~ aliases annotation expected = let aliases ? replace_unbound_parameters_with_any : _ = aliases in assert_equal ~ printer : Type . show ~ cmp : Type . equal expected ( Type . resolve_aliases ~ aliases annotation ) in let aliases = function | " MyInt " -> Some ( Type . Ty... |
let test_instantiate _ = let assert_instantiate mappings ~ generic ~ expected = let map = Type . Map . of_alist_exn mappings in assert_equal ~ printer : Type . show ~ cmp : Type . equal expected ( Type . instantiate ~ constraints ( : Map . find map ) generic ) in assert_instantiate [ ] ~ generic ( : Type . Primitive " ... |
let test_expression _ = let assert_expression annotation expression = assert_equal ~ printer : Expression . show ~ cmp ( : fun left right -> Expression . location_insensitive_compare left right = 0 ) ( parse_single_expression ~ coerce_special_methods : true expression ) ( Type . expression annotation ) in assert_expres... |
let test_concise _ = let assert_concise annotation expected = assert_equal ~ printer ( : fun annotation -> annotation ) expected ( Type . show_concise annotation ) in assert_concise Type . Bottom " " ; ? assert_concise Type . Top " unknown " ; assert_concise ( Type . Callable . create ~ name " :!& foo " ~ annotation : ... |
let test_weaken_literals _ = let assert_weakened_literal literal expected = assert_equal ~ printer : Type . show ~ cmp : Type . equal expected ( Type . weaken_literals literal ) in assert_weakened_literal ( Type . literal_integer 1 ) Type . integer ; assert_weakened_literal ( Type . literal_string " foo " ) Type . stri... |
let test_union _ = let assert_union arguments expected = assert_equal ~ printer : Type . show ~ cmp : Type . equal expected ( Type . union arguments ) in assert_union [ Type . string ; Type . optional ( Type . Union [ Type . integer ; Type . string ] ) ] ( Type . Union [ Type . none ; Type . integer ; Type . string ] )... |
let test_primitives _ = assert_equal [ ] ( Type . primitives ( Type . Callable . create ~ annotation : Type . Top ( ) ) ) ; assert_equal [ Type . integer ] ( Type . primitives ( Type . Callable . create ~ annotation : Type . integer ( ) ) ) ; assert_equal [ ] ( Type . primitives ( Type . optional Type . Top ) ) ; asser... |
let test_elements _ = let assert_equal = assert_equal ~ printer ( : List . to_string ~ f : Fn . id ) in assert_equal [ " typing . Callable " ] ( Type . elements ( Type . Callable . create ~ annotation : Type . Top ( ) ) ) ; assert_equal [ " int " ; " typing . Callable " ] ( Type . elements ( Type . Callable . create ~ ... |
let test_exists _ = let top_exists = Type . exists ~ predicate ( : function | Type . Top -> true | _ -> false ) in assert_true ( top_exists ( Type . Callable . create ~ annotation : Type . Top ( ) ) ) ; assert_false ( top_exists ( Type . Callable . create ~ annotation : Type . integer ( ) ) ) ; assert_true ( top_exists... |
let test_is_iterator _ = assert_true ( Type . is_iterator ( Type . iterator Type . string ) ) ; assert_false ( Type . is_iterator Type . string ) ; assert_false ( Type . is_iterator ( Type . Primitive " typing . Iterator " ) ) |
let test_contains_callable _ = assert_true ( Type . contains_callable ( Type . Callable . create ~ annotation : Type . integer ( ) ) ) ; assert_true ( Type . contains_callable ( Type . optional ( Type . Callable . create ~ annotation : Type . integer ( ) ) ) ) ; assert_true ( Type . contains_callable ( Type . union [ T... |
let test_map_callable_annotation _ = let assert_mapped ~ f callable expected = assert_equal ~ cmp : Type . Callable . equal ~ printer : Type . Callable . show expected ( Type . Callable . map_annotation ~ f callable ) in let callable = { Type . Record . Callable . kind = Type . Record . Callable . Named ( Reference . c... |
let test_type_parameters_for_bounded_tuple_union _ = let assert_type_parameters actual expected = assert_equal ~ cmp [ :% equal : Type . t list option ] ~ printer [ :% show : Type . t list option ] expected ( Type . type_parameters_for_bounded_tuple_union actual ) in assert_type_parameters Type . integer None ; assert_... |
let test_contains_any _ = assert_true ( Type . contains_any Type . Any ) |
let test_expression_contains_any _ = assert_true ( Type . expression_contains_any ( parse_single_expression ~ preprocess : true " typing . Dict [ typing . Any , typing . Any ] " ) ) ; assert_false ( Type . expression_contains_any ( parse_single_expression ~ preprocess : true " dict " ) ) ; assert_false ( Type . express... |
let test_is_concrete _ = assert_true ( Type . is_concrete Type . none ) ; assert_true ( Type . is_concrete ( Type . parametric " typing . Optional " [ ! Type . Bottom ] ) ) ; assert_true ( Type . is_concrete ( Type . Callable . create ~ annotation : Type . none ( ) ) ) ; assert_false ( Type . is_concrete ( Type . Calla... |
let test_is_not_instantiated _ = assert_true ( Type . is_not_instantiated Type . Bottom ) ; assert_true ( Type . is_not_instantiated ( Type . dictionary ~ key : Type . Bottom ~ value : Type . Bottom ) ) ; assert_false ( Type . is_not_instantiated Type . NoneType ) ; assert_false ( Type . is_not_instantiated Type . Top ... |
let test_is_meta _ = assert_true ( Type . is_meta ( Type . parametric " type " [ ! Type . integer ] ) ) ; assert_false ( Type . is_meta Type . integer ) ; assert_false ( Type . is_meta ( Type . parametric " typing . Type " [ ! Type . integer ] ) ) |
let test_is_none _ = assert_false ( Type . is_none ( Type . Primitive " None " ) ) ; assert_false ( Type . is_none Type . integer ) ; assert_false ( Type . is_none ( Type . Primitive " foo " ) ) ; assert_true ( Type . is_none Type . NoneType ) |
let test_is_type_alias _ = assert_true ( Type . is_type_alias ( Type . Primitive " typing_extensions . TypeAlias " ) ) ; assert_false ( Type . is_type_alias ( Type . Primitive " typing . TypeAlias " ) ) ; assert_false ( Type . is_type_alias ( Type . parametric " typing_extensions . TypeAlias " [ ! Type . Top ] ) ) |
let test_create_recursive_type _ = let tree_name , tree_body = " Tree " , Type . union [ Type . integer ; Type . tuple [ Type . Primitive " Foo " ; Type . Primitive " Tree " ] ] in let tree_annotation = Type . RecursiveType . create ~ name : tree_name ~ body : tree_body in assert_raises ( Failure " Body of recursive ty... |
let test_unfold_recursive_type _ = let assert_unfolded recursive_type expected = assert_equal ~ cmp : Type . equal ~ printer : Type . show expected ( match recursive_type with | Type . RecursiveType record -> Type . RecursiveType . unfold_recursive_type record | _ -> failwith " expected RecursiveType " ) in let tree_na... |
let test_contains_unknown _ = assert_true ( Type . contains_unknown Type . Top ) ; assert_false ( Type . contains_unknown Type . Bottom ) ; assert_false ( Type . contains_unknown Type . Any ) ; assert_true ( Type . contains_unknown ( Type . optional Type . Top ) ) ; assert_false ( Type . contains_unknown ( Type . optio... |
let test_contains_undefined _ = assert_true ( Type . contains_undefined Type . Bottom ) ; assert_false ( Type . contains_undefined Type . Top ) ; assert_false ( Type . contains_undefined Type . Any ) ; assert_true ( Type . contains_undefined ( Type . optional Type . Bottom ) ) ; assert_false ( Type . contains_undefined... |
let test_is_resolved _ = assert_false ( Type . Variable . all_variables_are_resolved ( Type . variable " _T " ) ) ; assert_false ( Type . Variable . all_variables_are_resolved ( Type . union [ Type . integer ; Type . variable " _T " ] ) ) ; assert_true ( Type . Variable . all_variables_are_resolved Type . integer ) ; a... |
let test_class_name _ = let assert_class_name annotation expected = assert_equal ~ cmp : Reference . equal ~ printer : Reference . show ( Reference . create expected ) ( Type . class_name annotation ) in assert_class_name ( Type . Primitive " qualified . primitive " ) " qualified . primitive " ; assert_class_name ( Typ... |
let test_optional_value _ = assert_equal ( Option . value_exn ( Type . optional_value ( Type . optional ( Type . parametric " foo " [ ! Type . integer ; Type . Top ] ) ) ) ) ( Type . parametric " foo " [ ! Type . integer ; Type . Top ] ) ; assert_true ( Option . is_none ( Type . optional_value ( Type . parametric " foo... |
let test_dequalify _ = let map = { | from typing import ( Optional , List , ) import typing from A . B import C import d as e } | in let assert_dequalify source expected = assert_equal ~ cmp : Type . equal ~ printer ( : Format . asprintf " % a " Type . pp ) ~ pp_diff ( : diff ~ print : Type . pp ) ( Type . dequalify ( ... |
let test_from_overloads _ = let assert_create ( ? aliases = Type . empty_aliases ) sources expected = let merged = let parse_callable source = match Type . create ~ aliases ( parse_single_expression source ) with | Type . Callable callable -> callable | _ -> failwith ( " Could not extract callable from " ^ source ) in ... |
let test_with_return_annotation _ = let assert_with_return_annotation annotation callable expected = let callable = match Type . create ~ aliases : Type . empty_aliases ( parse_single_expression callable ) with | Type . Callable callable -> callable | _ -> failwith ( " Could not extract callable from " ^ callable ) in ... |
let test_overload_parameters _ = let assert_parameters callable expected = let { Type . Callable . overloads ; _ } = Type . create ~ aliases : Type . empty_aliases ( parse_single_expression callable ) |> function | Type . Callable callable -> callable | _ -> failwith ( " Could not extract callable from " ^ callable ) i... |
let test_variables _ = let assert_variables source expected = let aliases = let aliases = Identifier . Map . of_alist_exn [ " T " , Type . variable " T " ; " S " , Type . variable " S " ] in Map . find aliases in let aliases = create_type_alias_table aliases in let variables = Type . create ~ aliases ( parse_single_exp... |
let test_lambda _ = assert_true ( Type . equal ( parse_callable " typing . Callable [ [ Named ( x , str ) ] , int ] " ) ( Type . lambda ~ parameters [ " : x " , Type . string ] ~ return_annotation : Type . integer ) ) ; assert_true ( Type . equal ( parse_callable " typing . Callable [ [ Keywords ( str ) ] , int ] " ) (... |
let test_visit _ = let create source = Type . create ~ aliases : Type . empty_aliases ( parse_single_expression source ) in let assert_types_equal annotation expected = assert_equal ~ printer : Type . show ~ cmp : Type . equal expected annotation in let module CountTransform = Type . Transform . Make ( struct type stat... |
let test_collapse_escaped_variable_unions _ = let assert_types_equal annotation expected = assert_equal ~ printer : Type . show ~ cmp : Type . equal expected annotation in let escaped = Type . Variable . mark_all_free_variables_as_escaped ( Type . variable " Escapee " ) in assert_types_equal ( Type . union [ Type . int... |
let test_namespace_insensitive_compare _ = let no_namespace_variable = Type . Variable . Unary . create " A " in let namespaced_variable_1 = let namespace = Type . Variable . Namespace . create_fresh ( ) in Type . Variable { no_namespace_variable with namespace } in let namespaced_variable_2 = let namespace = Type . Va... |
let test_namespace _ = let no_namespace_variable = Type . Variable . Unary . create " A " in let namespaced_variable_1 = let namespace = Type . Variable . Namespace . create_fresh ( ) in Type . Variable . Unary { no_namespace_variable with namespace } in let namespace_2 = Type . Variable . Namespace . create_fresh ( ) ... |
let test_mark_all_variables_as_bound _ = let variable = Type . Variable ( Type . Variable . Unary . create " T " ) in assert_false ( Type . Variable . all_variables_are_resolved variable ) ; let variable = Type . Variable . mark_all_variables_as_bound variable in assert_true ( Type . Variable . all_variables_are_resolv... |
let test_mark_all_variables_as_free _ = let variable = Type . Variable ( Type . Variable . Unary . create " T " ) |> Type . Variable . mark_all_variables_as_bound in assert_true ( Type . Variable . all_variables_are_resolved variable ) ; let variable = Type . Variable . mark_all_variables_as_free variable in assert_fal... |
let test_namespace_all_free_variables _ = let free_variable = Type . Variable ( Type . Variable . Unary . create " T " ) in let bound_variable = Type . Variable . Unary . create " T2 " |> Type . Variable . Unary . mark_as_bound |> fun variable -> Type . Variable variable in let annotation = Type . parametric " p " [ ! ... |
let test_mark_all_free_variables_as_escaped _ = let free_variable = Type . Variable ( Type . Variable . Unary . create " T " ) in let bound_variable = Type . Variable . Unary . create " T2 " |> Type . Variable . Unary . mark_as_bound |> fun variable -> Type . Variable variable in let annotation = Type . parametric " p ... |
let test_contains_escaped_free_variable _ = let free_variable = Type . Variable ( Type . Variable . Unary . create " T " ) in assert_false ( Type . Variable . contains_escaped_free_variable free_variable ) ; let escaped_free = Type . Variable . Unary . create " T " |> Type . Variable . Unary . mark_as_escaped |> fun va... |
let polynomial_create_from_variables_list = Type . Polynomial . create_from_variables_list ~ compare_t : Type . compare |
let test_convert_all_escaped_free_variables_to_anys _ = let free_variable = Type . Variable ( Type . Variable . Unary . create " T " ) in let escaped_free = Type . Variable . Unary . create " T " |> Type . Variable . Unary . mark_as_escaped |> fun variable -> Type . Variable variable in let annotation = Type . parametr... |
let test_int_expression_create _ = let x = Type . Variable . Unary . create " x " in let y = Type . Variable . Unary . create " y " in let assert_create_list_type given expected = assert_equal ~ printer [ :% show : Type . type_t ] ~ cmp [ :% equal : Type . type_t ] ( Type . IntExpression . create ( polynomial_create_fr... |
let test_replace_all _ = let free_variable = Type . Variable ( Type . Variable . Unary . create " T " ) in let annotation = Type . parametric " p " [ ! free_variable ; Type . integer ] in let assert_equal actual expected = assert_equal ~ cmp : Type . equal ~ printer : Type . show expected actual in assert_equal ( Type ... |
let test_product_replace_variadic _ = let assert_equal actual expected = assert_equal ~ cmp : Type . equal ~ printer : Type . show expected actual in let variadic = Type . Variable . Variadic . Tuple . create " Ts " in let variadic2 = Type . Variable . Variadic . Tuple . create " Ts2 " in let variable = Type . Variable... |
let test_less_or_equal _ = let assert_solve ~ left ~ right expected = let impossible = [ ] in let rec solve ~ left ~ right = match left , right with | Type . Variable variable1 , Type . Variable variable2 -> List . sort [ [ variable1 , Type . Variable variable2 ] ; [ variable2 , Type . Variable variable1 ] ] ~ compare ... |
let test_collect_all _ = let free_variable = Type . Variable ( Type . Variable . Unary . create " T " ) in let annotation = Type . parametric " p " [ ! free_variable ; Type . integer ] in assert_equal ( Type . Variable . GlobalTransforms . Unary . collect_all annotation ) [ Type . Variable . Unary . create " T " ] ; as... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.