X-Git-Url: https://git.yukkurigames.com/?p=string-lerp.git;a=blobdiff_plain;f=tests%2Fstring-lerp.js;h=0a68921793c96ddfe07ea1093c78a9d4fe724e1e;hp=7cee7d175b106f9c312e32109b86a6ebdc20c133;hb=0c13ad2908e977aca58e5411e724881abca7228b;hpb=8ca7031e6a8079cecb8e06186c0d50cb2ab0aceb diff --git a/tests/string-lerp.js b/tests/string-lerp.js index 7cee7d1..0a68921 100644 --- a/tests/string-lerp.js +++ b/tests/string-lerp.js @@ -169,3 +169,36 @@ JS.Test.describe('numeric lerp', function () { with (this) { assertEqual("Chapter 5. The sky was rgb(0, 0, 128).", lerp(A, B, 0.5)); }}); }}); + +JS.Test.describe('fast lerp', function () { with (this) { + var lerp = m.lerp; + var A = "Do you like green eggs and ham?"; + var B = "I do not like them, Sam-I-am."; + + it("handles empty strings", function () { with (this) { + assertEqual("", lerp("", "", -1)); + assertEqual("", lerp("", "", 0)); + assertEqual("", lerp("", "", 0.5)); + assertEqual("", lerp("", "", 1)); + assertEqual("", lerp("", "", 2)); + }}); + + it("maintains identity", function () { with (this) { + for (var i = -1; i < 2; i += 1/1024) { + assertEqual(A, lerp(A, A, i)); + assertEqual(B, lerp(B, B, i)); + } + }}); + + it("handles lows", function () { with (this) { + assertEqual(A, lerp(A, B, -Infinity)); + assertEqual(A, lerp(A, B, -1)); + assertEqual(A, lerp(A, B, 0)); + }}); + + it("handles highs", function () { with (this) { + assertEqual(B, lerp(A, B, 1)); + assertEqual(B, lerp(A, B, 2)); + assertEqual(B, lerp(A, B, Infinity)); + }}); +}});