Rather than assert that the types are correct, use the force type functions on the parameters:
ff, fk, fs, q2f, v2f, and the new fi, fl.
These functions have also been modified to ensure that the input type supports an implicit typecast to the target type and perform it, or emit ELSLInvalidType otherwise, rather than an assertion failure. fl in particular returns the original list if it isn't changed, or a copy if it is.
A couple bugs were found in testfuncs.py as a result, which have been fixed as well. A test has been added to ensure that the exception that caught these bugs remains in place.
The isxxxx functions are no longer necessary, so they are removed. Same goes for the painful cast handling process in foldconst, which was basically performing this task, and not necessarily well.
This approach is much more robust and should have been used since the beginning, but I didn't figure it out then.
When the input was of the form e.g. "%4%40", the second "%" was erroneously starting another quoted character. LSL doesn't behave that way: parsing resumes without starting another quoted character. Disturbingly, the expected result in the corresponding test was wrong. Fixed both the test case and the code to match actual LSL behaviour.
There was a duplicate(ish) test, which tested float("nan") instead of NaN or Indet. On Windows it was not duplicate, because under Windows, float("nan") produces Indet, which was not tested. Change it to Indet so we know what we're testing.
It doesn't make sense to check the output multiple times. It would if lslcommon.IsCalc were set to True, because then it wouldn't be distinguishable from a randomly obtained value. But in non-calc mode, it would raise ELSLCantCompute if it were unpredictable, so it's OK to check just once because if it doesn't raise, it's predictable and can be checked.
The test for two empty lists passed to llListFindList was duplicated. That case generates -1 under LSO, and that wasn't tested, so we add that as a test now. Check also that another corner case behaves properly under LSO.
The reason is they have an embedded delay. A script might rely on it, therefore substituting the call with its value is not equivalent to leaving the call. They were both already excluded from the SEF table for the same reason.
- Remove it from lslextrafuncs, and move all the code to lslbasefuncs.
- Make it behave like SL's more accurately. Denormals return 0 always in SL.
- Use int() for truncation rather then floor/ceil.
- Add test cases.
llBase64ToString doesn't behave like llUnescapeURL wrt invalid UTF-8. First, the last NUL if any is removed, and the remaining NULs are converted to "?". Second, all overlong sequences are converted to a single "?", *including the 5- and 6-byte UTF-8*.
Implement this behavour and the corresponding unit tests.
Our UTF-8 validity checker failed to recognize that characters in the surrogate range (D800-DFFF) were invalid. Fortunately, Python 2 is happy about that, therefore it doesn't crash (Python 3 fixed that range too). Unfortunately, SL isn't, therefore we fix it.
Added corresponding unit tests.
One big disappointment is that Python doesn't allow redefining float.__repr__, leading to a much increased difficulty in checking and reporting differences in NaN vs. Indet. We do what we can, though. We re-enable the recursive comparison as opposed to the repr comparison.
As a result, many of the tests reported wrong results. Fixed them. Fix also a problem with comparing infinities (they can't be compared to a tolerance).
This commit also changes the struct.pack check to math.copysing as in the previous commit.
reallyequal: Compare the sign of NaN when checking if the args are NaN.
Tests added:
- llAsin, llAcos with out-of-range argument produces NaN.
- llAtan2 with (0, 0) produces 0.
- Sign of NaN is not distinguished in lists, even if NaN compares equal to NaN.
Besides dividing by zero, any result producing NaN including inf/inf, NaN/anything, anything/NaN causes a math error as well. We only contemplated NaN/anything and neglected the rest, so we generalize it.
Fix bug: add(Key, Key) is not valid.
Fix bug: llList2CSV was raising an exception always.
Fix bug in test program: llDumpList2String requires Unicode separator.
Patch test program to not output the passed tests.
- Scratch TODO item: Change shouldbeXXX to asserts.
- shoudlbeXXX(x) has been turned into assert isXXX(x). Affects lsl2json too.
- New base functions:
- compare (for == and !=)
- less (for <, >, <=, >=)
- minus() renamed to neg() for consistency. Affects testfuncs too.
- add() now supports key+string and string+key.
- Allow integers in place of floats. That has caused the addition of three utility functions:
- ff (force float)
- v2f (force floats in all components of a vector)
- q2f (force floats in all components of a quaternion)
Used everywhere where necessary.
Special care was taken in a few funcs (llListFindList and maybe others) to ensure that lists containing vectors or quaternions which in turn contain integer components, behave as if they were floats, because LSL lists can not physically hold integer values as components of vectors/quats.
This also fixes a case where if a large integer had more precision than a F32 (e.g. 16777217), the product/division would be more precise than what LSL returns.
- Fix bugs of missing F32() in some places (llRotBetween, llEuler2Rot).
- Some functions marked for moving in an incoming commit.
- llList2CSV marked with a warning that it is not thread safe. That's a future TODO.
- Document llListFindList better.
- Make llListStatistics Use a more orthodox method to return the result for LIST_STAT_RANGE, LIST_STAT_MIN, LIST_STAT_MAX.
- Make llAxisAngle2Rot use more precision from llVecNorm, by adding an optional truncation parameter in the latter.
- Change order of some F32(Quaternion(...)) to not force so much instancing.
- Bugfix: llVecNorm did not return a Vector.