File modules/editor/codemirror/test/search_test.min.js
Last commit: Tue May 22 22:39:53 2018 +0200 Jan Dankert Fix für PHP 7.2: 'Object' darf nun nicht mehr als Klassennamen verwendet werden. AUCH NICHT IN EINEM NAMESPACE! WTF, wozu habe ich das in einen verfickten Namespace gepackt? Wozu soll der sonst da sein??? Amateure. Daher nun notgedrungen unbenannt in 'BaseObject'.
1 (function() { 2 "use strict"; 3 4 function run(doc, query, options) { 5 var cursor = doc.getSearchCursor(query, null, options); 6 for (var i = 3; i < arguments.length; i += 4) { 7 var found = cursor.findNext(); 8 is(found, "not enough results (forward)"); 9 eqCharPos(Pos(arguments[i], arguments[i + 1]), cursor.from(), "from, forward, " + (i - 3) / 4); 10 eqCharPos(Pos(arguments[i + 2], arguments[i + 3]), cursor.to(), "to, forward, " + (i - 3) / 4); 11 } 12 is(!cursor.findNext(), "too many matches (forward)"); 13 for (var i = arguments.length - 4; i >= 3; i -= 4) { 14 var found = cursor.findPrevious(); 15 is(found, "not enough results (backwards)"); 16 eqCharPos(Pos(arguments[i], arguments[i + 1]), cursor.from(), "from, backwards, " + (i - 3) / 4); 17 eqCharPos(Pos(arguments[i + 2], arguments[i + 3]), cursor.to(), "to, backwards, " + (i - 3) / 4); 18 } 19 is(!cursor.findPrevious(), "too many matches (backwards)"); 20 } 21 22 function test(name, f) { window.test("search_" + name, f) } 23 24 test("simple", function() { 25 var doc = new CodeMirror.Doc("abcdefg\nabcdefg") 26 run(doc, "cde", false, 0, 2, 0, 5, 1, 2, 1, 5); 27 }); 28 29 test("multiline", function() { 30 var doc = new CodeMirror.Doc("hallo\na\nb\ngoodbye") 31 run(doc, "llo\na\nb\ngoo", false, 0, 2, 3, 3); 32 run(doc, "blah\na\nb\nhall", false); 33 run(doc, "bye\nx\neye", false); 34 }); 35 36 test("regexp", function() { 37 var doc = new CodeMirror.Doc("abcde\nabcde") 38 run(doc, /bcd/, false, 0, 1, 0, 4, 1, 1, 1, 4); 39 run(doc, /BCD/, false); 40 run(doc, /BCD/i, false, 0, 1, 0, 4, 1, 1, 1, 4); 41 }); 42 43 test("regexpMultiline", function() { 44 var doc = new CodeMirror.Doc("foo foo\nbar\nbaz") 45 run(doc, /fo[^]*az/, {multiline: true}, 0, 0, 2, 3) 46 run(doc, /[oa][^u]/, {multiline: true}, 0, 1, 0, 3, 0, 5, 0, 7, 1, 1, 1, 3, 2, 1, 2, 3) 47 run(doc, /[a][^u]{2}/, {multiline: true}, 1, 1, 2, 0) 48 }) 49 50 test("insensitive", function() { 51 var doc = new CodeMirror.Doc("hallo\nHALLO\noink\nhAllO") 52 run(doc, "All", false, 3, 1, 3, 4); 53 run(doc, "All", true, 0, 1, 0, 4, 1, 1, 1, 4, 3, 1, 3, 4); 54 }); 55 56 test("multilineInsensitive", function() { 57 var doc = new CodeMirror.Doc("zie ginds komT\nDe Stoomboot\nuit Spanje weer aan") 58 run(doc, "komt\nde stoomboot\nuit", false); 59 run(doc, "komt\nde stoomboot\nuit", {caseFold: true}, 0, 10, 2, 3); 60 run(doc, "kOMt\ndE stOOmboot\nuiT", {caseFold: true}, 0, 10, 2, 3); 61 }); 62 63 test("multilineInsensitiveSlow", function() { 64 var text = "" 65 for (var i = 0; i < 1000; i++) text += "foo\nbar\n" 66 var doc = new CodeMirror.Doc("find\nme\n" + text + "find\nme\n") 67 var t0 = +new Date 68 run(doc, /find\nme/, {multiline: true}, 0, 0, 1, 2, 2002, 0, 2003, 2) 69 is(+new Date - t0 < 100) 70 }) 71 72 test("expandingCaseFold", function() { 73 var doc = new CodeMirror.Doc("<b>İİ İİ</b>\n<b>uu uu</b>") 74 run(doc, "</b>", true, 0, 8, 0, 12, 1, 8, 1, 12); 75 run(doc, "İİ", true, 0, 3, 0, 5, 0, 6, 0, 8); 76 }); 77 78 test("normalize", function() { 79 if (!String.prototype.normalize) return 80 var doc = new CodeMirror.Doc("yılbaşı\n수 있을까\nLe taux d'humidité à London") 81 run(doc, "s", false, 0, 5, 0, 6) 82 run(doc, "이", false, 1, 2, 1, 3) 83 run(doc, "a", false, 0, 4, 0, 5, 2, 4, 2, 5, 2, 19, 2, 20) 84 }) 85 })();
Downloadmodules/editor/codemirror/test/search_test.min.js
History Tue, 22 May 2018 22:39:53 +0200 Jan Dankert Fix für PHP 7.2: 'Object' darf nun nicht mehr als Klassennamen verwendet werden. AUCH NICHT IN EINEM NAMESPACE! WTF, wozu habe ich das in einen verfickten Namespace gepackt? Wozu soll der sonst da sein??? Amateure. Daher nun notgedrungen unbenannt in 'BaseObject'.