delphidabbler / codesnip

A code bank designed with Pascal in mind
https://delphidabbler.com/software/codesnip
Other
111 stars 34 forks source link

`TREMLEntities.MapToEntity` doesn't perform per description #84

Open delphidabbler opened 1 year ago

delphidabbler commented 1 year ago

https://github.com/delphidabbler/codesnip/blob/02656b8417c2863a89cf2bf45e3be275ca9f94a9/Src/UREMLDataIO.pas#L904

Description says this function returns the character itself if it is printable ASCII, but it returns the empty string in this case.

delphidabbler commented 1 year ago

Need to check how this method is used. If calling code depends on out of spec behaviour then update comments else correct the code.

delphidabbler commented 1 year ago

TREMLEntities.MapToEntity gets called from this method:

https://github.com/delphidabbler/codesnip/blob/02656b8417c2863a89cf2bf45e3be275ca9f94a9/Src/UREMLDataIO.pas#L655

This code tests the method's return value against the empty string, so this is what it is expecting.

So, it looks like the method acts as expected and the comments are wrong.

I think the actual behaviour is reasonable because the code is supposed to be return an entity if one exists. Furthermore, the calling code has to wrap the entity between & and ; characters, so the empty string result is useful to help deciding if this should be done.

Maybe renaming to MapToEntityIfExists would clarify.