X-Git-Url: https://git.yukkurigames.com/?p=string-lerp.git;a=blobdiff_plain;f=tests%2Fstring-lerp.js;fp=tests%2Fstring-lerp.js;h=7cee7d175b106f9c312e32109b86a6ebdc20c133;hp=5728e7f9ece4844cfea0f3a17050e6bf405b3999;hb=f037d43269bdb28acf28500ce24d2bef1e011a75;hpb=245005bdfa792a76d55b0fafd2255c4c8325d28c diff --git a/tests/string-lerp.js b/tests/string-lerp.js index 5728e7f..7cee7d1 100644 --- a/tests/string-lerp.js +++ b/tests/string-lerp.js @@ -114,6 +114,22 @@ JS.Test.describe('diff lerp', function () { with (this) { assert(r === "a" || r === UNUSUAL_Q); } }}); + + it("prefers ins/del to sub/sub", function () { with (this) { + // When the cost is uniform this string can be transformed by + // rewriting the whole thing for the same cost as deleting the + // front and adding to the back. But visually, we'd rather do + // the latter. + assertEqual("core", lerp("hard core", "core dump", 0.50)); + }}); + + it("weights ins/del cheaper than sub", function () { with (this) { + // When the cost is uniform it is cheaper to rewrite the + // former into the latter. But we'd rather keep the "core" for + // visual reasons, so we need to make sure we have unequal + // costs. + assertEqual("core", lerp("apple core", "core dump", 0.51)); + }}); }}); JS.Test.describe('numeric lerp', function () { with (this) {