DoclerLabs / hexMachina

Releases, issues, documentation, website of hexMachina, framework written in Haxe
http://hexmachina.org
MIT License
44 stars 8 forks source link

The ambiguous behavior of parameterized message formatter #224

Closed ivan-slepchenko closed 7 years ago

ivan-slepchenko commented 7 years ago

I'm not sure, but looks wrong - ["{}", null, "{}"], gives you "{}" when ["Test message {}{} {}", ["a", "b"], "Test message ab null"] gives you null for the same empty value. Its in ParameterizedMessageTest.hx.

I think both should print "null", or both should print "{}"

st3veV commented 7 years ago

there is a difference between null as parameters and null as an empty value... logger.debug("{}") outputs "{}" because there are no replacements requested... same goes for logger.debug("{}",null) because that is exactly the same statement as the one before. logger.debug("{}",[]) on the other hand asks for replacements but the value is missing so the correct output should be "null". In other words, the empty value you're referring to is not really the same empty value. It's "I don't have any replacements" vs. "I don't have a value to be replaced".

That said, there is inconsistency but not between the tests you wrote (where the behavior is correct) but between ["{}", [], "{}"] and ["Test message {}{} {}", ["a", "b"], "Test message ab null"] where the first one should clearly output "null"

st3veV commented 7 years ago

fixed