|
| 1 | +function check(name, value) { |
| 2 | + var value2 = value; |
| 3 | + |
| 4 | + if (typeof value2 === "string") { |
| 5 | + value2 = value2.split("\r").join("\\r").split("\n").join("\\n"); |
| 6 | + } |
| 7 | + |
| 8 | + trace(name + ": " + value2 + " [" + (typeof value) + "]"); |
| 9 | +} |
| 10 | + |
| 11 | +var ts = new TextSnapshot(_root); |
| 12 | + |
| 13 | +check("getCount()", ts.getCount()); |
| 14 | + |
| 15 | +check("findText()", ts.findText()); |
| 16 | +check("findText(0)", ts.findText(0)); |
| 17 | +check("findText(1)", ts.findText(1)); |
| 18 | +check("findText(1, \"A\")", ts.findText(1, "A")); |
| 19 | +check("findText(1, \"A\", true)", ts.findText(1, "A", true)); |
| 20 | +check("findText(1, \"A\", true, 1)", ts.findText(1, "A", true, 1)); |
| 21 | + |
| 22 | +check("findText(0, \"A\", true)", ts.findText(0, "A", true)); |
| 23 | +check("findText(0, \"A\", false)", ts.findText(0, "A", false)); |
| 24 | +check("findText(0, \"a\", false)", ts.findText(0, "a", false)); |
| 25 | +check("findText(0, \"a\", true)", ts.findText(0, "a", true)); |
| 26 | + |
| 27 | +check("findText(0, \"EF\", true)", ts.findText(0, "EF", true)); |
| 28 | +check("findText(0, \"eF\", true)", ts.findText(0, "eF", true)); |
| 29 | +check("findText(0, \"eF\", false)", ts.findText(0, "eF", false)); |
| 30 | + |
| 31 | +check("findText(1, \"EF\", true)", ts.findText(1, "EF", true)); |
| 32 | +check("findText(3, \"EF\", true)", ts.findText(3, "EF", true)); |
| 33 | +check("findText(4, \"EF\", true)", ts.findText(4, "EF", true)); |
| 34 | +check("findText(5, \"EF\", true)", ts.findText(5, "EF", true)); |
| 35 | + |
| 36 | +check("findText(0, \"FG\", true)", ts.findText(0, "FG", true)); |
| 37 | +check("findText(0, \"FG\", false)", ts.findText(0, "FG", false)); |
| 38 | +check("findText(0, \"gh\", true)", ts.findText(0, "gh", true)); |
| 39 | +check("findText(0, \"gh\", false)", ts.findText(0, "gh", false)); |
| 40 | +check("findText(0, \"F\\nG\", true)", ts.findText(0, "F\nG", true)); |
| 41 | +check("findText(0, \"F\\nG\", false)", ts.findText(0, "F\nG", false)); |
| 42 | + |
| 43 | +check("findText(0, \" \", false)", ts.findText(0, " ", false)); |
| 44 | + |
| 45 | +var threeLike = {}; |
| 46 | +threeLike.valueOf = function() { return 3; } |
| 47 | +check("findText(3-like, \"A\", true)", ts.findText(threeLike, "A", true)); |
| 48 | +check("findText(3-like, \"E\", true)", ts.findText(threeLike, "E", true)); |
| 49 | + |
| 50 | +var stringLike = {}; |
| 51 | +stringLike.toString = function() { return "C"; } |
| 52 | +check("findText(0, C-like, true)", ts.findText(0, stringLike, true)); |
| 53 | +check("findText(4, C-like, true)", ts.findText(4, stringLike, true)); |
| 54 | + |
| 55 | +check("findText(0, \"A\", 1)", ts.findText(0, "A", 1)); |
| 56 | +check("findText(0, \"A\", new Object())", ts.findText(0, "A", new Object())); |
| 57 | +check("findText(0, \"A\", \"0\")", ts.findText(0, "A", "0")); |
| 58 | + |
| 59 | +check("findText(0, \"ABCDEFGHIJK\", true)", ts.findText(0, "ABCDEFGHIJK", true)); |
| 60 | +check("findText(0, \"aBcdEfGHIjK\", true)", ts.findText(0, "aBcdEfGHIjK", true)); |
| 61 | +check("findText(0, \"aBcdEfGHIjK\", false)", ts.findText(0, "aBcdEfGHIjK", false)); |
| 62 | + |
| 63 | +check("findText(-1, \"A\", 1)", ts.findText(-1, "A", 1)); |
| 64 | +check("findText(-10, \"A\", 1)", ts.findText(-10, "A", 1)); |
| 65 | +check("findText(100, \"A\", 1)", ts.findText(100, "A", 1)); |
| 66 | + |
| 67 | +check("findText(0, \"\", true)", ts.findText(0, "", true)); |
| 68 | +check("findText(0, \"\", false)", ts.findText(0, "", false)); |
| 69 | +check("findText(1, \"\", true)", ts.findText(1, "", true)); |
| 70 | +check("findText(1, \"\", false)", ts.findText(1, "", false)); |
| 71 | +check("findText(-1, \"\", true)", ts.findText(-1, "", true)); |
| 72 | +check("findText(-1, \"\", false)", ts.findText(-1, "", false)); |
0 commit comments