Skip to content

Commit cf13a12

Browse files
committed
[review] add test for overriding partially unstable option
1 parent 50c3ff0 commit cf13a12

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/config/mod.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,15 @@ mod test {
406406
#[allow(dead_code)]
407407
mod mock {
408408
use super::super::*;
409+
use rustfmt_config_proc_macro::config_type;
410+
411+
#[config_type]
412+
pub enum PartiallyUnstableOption {
413+
V1,
414+
V2,
415+
#[unstable_variant]
416+
V3,
417+
}
409418

410419
create_config! {
411420
// Options that are used by the generated functions
@@ -449,6 +458,8 @@ mod test {
449458
// Options that are used by the tests
450459
stable_option: bool, false, true, "A stable option";
451460
unstable_option: bool, false, false, "An unstable option";
461+
partially_unstable_option: PartiallyUnstableOption, PartiallyUnstableOption::V1, true,
462+
"A partially unstable option";
452463
}
453464
}
454465

@@ -918,4 +929,42 @@ make_backup = false
918929
assert_eq!(config.single_line_if_else_max_width(), 100);
919930
}
920931
}
932+
933+
#[cfg(test)]
934+
mod partially_unstable_option {
935+
use super::mock::{Config, PartiallyUnstableOption};
936+
use super::*;
937+
938+
#[test]
939+
fn test_override_stable_value() {
940+
let mut config = Config::default();
941+
config.override_value("partially_unstable_option", "V2");
942+
assert_eq!(
943+
config.partially_unstable_option(),
944+
PartiallyUnstableOption::V2
945+
);
946+
}
947+
948+
#[stable_only_test]
949+
#[test]
950+
fn test_override_unstable_value_on_stable() {
951+
let mut config = Config::default();
952+
config.override_value("partially_unstable_option", "V3");
953+
assert_eq!(
954+
config.partially_unstable_option(),
955+
PartiallyUnstableOption::V1
956+
);
957+
}
958+
959+
#[nightly_only_test]
960+
#[test]
961+
fn test_override_unstable_value_on_nightly() {
962+
let mut config = Config::default();
963+
config.override_value("partially_unstable_option", "V3");
964+
assert_eq!(
965+
config.partially_unstable_option(),
966+
PartiallyUnstableOption::V3
967+
);
968+
}
969+
}
921970
}

0 commit comments

Comments
 (0)