fix: support mutable language tab configuration
This commit is contained in:
+27
-2
@@ -1006,7 +1006,8 @@ mod tests {
|
||||
r#"
|
||||
Vamp.configure do |c|
|
||||
c.tab_spaces = 4
|
||||
c.language_tab_spaces = { "ruby" => 2, "makefile" => nil, "json" => 1, "yaml" => 255, "cpp" => 3, "typescriptreact" => 5 }
|
||||
c.language_tab_spaces.merge!("ruby" => 2, "makefile" => nil, "json" => 1, "yaml" => 255, "typescriptreact" => 5)
|
||||
c.language_tab_spaces["cpp"] = 3
|
||||
end
|
||||
"#,
|
||||
);
|
||||
@@ -1069,12 +1070,18 @@ end
|
||||
for assignment in [
|
||||
format!("c.tab_spaces = {value}"),
|
||||
format!(r#"c.language_tab_spaces = {{ "ruby" => {value} }}"#),
|
||||
format!(r#"c.language_tab_spaces.merge!("ruby" => {value})"#),
|
||||
format!(r#"c.language_tab_spaces["ruby"] = {value}"#),
|
||||
] {
|
||||
let config = fixture.file(
|
||||
"config.rb",
|
||||
&format!("Vamp.configure {{ |c| {assignment} }}"),
|
||||
);
|
||||
assert!(load_config(&config).is_err(), "{assignment}");
|
||||
let error = load_config(&config).unwrap_err();
|
||||
assert!(
|
||||
error.contains("tab_spaces must be nil or an Integer"),
|
||||
"{assignment}: {error}"
|
||||
);
|
||||
}
|
||||
}
|
||||
for value in [
|
||||
@@ -1092,6 +1099,24 @@ end
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn language_tab_space_mutations_reject_invalid_keys_before_serialization() {
|
||||
let fixture = Fixture::new();
|
||||
for key in [r#""""#, ":ruby", r#""\n""#, "7"] {
|
||||
for assignment in [
|
||||
format!("c.language_tab_spaces.merge!({key} => 2)"),
|
||||
format!("c.language_tab_spaces[{key}] = 2"),
|
||||
] {
|
||||
let config = fixture.file(
|
||||
"config.rb",
|
||||
&format!("Vamp.configure {{ |c| {assignment} }}"),
|
||||
);
|
||||
let error = load_config(&config).unwrap_err();
|
||||
assert!(error.contains("Tab language"), "{assignment}: {error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn actual_ruby_dsl_context_queued_effects_and_output_isolation() {
|
||||
let fixture = Fixture::new();
|
||||
|
||||
Reference in New Issue
Block a user