Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 namespace = "comment_";
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 }
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) {
48 cm.setCursor(1);
49 cm.execCommand("toggleComment");
50 }, "a;\n\nb;", "a;\n// \nb;");
52 test("dontMessWithStrings", "javascript", function(cm) {
53 cm.execCommand("toggleComment");
54 }, "console.log(\"/*string*/\");", "// console.log(\"/*string*/\");");
56 test("dontMessWithStrings2", "javascript", function(cm) {
57 cm.execCommand("toggleComment");
58 }, "console.log(\"// string\");", "// console.log(\"// string\");");
60 test("dontMessWithStrings3", "javascript", function(cm) {
61 cm.execCommand("toggleComment");
62 }, "// console.log(\"// string\");", "console.log(\"// string\");");
63 })();