MCPcopy Index your code
hub / github.com/github/gh-aw / TestRemoveJavaScriptComments

Function TestRemoveJavaScriptComments

pkg/workflow/js_comments_test.go:11–393  ·  view source on GitHub ↗

TestRemoveJavaScriptComments tests the removeJavaScriptComments function extensively

(t *testing.T)

Source from the content-addressed store, hash-verified

9
10// TestRemoveJavaScriptComments tests the removeJavaScriptComments function extensively
11func TestRemoveJavaScriptComments(t *testing.T) {
12 tests := []struct {
13 name string
14 input string
15 expected string
16 }{
17 // Basic cases
18 {
19 name: "empty string",
20 input: "",
21 expected: "",
22 },
23 {
24 name: "no comments",
25 input: "const x = 1;",
26 expected: "const x = 1;",
27 },
28 {
29 name: "single line comment only",
30 input: "// comment",
31 expected: "",
32 },
33 {
34 name: "multiple single line comments",
35 input: "// comment 1\n// comment 2\n// comment 3",
36 expected: "\n\n",
37 },
38 {
39 name: "code with trailing comment",
40 input: "const x = 1; // comment",
41 expected: "const x = 1; ",
42 },
43 {
44 name: "code with leading comment",
45 input: "// comment\nconst x = 1;",
46 expected: "\nconst x = 1;",
47 },
48
49 // Block comments
50 {
51 name: "simple block comment",
52 input: "/* comment */",
53 expected: "",
54 },
55 {
56 name: "multiline block comment",
57 input: "/* line 1\n line 2\n line 3 */",
58 expected: "\n\n", // Block comments preserve line structure
59 },
60 {
61 name: "code before and after block comment",
62 input: "const x = 1; /* comment */ const y = 2;",
63 expected: "const x = 1; const y = 2;",
64 },
65 {
66 name: "nested block comment markers",
67 input: "/* outer /* inner */ still in comment */const x = 1;",
68 expected: " still in comment */const x = 1;", // Block comments don't nest in JavaScript

Callers

nothing calls this directly

Calls 3

removeJavaScriptCommentsFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected