@@ -113,9 +113,16 @@ pub fn validate(file_name: &str) {
113113 let mod_type = determine_mod_type ( base_name, & content) ;
114114
115115 let reports = match mod_type {
116- ModTypeOrReport :: Type ( ModuleType :: Assembly ) => assembly:: check ( base_name, & content) ,
117- ModTypeOrReport :: Report ( report) => vec ! [ report] ,
118- _ => module:: check ( base_name, & content) ,
116+ // If the file is an assembly, test the assembly requirements
117+ ModTypeOrReport :: Type ( ModuleType :: Assembly ) => assembly:: check ( & content) ,
118+ // If the module type is indeterminate, test the requirements that don't depend on the type
119+ ModTypeOrReport :: Report ( type_report) => {
120+ let mut reports = check_common ( & content) ;
121+ reports. push ( type_report) ;
122+ reports
123+ }
124+ // In the remaining cases, the file is a module, so test module requirements
125+ _ => module:: check ( & content) ,
119126 } ;
120127
121128 report_issues ( reports, file_name) ;
@@ -202,7 +209,7 @@ mod title {
202209 ] ;
203210
204211 /// This function collects all tests that target both assembly and module files
205- pub fn check ( _base_name : & str , content : & str ) -> Vec < IssueReport > {
212+ pub fn check ( content : & str ) -> Vec < IssueReport > {
206213 let mut reports = Vec :: new ( ) ;
207214
208215 reports. append ( perform_simple_tests ( content, & SIMPLE_TITLE_TESTS ) . as_mut ( ) ) ;
@@ -307,7 +314,7 @@ mod content {
307314 ] ;
308315
309316 /// This function collects all tests that target both assembly and module files
310- pub fn check ( _base_name : & str , content : & str ) -> Vec < IssueReport > {
317+ pub fn check ( content : & str ) -> Vec < IssueReport > {
311318 let mut reports = Vec :: new ( ) ;
312319
313320 reports. append ( perform_simple_tests ( content, & SIMPLE_CONTENT_TESTS ) . as_mut ( ) ) ;
@@ -393,9 +400,21 @@ mod content {
393400 }
394401}
395402
403+ /// This function collects all tests required regardless of the module or assembly type
404+ fn check_common ( content : & str ) -> Vec < IssueReport > {
405+ let mut reports = Vec :: new ( ) ;
406+
407+ reports. append ( title:: check ( content) . as_mut ( ) ) ;
408+ reports. append ( content:: check ( content) . as_mut ( ) ) ;
409+ reports. append ( additional_resources:: check ( content) . as_mut ( ) ) ;
410+
411+ reports
412+ }
413+
396414// This section groups all module requirements;
397415// they depend on title and content, and additional resources requirements
398416mod module {
417+ use crate :: validation:: check_common;
399418 use crate :: validation:: find_first_occurrence;
400419 use crate :: validation:: find_mod_id;
401420 use crate :: validation:: perform_simple_tests;
@@ -421,13 +440,10 @@ mod module {
421440 ] ;
422441
423442 /// This function collects all tests required in module files
424- pub fn check ( base_name : & str , content : & str ) -> Vec < IssueReport > {
443+ pub fn check ( content : & str ) -> Vec < IssueReport > {
425444 let mut reports = Vec :: new ( ) ;
426445
427- reports. append ( crate :: validation:: title:: check ( base_name, content) . as_mut ( ) ) ;
428- reports. append ( crate :: validation:: content:: check ( base_name, content) . as_mut ( ) ) ;
429- reports. append ( crate :: validation:: additional_resources:: check ( content) . as_mut ( ) ) ;
430-
446+ reports. append ( check_common ( content) . as_mut ( ) ) ;
431447 reports. append ( perform_simple_tests ( content, & SIMPLE_MODULE_TESTS ) . as_mut ( ) ) ;
432448 reports. append ( check_metadata_variable ( content) . as_mut ( ) ) ;
433449 reports. append ( check_include_except_snip ( content) . as_mut ( ) ) ;
@@ -512,6 +528,7 @@ mod module {
512528// This section groups all assembly requirements;
513529// they depend on title and content, and additional resources requirements
514530mod assembly {
531+ use crate :: validation:: check_common;
515532 use crate :: validation:: perform_simple_tests;
516533 use crate :: validation:: IssueDefinition ;
517534 use crate :: validation:: IssueReport ;
@@ -543,15 +560,12 @@ mod assembly {
543560 ] ;
544561
545562 /// This function collects all tests required in assembly files
546- pub fn check ( base_name : & str , content : & str ) -> Vec < IssueReport > {
563+ pub fn check ( content : & str ) -> Vec < IssueReport > {
547564 // check_no_nesting(base_name, content);
548565 // check_supported_leveloffset(base_name, content);
549566 let mut reports = Vec :: new ( ) ;
550567
551- reports. append ( crate :: validation:: title:: check ( base_name, content) . as_mut ( ) ) ;
552- reports. append ( crate :: validation:: content:: check ( base_name, content) . as_mut ( ) ) ;
553- reports. append ( crate :: validation:: additional_resources:: check ( content) . as_mut ( ) ) ;
554-
568+ reports. append ( check_common ( content) . as_mut ( ) ) ;
555569 reports. append ( perform_simple_tests ( content, & SIMPLE_ASSEMBLY_TESTS ) . as_mut ( ) ) ;
556570 reports. append ( check_headings_in_assembly ( content) . as_mut ( ) ) ;
557571
0 commit comments