@@ -4,6 +4,7 @@ use std::{
44 hash:: Hash ,
55} ;
66
7+ use arcstr:: ArcStr ;
78use clap:: ValueEnum ;
89use enum_map:: Enum ;
910use enumset:: EnumSetType ;
@@ -31,7 +32,9 @@ use whippit::{
3132 } ,
3233} ;
3334
34- use crate :: wpt:: metadata:: properties:: { ExpandedPropertyValue , Expected , NormalizedPropertyValue } ;
35+ use crate :: wpt:: metadata:: properties:: {
36+ DisabledString , ExpandedPropertyValue , Expected , NormalizedPropertyValue ,
37+ } ;
3538
3639#[ cfg( test) ]
3740use insta:: assert_debug_snapshot;
@@ -63,7 +66,7 @@ impl<'a> metadata::File<'a> for File {
6366
6467#[ derive( Clone , Debug , Default , Serialize ) ]
6568pub struct FileProps {
66- pub is_disabled : Option < PropertyValue < Expr < Value < ' static > > , String > > ,
69+ pub disabled : Option < PropertyValue < Expr < Value < ' static > > , DisabledString > > ,
6770 #[ allow( clippy:: type_complexity) ]
6871 pub prefs : Option < PropertyValue < Expr < Value < ' static > > , Vec < ( String , String ) > > > ,
6972 pub tags : Option < PropertyValue < Expr < Value < ' static > > , Vec < String > > > ,
@@ -139,11 +142,11 @@ impl<'a> Properties<'a> for FileProps {
139142 any ( )
140143 . and_is ( newline ( ) . or ( end ( ) ) . not ( ) )
141144 . repeated ( )
142- . at_least ( 1 )
143145 . to_slice ( )
144- . map ( |s : & str | s. to_owned ( ) ) ,
146+ . map ( ArcStr :: from)
147+ . map ( DisabledString :: new) ,
145148 )
146- . map ( |( ( ) , is_disabled ) | FileProp :: Disabled ( is_disabled ) ) ;
149+ . map ( |( ( ) , val ) | FileProp :: Disabled ( val ) ) ;
147150
148151 let implementation_status = helper
149152 . parser (
@@ -164,7 +167,7 @@ impl<'a> Properties<'a> for FileProps {
164167 let ( span, prop) = prop;
165168 let Self {
166169 implementation_status,
167- is_disabled ,
170+ disabled ,
168171 prefs,
169172 tags,
170173 } = self ;
@@ -190,7 +193,7 @@ impl<'a> Properties<'a> for FileProps {
190193 FileProp :: Prefs ( new_prefs) => check_dupe_then_insert ! ( new_prefs, prefs, "prefs" ) ,
191194 FileProp :: Tags ( new_tags) => check_dupe_then_insert ! ( new_tags, tags, "tags" ) ,
192195 FileProp :: Disabled ( new_is_disabled) => {
193- check_dupe_then_insert ! ( new_is_disabled, is_disabled , DISABLED_IDENT )
196+ check_dupe_then_insert ! ( new_is_disabled, disabled , DISABLED_IDENT )
194197 }
195198 }
196199 }
@@ -453,7 +456,7 @@ const DISABLED_IDENT: &str = "disabled";
453456pub enum FileProp {
454457 Prefs ( PropertyValue < Expr < Value < ' static > > , Vec < ( String , String ) > > ) ,
455458 Tags ( PropertyValue < Expr < Value < ' static > > , Vec < String > > ) ,
456- Disabled ( PropertyValue < Expr < Value < ' static > > , String > ) ,
459+ Disabled ( PropertyValue < Expr < Value < ' static > > , DisabledString > ) ,
457460 ImplementationStatus ( PropertyValue < Expr < Value < ' static > > , ImplementationStatus > ) ,
458461}
459462
@@ -521,7 +524,7 @@ fn format_file_properties(props: &FileProps) -> impl Display + '_ {
521524 lazy_format ! ( |f| {
522525 let FileProps {
523526 implementation_status,
524- is_disabled ,
527+ disabled ,
525528 prefs,
526529 tags,
527530 } = props;
@@ -559,8 +562,8 @@ fn format_file_properties(props: &FileProps) -> impl Display + '_ {
559562 ) ?;
560563 }
561564
562- if let Some ( is_disabled ) = is_disabled {
563- write_prop_val( DISABLED_IDENT , is_disabled , Display :: fmt, f) ?;
565+ if let Some ( disabled ) = disabled {
566+ write_prop_val( DISABLED_IDENT , disabled , Display :: fmt, f) ?;
564567 }
565568
566569 Ok ( ( ) )
@@ -749,15 +752,11 @@ where
749752 . join_with( " " )
750753 ) ) ;
751754 let TestProps {
752- is_disabled ,
755+ disabled ,
753756 expected,
754757 implementation_status,
755758 } = property;
756759
757- if * is_disabled {
758- writeln!( f, "{indent}disabled: true" ) ?;
759- }
760-
761760 fn write_normalized<T >(
762761 f: & mut Formatter <' _>,
763762 indent: & dyn Display ,
@@ -841,6 +840,10 @@ where
841840 ) ?;
842841 }
843842
843+ if let Some ( disabled) = disabled {
844+ write_normalized( f, & indent, "disabled" , disabled) ?;
845+ }
846+
844847 if let Some ( exps) = expected {
845848 write_normalized( f, & indent, EXPECTED_IDENT , exps) ?;
846849 }
@@ -867,7 +870,7 @@ pub struct TestProps<Out>
867870where
868871 Out : EnumSetType ,
869872{
870- pub is_disabled : bool ,
873+ pub disabled : Option < ExpandedPropertyValue < DisabledString > > ,
871874 pub expected : Option < ExpandedPropertyValue < Expected < Out > > > ,
872875 pub implementation_status : Option < ExpandedPropertyValue < ImplementationStatus > > ,
873876}
@@ -878,7 +881,7 @@ where
878881{
879882 fn insert ( & mut self , prop : TestProp < Out > , emitter : & mut Emitter < Rich < ' a , char > > ) {
880883 let Self {
881- is_disabled ,
884+ disabled ,
882885 expected,
883886 implementation_status,
884887 } = self ;
@@ -946,11 +949,8 @@ where
946949 TestPropKind :: Expected ( val) => {
947950 conditional ( emitter, span, EXPECTED_IDENT , expected, val)
948951 }
949- TestPropKind :: Disabled => {
950- if * is_disabled {
951- emitter. emit ( Rich :: custom ( span, "duplicate `disabled` key detected" ) )
952- }
953- * is_disabled = true ;
952+ TestPropKind :: Disabled ( val) => {
953+ conditional ( emitter, span, DISABLED_IDENT , disabled, val)
954954 }
955955 TestPropKind :: ImplementationStatus ( val) => conditional (
956956 emitter,
@@ -984,7 +984,7 @@ where
984984 Out : EnumSetType ,
985985{
986986 Expected ( PropertyValue < Applicability , Expected < Out > > ) ,
987- Disabled ,
987+ Disabled ( PropertyValue < Applicability , DisabledString > ) ,
988988 ImplementationStatus ( PropertyValue < Applicability , ImplementationStatus > ) ,
989989}
990990
@@ -1143,22 +1143,16 @@ where
11431143 . parser (
11441144 just ( DISABLED_IDENT ) . to ( ( ) ) ,
11451145 conditional_term. clone ( ) ,
1146- just ( "true" ) . to ( ( ) ) ,
1146+ any ( )
1147+ . and_is ( newline ( ) . not ( ) )
1148+ . repeated ( )
1149+ . to_slice ( )
1150+ . map ( ArcStr :: from)
1151+ . map ( DisabledString :: new) ,
11471152 )
1148- . validate ( |( ( ) , val) , e, emitter| {
1149- match val {
1150- PropertyValue :: Unconditional ( ( ) ) => ( ) ,
1151- PropertyValue :: Conditional { .. } => {
1152- emitter. emit ( Rich :: custom (
1153- e. span ( ) ,
1154- "conditional rules for `disabled` aren't supported yet" ,
1155- ) ) ;
1156- }
1157- }
1158- TestProp {
1159- span : e. span ( ) ,
1160- kind : TestPropKind :: Disabled ,
1161- }
1153+ . map_with ( |( ( ) , val) , e| TestProp {
1154+ span : e. span ( ) ,
1155+ kind : TestPropKind :: Disabled ( val) ,
11621156 } ) ,
11631157 helper
11641158 . parser (
0 commit comments