|
1 | | -//! Tests for the deterministic line-editing transforms and the comment |
2 | | -//! token table. Expected values were pinned against IDEA semantics and the |
3 | | -//! review regressions from PR #642. |
| 1 | +//! Tests for the deterministic line-editing transforms. Expected values |
| 2 | +//! were pinned against IDEA semantics and the review regressions from |
| 3 | +//! PR #642. |
4 | 4 |
|
5 | 5 | use serde_json::{json, Value}; |
6 | 6 |
|
7 | | -use super::line_edit::{line_comment_token, line_edit, LineCommentTokenRequest, LineEditRequest}; |
| 7 | +use super::line_edit::{line_edit, LineEditRequest}; |
8 | 8 |
|
9 | 9 | fn edit( |
10 | 10 | operation: &str, |
@@ -500,65 +500,6 @@ fn copy_line_down_behaves_like_duplicate() { |
500 | 500 | assert_eq!(outcome["selectionStart"], json!(5)); |
501 | 501 | } |
502 | 502 |
|
503 | | -// MARK: Comment token table |
504 | | - |
505 | | -#[test] |
506 | | -fn line_comment_token_maps_common_extensions_and_language_ids() { |
507 | | - for (extension, expected) in [ |
508 | | - ("swift", "//"), |
509 | | - ("Swift", "//"), |
510 | | - ("ts", "//"), |
511 | | - ("csharp", "//"), |
512 | | - ("zig", "//"), |
513 | | - ("rust", "//"), |
514 | | - ("javascript", "//"), |
515 | | - ("javascriptreact", "//"), |
516 | | - ("typescript", "//"), |
517 | | - ("typescriptreact", "//"), |
518 | | - ("kotlin", "//"), |
519 | | - ("py", "#"), |
520 | | - ("python", "#"), |
521 | | - ("ruby", "#"), |
522 | | - ("yaml", "#"), |
523 | | - ("properties", "#"), |
524 | | - ("shell", "#"), |
525 | | - ("dotenv", "#"), |
526 | | - ("sql", "--"), |
527 | | - ("lua", "--"), |
528 | | - ] { |
529 | | - let token = line_comment_token(LineCommentTokenRequest { |
530 | | - identifier: extension.to_string(), |
531 | | - }); |
532 | | - assert_eq!( |
533 | | - token.token.as_deref(), |
534 | | - Some(expected), |
535 | | - "extension {extension}" |
536 | | - ); |
537 | | - } |
538 | | -} |
539 | | - |
540 | | -#[test] |
541 | | -fn line_comment_token_returns_none_for_unknown_extension() { |
542 | | - for extension in ["json", ""] { |
543 | | - let token = line_comment_token(LineCommentTokenRequest { |
544 | | - identifier: extension.to_string(), |
545 | | - }); |
546 | | - assert_eq!(token.token, None, "extension {extension}"); |
547 | | - } |
548 | | -} |
549 | | - |
550 | | -#[test] |
551 | | -fn line_comment_token_resolves_dotfile_basenames() { |
552 | | - // Regression: macOS pathExtension is empty for dotfiles such as .env, |
553 | | - // so callers pass the basename and Core resolves the last dot segment. |
554 | | - for (name, expected) in [(".env", Some("#")), ("Foo.py", Some("#")), ("README", None)] { |
555 | | - let token = line_comment_token(LineCommentTokenRequest { |
556 | | - identifier: name.to_string(), |
557 | | - }); |
558 | | - assert_eq!(token.token.as_deref(), expected, "file name {name}"); |
559 | | - } |
560 | | -} |
561 | | - |
562 | 503 | #[test] |
563 | 504 | fn move_down_maps_crlf_separator_caret_to_valid_selection() { |
564 | 505 | // Regression: a caret between \r and \n once mapped to an offset |
@@ -655,21 +596,12 @@ fn shared_fixture_cases_match_core_outcomes() { |
655 | 596 | .expect("line edit fixture should be valid JSON"); |
656 | 597 | for case_value in fixture["cases"].as_array().expect("cases") { |
657 | 598 | let name = case_value["name"].as_str().expect("case name"); |
658 | | - // The fixture covers both editor commands; dispatch on the request |
659 | | - // shape so one file pins the whole editor contract. |
660 | | - let outcome = if case_value["request"].get("operation").is_some() { |
661 | | - let request: LineEditRequest = serde_json::from_value(case_value["request"].clone()) |
662 | | - .unwrap_or_else(|error| panic!("{name}: {error:?}")); |
663 | | - serde_json::to_value( |
664 | | - line_edit(request).unwrap_or_else(|error| panic!("{name}: {error:?}")), |
665 | | - ) |
666 | | - .expect("outcome should serialize") |
667 | | - } else { |
668 | | - let request: LineCommentTokenRequest = |
669 | | - serde_json::from_value(case_value["request"].clone()) |
670 | | - .unwrap_or_else(|error| panic!("{name}: {error:?}")); |
671 | | - serde_json::to_value(line_comment_token(request)).expect("token should serialize") |
672 | | - }; |
| 599 | + let request: LineEditRequest = serde_json::from_value(case_value["request"].clone()) |
| 600 | + .unwrap_or_else(|error| panic!("{name}: {error:?}")); |
| 601 | + let outcome = serde_json::to_value( |
| 602 | + line_edit(request).unwrap_or_else(|error| panic!("{name}: {error:?}")), |
| 603 | + ) |
| 604 | + .expect("outcome should serialize"); |
673 | 605 | assert_eq!(outcome, case_value["expected"], "case {name}"); |
674 | 606 | } |
675 | 607 | } |
0 commit comments