Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule TypeClass.Property do
- @moduledoc "A *very* simple prop checker"
- # (...)
- @doc "Run all properties for the type class"
- def run!(datatype, class, prop_name, times \\ 100) do
- property_module = Module.concat(class, Property)
- # Irrelevant parts in this scenario are commented out.
- # custom_generator = Module.concat([class, "Proto", datatype]).__custom_generator__()
- data_generator =
- # if custom_generator do
- # custom_generator
- # else
- Module.concat(TypeClass.Property.Generator, datatype).generate(nil)
- # end
- fn ->
- unless apply(property_module, prop_name, [data_generator]) do
- raise TypeClass.Property.FailedCheckError.new(datatype, class, prop_name)
- end
- end
- |> Stream.repeatedly()
- |> Enum.take(times)
- end
- # (...)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement