Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule DecimalTest do
- use ExUnit.Case, async: true
- alias Decimal.Context
- alias Decimal.Error
- require Decimal
- doctest Decimal
- defmacrop d(sign, coef, exp) do
- quote do
- %Decimal{sign: unquote(sign), coef: unquote(coef), exp: unquote(exp)}
- end
- end
- # Function version of the `d` macro, which appears to be equivalent
- # in terms of outcome.
- # def d(sign, coef, exp) do
- # %Decimal{sign: sign, coef: coef, exp: exp}
- # end
- defmacrop sigil_d(str, _opts) do
- quote do
- Decimal.new(unquote(str))
- end
- end
- test "test functions" do
- assert Decimal.nan?(~d"nan")
- refute Decimal.nan?(~d"0")
- assert Decimal.inf?(~d"inf")
- refute Decimal.inf?(~d"0")
- assert Decimal.decimal?(~d"nan")
- assert Decimal.decimal?(~d"inf")
- # ... lots more below
Add Comment
Please, Sign In to add comment