Improve output of userdata, handling`__tostring` and NULL
This PR includes 2 commits:
The first one includes evaluation of __tostring for userdata values. This should be safe because __tostring of userdata is unlikely to recurse into inspect. A test is included.
The second one adds a special case for NULL userdata.
When interpreting userdata values using 'inspect', the numeric identifiers
are useful to match identify of pointers (comparing the low counters
like <userdata 3> is easier than reading long pointers like userdata: 0x749abc39efa29`).
However, the NULL pointer is enough of a special case that it is
important to know when one of those numbered pointers happens to
be NULL. When one is dealing with things like JSON parsers, where
the only usual userdata is cjson.null, one gets accostumed over
time to interpret <userdata 1> to mean NULL. This is not obvious,
however, and a seasoned user will trip up the day another userdata
is used in the same table and NULL is now <userdata 2>.
Adding a test for this would require compiling and loading a C extension, such as lua-cjson. I can do so if desired.
Coverage decreased (-1.1%) to 98.178% when pulling c32cdda2bb58b63ab26ac9031295422e89fb81ca on hishamhm:tostring-userdata into b611db6bfa9c12ce35dd4972032fbbd2ad5ba965 on kikito:master.
Coverage decreased (-1.1%) to 98.178% when pulling c32cdda2bb58b63ab26ac9031295422e89fb81ca on hishamhm:tostring-userdata into b611db6bfa9c12ce35dd4972032fbbd2ad5ba965 on kikito:master.