1 namespace = "comment_";
4 function test(name, mode, run, before, after) {
5 return testCM(name, function(cm) {
7 eq(cm.getValue(), after);
8 }, {value: before, mode: mode});
11 var simpleProg = "function foo() {\n return bar;\n}";
13 test("block", "javascript", function(cm) {
14 cm.blockComment(Pos(0, 3), Pos(3, 0), {blockCommentLead: " *"});
15 }, simpleProg + "\n", "/* function foo() {\n * return bar;\n * }\n */");
17 test("blockToggle", "javascript", function(cm) {
18 cm.blockComment(Pos(0, 3), Pos(2, 0), {blockCommentLead: " *"});
19 cm.uncomment(Pos(0, 3), Pos(2, 0), {blockCommentLead: " *"});
20 }, simpleProg, simpleProg);
22 test("line", "javascript", function(cm) {
23 cm.lineComment(Pos(1, 1), Pos(1, 1));
24 }, simpleProg, "function foo() {\n// return bar;\n}");
26 test("lineToggle", "javascript", function(cm) {
27 cm.lineComment(Pos(0, 0), Pos(2, 1));
28 cm.uncomment(Pos(0, 0), Pos(2, 1));
29 }, simpleProg, simpleProg);
31 test("fallbackToBlock", "css", function(cm) {
32 cm.lineComment(Pos(0, 0), Pos(2, 1));
33 }, "html {\n border: none;\n}", "/* html {\n border: none;\n} */");
35 test("fallbackToLine", "ruby", function(cm) {
36 cm.blockComment(Pos(0, 0), Pos(1));
37 }, "def blah()\n return hah\n", "# def blah()\n# return hah\n");
39 test("commentRange", "javascript", function(cm) {
40 cm.blockComment(Pos(1, 2), Pos(1, 13), {fullLines: false});
41 }, simpleProg, "function foo() {\n /*return bar;*/\n}");
43 test("indented", "javascript", function(cm) {
44 cm.lineComment(Pos(1, 0), Pos(2), {indent: true});
45 }, simpleProg, "function foo() {\n // return bar;\n // }");
47 test("singleEmptyLine", "javascript", function(cm) {
49 cm.execCommand("toggleComment");
50 }, "a;\n\nb;", "a;\n// \nb;");