Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. defmodule TypeClass.Property do
  2. @moduledoc "A *very* simple prop checker"
  3.  
  4. # (...)
  5.  
  6. @doc "Run all properties for the type class"
  7. def run!(datatype, class, prop_name, times \\ 100) do
  8. property_module = Module.concat(class, Property)
  9.  
  10. # Irrelevant parts in this scenario are commented out.
  11.  
  12. # custom_generator = Module.concat([class, "Proto", datatype]).__custom_generator__()
  13.  
  14. data_generator =
  15. # if custom_generator do
  16. # custom_generator
  17. # else
  18. Module.concat(TypeClass.Property.Generator, datatype).generate(nil)
  19. # end
  20.  
  21. fn ->
  22. unless apply(property_module, prop_name, [data_generator]) do
  23. raise TypeClass.Property.FailedCheckError.new(datatype, class, prop_name)
  24. end
  25. end
  26. |> Stream.repeatedly()
  27. |> Enum.take(times)
  28. end
  29.  
  30. # (...)
  31.  
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement