Path: blob/master/web-gui/buildyourownbotnet/assets/js/codemirror/test/comment_test.js
1293 views
namespace = "comment_";12(function() {3function test(name, mode, run, before, after) {4return testCM(name, function(cm) {5run(cm);6eq(cm.getValue(), after);7}, {value: before, mode: mode});8}910var simpleProg = "function foo() {\n return bar;\n}";1112test("block", "javascript", function(cm) {13cm.blockComment(Pos(0, 3), Pos(3, 0), {blockCommentLead: " *"});14}, simpleProg + "\n", "/* function foo() {\n * return bar;\n * }\n */");1516test("blockToggle", "javascript", function(cm) {17cm.blockComment(Pos(0, 3), Pos(2, 0), {blockCommentLead: " *"});18cm.uncomment(Pos(0, 3), Pos(2, 0), {blockCommentLead: " *"});19}, simpleProg, simpleProg);2021test("line", "javascript", function(cm) {22cm.lineComment(Pos(1, 1), Pos(1, 1));23}, simpleProg, "function foo() {\n// return bar;\n}");2425test("lineToggle", "javascript", function(cm) {26cm.lineComment(Pos(0, 0), Pos(2, 1));27cm.uncomment(Pos(0, 0), Pos(2, 1));28}, simpleProg, simpleProg);2930test("fallbackToBlock", "css", function(cm) {31cm.lineComment(Pos(0, 0), Pos(2, 1));32}, "html {\n border: none;\n}", "/* html {\n border: none;\n} */");3334test("fallbackToLine", "ruby", function(cm) {35cm.blockComment(Pos(0, 0), Pos(1));36}, "def blah()\n return hah\n", "# def blah()\n# return hah\n");3738test("commentRange", "javascript", function(cm) {39cm.blockComment(Pos(1, 2), Pos(1, 13), {fullLines: false});40}, simpleProg, "function foo() {\n /*return bar;*/\n}");4142test("indented", "javascript", function(cm) {43cm.lineComment(Pos(1, 0), Pos(2), {indent: true});44}, simpleProg, "function foo() {\n // return bar;\n // }");4546test("singleEmptyLine", "javascript", function(cm) {47cm.setCursor(1);48cm.execCommand("toggleComment");49}, "a;\n\nb;", "a;\n// \nb;");5051test("dontMessWithStrings", "javascript", function(cm) {52cm.execCommand("toggleComment");53}, "console.log(\"/*string*/\");", "// console.log(\"/*string*/\");");5455test("dontMessWithStrings2", "javascript", function(cm) {56cm.execCommand("toggleComment");57}, "console.log(\"// string\");", "// console.log(\"// string\");");5859test("dontMessWithStrings3", "javascript", function(cm) {60cm.execCommand("toggleComment");61}, "// console.log(\"// string\");", "console.log(\"// string\");");62})();636465