adobe / json-formula

Query language for JSON documents
http://opensource.adobe.com/json-formula/
Apache License 2.0
19 stars 8 forks source link

Incorrect "substitute" results #131

Closed Eswcvlad closed 6 months ago

Eswcvlad commented 6 months ago

Haven't checked, what the cause for these issues might be, but here are the cases:

Expression Expected Actual
substitute(13.37, "3", "42")|142.427|142.37
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", "😀")|😀Ю😀н😀и😀к😀о😀д😀|🤕Ю🤕н🤕и🤕к🤕о🤕д😀
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", `null`, "😀")|🤕Ю🤕н🤕и🤕к🤕о🤕д🤕|😀🤕Ю😀🤕н😀🤕и😀🤕к😀🤕о😀🤕д😀🤕
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", `null`)|Юникод|🤕Ю🤕н🤕и🤕к🤕о🤕д
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", `false`)|falseЮfalseнfalseиfalseкfalseоfalseдfalse|🤕Ю🤕н🤕и🤕к🤕о🤕дfalse
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", `true`)|trueЮtrueнtrueиtrueкtrueоtrueдtrue|🤕Ю🤕н🤕и🤕к🤕о🤕дtrue
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", 42)|42Ю42н42и42к42о42д42|🤕Ю🤕н🤕и🤕к🤕о🤕д42
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", "😀", `true`)|😀Ю🤕н🤕и🤕к🤕о🤕д🤕|🤕Ю🤕н🤕и🤕к🤕о🤕д😀
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", "😀", 2)|🤕Ю😀н🤕и🤕к🤕о🤕д🤕|🤕Ю🤕н🤕и🤕к🤕о🤕д🤕
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", "😀", 1.1)|😀Ю🤕н🤕и🤕к🤕о🤕д🤕|🤕Ю🤕н🤕и🤕к🤕о🤕д😀
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", "😀", "3.5")|🤕Ю🤕н😀и🤕к🤕о🤕д🤕|🤕Ю🤕н🤕и🤕к🤕о🤕д🤕
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "", "😀")|🤕Ю🤕н🤕и🤕к🤕о🤕д🤕|😀🤕Ю😀🤕н😀🤕и😀🤕к😀🤕о😀🤕д😀🤕
substitute("🤕Ю🤕н🤕и🤕к🤕о🤕д🤕", "🤕", "")|Юникод|🤕Ю🤕н🤕и🤕к🤕о🤕д
  1. For some reason, calls without which replace only some of the matches.
  2. Similarly, if which is 1, it replaces only the last occurrence and none, if it is greater...
  3. When old is empty, instead of returning the string as-is, it returns a modification.