I’m working on the Hologram project which aims to transpile Elixir code to Javascript.
To give context, I’m working on a Javascript implementation of the :filename.rootname/2 function. This should be implemented to strictly follow the Erlang implementation.
This function is then tested using javascript tests, along with corresponding consistency tests that look for the same results using ExUnit.
However, I am experiencing an inconsistency between Erlang and Elixir when using this function with an empty list as the first argument.
If I use erl, passing an empty list returns an empty list.:
1> filename:rootname([], “.erl”).
[]
If I do the same in Elixir, passing an empty list returns an empty Binary.
iex(1)> :filename.rootname([], “.ext”)
“”
This is mirrored in ExUnit. the following passes:
assert :filename.rootname([], ".erl") == ""
But asserting an empty list fails:
assert :filename.rootname([], ".erl") == [ ]
This means I either cannot maintain strict compatibility with Erlang, or I cannot keep my javascript and ExUnit tests consistent as JS would test for an empty list (a boxed type in Hologram) and an empty Binary in ExUnit.
Is there any way I can coerce Elixir to return the same empty list type that Erlang does, or am I going to have to accept the inconsistency between tests?






















