123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869open!Coreopen!Importopen!BonsaiopenProcopenBonsai.Let_syntaxmodulePath=Bonsai.Private.Pathlet%expect_test"path"=letcomponent=let%sub()=Bonsai.const()inlet%subpath=Bonsai.Private.pathinreturn(Value.mappath~f:Path.to_unique_identifier_string)inlethandle=Handle.create(Result_spec.string(moduleString))componentinHandle.disable_bonsai_path_censoringhandle;Handle.showhandle;(* The first of these "Subst_from" is actually a component that is
added by the testing helpers. *)[%expect{| bonsai_path_x_y_y_x |}];;letassert_path_unique_id_is_alphapath=letunique_id=Path.to_unique_identifier_stringpathinassert(String.for_allunique_id~f:(function|'a'..'z'|'_'->true|_->false));;let%test_unit"all the values are alpha"=letstring_id=Type_equal.Id.create~name:"string"[%sexp_of:string]inletkeyed=Path.Elem.keyed~compare:String.comparestring_id|>unstageinQuickcheck.testString.quickcheck_generator~sexp_of:[%sexp_of:string]~f:(funstring->letpath=Path.appendPath.empty(Path.Elem.Assoc(keyedstring))inassert_path_unique_id_is_alphapath);;let%test_unit"larger groupings of paths behave"=letstring_id=Type_equal.Id.create~name:"string"[%sexp_of:string]inletkeyed=Path.Elem.keyed~compare:String.comparestring_id|>unstageinletmoduleP=struct(* Make a dumb version of this module so that we can derive quickcheck for it. *)typet=|From|Into|Assocofstring|Switchofint[@@derivingquickcheck,sexp]letto_path_element=function|From->Path.Elem.Subst_from|Into->Path.Elem.Subst_into|Assocs->Path.Elem.Assoc(keyeds)|Switchi->Path.Elem.Switchi;;endinQuickcheck.test[%quickcheck.generator:P.tlist]~sexp_of:[%sexp_of:P.tlist]~f:(funpath->letpath=path|>List.map~f:P.to_path_element|>List.fold~init:Path.empty~f:Path.appendinassert_path_unique_id_is_alphapath);;