TestRemoveJavaScriptCommentsFromLine tests line-level comment removal
(t *testing.T)
| 394 | |
| 395 | // TestRemoveJavaScriptCommentsFromLine tests line-level comment removal |
| 396 | func TestRemoveJavaScriptCommentsFromLine(t *testing.T) { |
| 397 | tests := []struct { |
| 398 | name string |
| 399 | line string |
| 400 | inBlockComment bool |
| 401 | expected string |
| 402 | expectBlock bool |
| 403 | }{ |
| 404 | { |
| 405 | name: "simple line no comment", |
| 406 | line: "const x = 1;", |
| 407 | inBlockComment: false, |
| 408 | expected: "const x = 1;", |
| 409 | expectBlock: false, |
| 410 | }, |
| 411 | { |
| 412 | name: "line with trailing comment", |
| 413 | line: "const x = 1; // comment", |
| 414 | inBlockComment: false, |
| 415 | expected: "const x = 1; ", |
| 416 | expectBlock: false, |
| 417 | }, |
| 418 | { |
| 419 | name: "line starting in block comment", |
| 420 | line: "still in block */ after block", |
| 421 | inBlockComment: true, |
| 422 | expected: " after block", |
| 423 | expectBlock: false, |
| 424 | }, |
| 425 | { |
| 426 | name: "line starting block comment", |
| 427 | line: "before /* start block", |
| 428 | inBlockComment: false, |
| 429 | expected: "before ", |
| 430 | expectBlock: true, |
| 431 | }, |
| 432 | { |
| 433 | name: "line with complete block comment", |
| 434 | line: "before /* block */ after", |
| 435 | inBlockComment: false, |
| 436 | expected: "before after", |
| 437 | expectBlock: false, |
| 438 | }, |
| 439 | { |
| 440 | name: "entire line is comment", |
| 441 | line: "// entire line", |
| 442 | inBlockComment: false, |
| 443 | expected: "", |
| 444 | expectBlock: false, |
| 445 | }, |
| 446 | { |
| 447 | name: "line in middle of block comment", |
| 448 | line: "this is inside block comment", |
| 449 | inBlockComment: true, |
| 450 | expected: "", |
| 451 | expectBlock: true, |
| 452 | }, |
| 453 | { |
nothing calls this directly
no test coverage detected