File modules/editor/codemirror/test/comment_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 namespace = "comment_"; 2 3 (function() { 4 function test(name, mode, run, before, after) { 5 return testCM(name, function(cm) { 6 run(cm); 7 eq(cm.getValue(), after); 8 }, {value: before, mode: mode}); 9 } 10 11 var simpleProg = "function foo() {\n return bar;\n}"; 12 var inlineBlock = "foo(/* bar */ true);"; 13 var inlineBlocks = "foo(/* bar */ true, /* baz */ false);"; 14 var multiLineInlineBlock = ["above();", "foo(/* bar */ true);", "below();"]; 15 16 test("block", "javascript", function(cm) { 17 cm.blockComment(Pos(0, 3), Pos(3, 0), {blockCommentLead: " *"}); 18 }, simpleProg + "\n", "/* function foo() {\n * return bar;\n * }\n */"); 19 20 test("blockToggle", "javascript", function(cm) { 21 cm.blockComment(Pos(0, 3), Pos(2, 0), {blockCommentLead: " *"}); 22 cm.uncomment(Pos(0, 3), Pos(2, 0), {blockCommentLead: " *"}); 23 }, simpleProg, simpleProg); 24 25 test("blockToggle2", "javascript", function(cm) { 26 cm.setCursor({line: 0, ch: 7 /* inside the block comment */}); 27 cm.execCommand("toggleComment"); 28 }, inlineBlock, "foo(bar true);"); 29 30 // This test should work but currently fails. 31 // test("blockToggle3", "javascript", function(cm) { 32 // cm.setCursor({line: 0, ch: 7 /* inside the first block comment */}); 33 // cm.execCommand("toggleComment"); 34 // }, inlineBlocks, "foo(bar true, /* baz */ false);"); 35 36 test("line", "javascript", function(cm) { 37 cm.lineComment(Pos(1, 1), Pos(1, 1)); 38 }, simpleProg, "function foo() {\n// return bar;\n}"); 39 40 test("lineToggle", "javascript", function(cm) { 41 cm.lineComment(Pos(0, 0), Pos(2, 1)); 42 cm.uncomment(Pos(0, 0), Pos(2, 1)); 43 }, simpleProg, simpleProg); 44 45 test("fallbackToBlock", "css", function(cm) { 46 cm.lineComment(Pos(0, 0), Pos(2, 1)); 47 }, "html {\n border: none;\n}", "/* html {\n border: none;\n} */"); 48 49 test("fallbackToLine", "ruby", function(cm) { 50 cm.blockComment(Pos(0, 0), Pos(1)); 51 }, "def blah()\n return hah\n", "# def blah()\n# return hah\n"); 52 53 test("ignoreExternalBlockComments", "javascript", function(cm) { 54 cm.execCommand("toggleComment"); 55 }, inlineBlocks, "// " + inlineBlocks); 56 57 test("ignoreExternalBlockComments2", "javascript", function(cm) { 58 cm.setCursor({line: 0, ch: null /* eol */}); 59 cm.execCommand("toggleComment"); 60 }, inlineBlocks, "// " + inlineBlocks); 61 62 test("ignoreExternalBlockCommentsMultiLineAbove", "javascript", function(cm) { 63 cm.setSelection({line: 0, ch: 0}, {line: 1, ch: 1}); 64 cm.execCommand("toggleComment"); 65 }, multiLineInlineBlock.join("\n"), ["// " + multiLineInlineBlock[0], 66 "// " + multiLineInlineBlock[1], 67 multiLineInlineBlock[2]].join("\n")); 68 69 test("ignoreExternalBlockCommentsMultiLineBelow", "javascript", function(cm) { 70 cm.setSelection({line: 1, ch: 13 /* after end of block comment */}, {line: 2, ch: 1}); 71 cm.execCommand("toggleComment"); 72 }, multiLineInlineBlock.join("\n"), [multiLineInlineBlock[0], 73 "// " + multiLineInlineBlock[1], 74 "// " + multiLineInlineBlock[2]].join("\n")); 75 76 test("commentRange", "javascript", function(cm) { 77 cm.blockComment(Pos(1, 2), Pos(1, 13), {fullLines: false}); 78 }, simpleProg, "function foo() {\n /*return bar;*/\n}"); 79 80 test("indented", "javascript", function(cm) { 81 cm.lineComment(Pos(1, 0), Pos(2), {indent: true}); 82 }, simpleProg, "function foo() {\n// return bar;\n// }"); 83 84 test("singleEmptyLine", "javascript", function(cm) { 85 cm.setCursor(1); 86 cm.execCommand("toggleComment"); 87 }, "a;\n\nb;", "a;\n// \nb;"); 88 89 test("dontMessWithStrings", "javascript", function(cm) { 90 cm.execCommand("toggleComment"); 91 }, "console.log(\"/*string*/\");", "// console.log(\"/*string*/\");"); 92 93 test("dontMessWithStrings2", "javascript", function(cm) { 94 cm.execCommand("toggleComment"); 95 }, "console.log(\"// string\");", "// console.log(\"// string\");"); 96 97 test("dontMessWithStrings3", "javascript", function(cm) { 98 cm.execCommand("toggleComment"); 99 }, "// console.log(\"// string\");", "console.log(\"// string\");"); 100 101 test("includeLastLine", "javascript", function(cm) { 102 cm.execCommand("selectAll") 103 cm.execCommand("toggleComment") 104 }, "// foo\n// bar\nbaz", "// // foo\n// // bar\n// baz") 105 106 test("uncommentWithTrailingBlockEnd", "xml", function(cm) { 107 cm.execCommand("toggleComment") 108 }, "<!-- foo --> -->", "foo -->") 109 110 test("dontCommentInComment", "xml", function(cm) { 111 cm.setCursor(1, 0) 112 cm.execCommand("toggleComment") 113 }, "<!-- foo\nbar -->", "<!-- foo\nbar -->") 114 })();
Download modules/editor/codemirror/test/comment_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'.