Guest User

Untitled

a guest
Oct 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. defmodule DecimalTest do
  2. use ExUnit.Case, async: true
  3.  
  4. alias Decimal.Context
  5. alias Decimal.Error
  6.  
  7. require Decimal
  8.  
  9. doctest Decimal
  10.  
  11. defmacrop d(sign, coef, exp) do
  12. quote do
  13. %Decimal{sign: unquote(sign), coef: unquote(coef), exp: unquote(exp)}
  14. end
  15. end
  16. # Function version of the `d` macro, which appears to be equivalent
  17. # in terms of outcome.
  18. # def d(sign, coef, exp) do
  19. # %Decimal{sign: sign, coef: coef, exp: exp}
  20. # end
  21.  
  22. defmacrop sigil_d(str, _opts) do
  23. quote do
  24. Decimal.new(unquote(str))
  25. end
  26. end
  27.  
  28. test "test functions" do
  29. assert Decimal.nan?(~d"nan")
  30. refute Decimal.nan?(~d"0")
  31.  
  32. assert Decimal.inf?(~d"inf")
  33. refute Decimal.inf?(~d"0")
  34.  
  35. assert Decimal.decimal?(~d"nan")
  36. assert Decimal.decimal?(~d"inf")
  37. # ... lots more below
Add Comment
Please, Sign In to add comment