KLaus_K
Problem using NaiveDateTime in doctest
I have written some code that parses a string and creates a NaiveDateTime. I have written some ExUnit tests that work fine, comparing the result against a naive date time constant, created using the ~N sigil.
Unfortunately, this approach does not seem to work when I put the equivalent tests into DocTests, e.g.
code: date_parse(“31-May-2021”) === ~N[2021-05-31 00:00:00]
left: %NaiveDateTime{calendar: Calendar.ISO, day: 31, hour: 0, microsecond: {0, 0}, minute: 0, month: 5, second: 0, year: 2021}
right: ~N[2021-05-31 00:00:00]
Is there some reason why the comparison why the comparison works in one context but not in another? Is is due to the use of the ‘===’ operator? If so, is there any way I can modify this behaviour?
please note, I am using the Timex library to do the actual parsing. i am adding some metadata of my own, which I have omitted from this example, for simplicity.
First Post!
kokolegorille
Most Liked
kokolegorille
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









