- assertEqual("Do you like green eggsSam-I-am.", lerp(A, B, 0.3));
- assertEqual("Do you like green Sam-I-am.", lerp(A, B, 0.5));
- assertEqual("do not like them, Sam-I-am.", lerp(A, B, 0.9));
+ assertEqual(A, lerp(A, B, 0.01));
+ assertEqual("I do not like treen eggs and ham?", lerp(A, B, 0.3));
+ assertEqual("I do not like them, eggs and ham?", lerp(A, B, 0.5));
+ assertEqual("I do not like them, Sam-Iham?", lerp(A, B, 0.9));
+ assertEqual(B, lerp(A, B, 0.99));
+ }});
+
+ it("doesn't make half a poo", function () { with (this) {
+ var poos = "\uD83D\uDCA9\uD83D\uDCA9\uD83D\uDCA9\uD83D\uDCA9";
+ assertEqual("\uD83D\uDCA9\uD83D\uDCA9", lerp("", poos, 0.5));
+ assertEqual("\uD83D\uDCA9", lerp("", poos, 0.35));
+
+ for (var i = 0; i <= 1; i += 1/256)
+ assertNot(lerp("", poos, i).match(HALF_POOS));
+ }});
+
+ it("doesn't misplace combining marks", function () { with (this) {
+ for (var i = 0; i <= 1; i += 1/256) {
+ var r = lerp("a", UNUSUAL_Q, i);
+ 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));