File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
assembler/src/asmlib/driver Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -937,3 +937,37 @@ fn test_minus_hash_config_evaluation() {
937937
938938 assert_eq ! ( & program_a, & program_b) ;
939939}
940+
941+ #[ test]
942+ fn test_diagnose_duplicate_tags_in_macro_body ( ) {
943+ let input = concat ! (
944+ "☛☛DEF MYMACRO≡\n " ,
945+ // First tag assignment
946+ " T-> 2\n " ,
947+ // Second tag assignment (which is not allowed for the
948+ // same tag name, even inside a macro body).
949+ " T-> 3\n " ,
950+ "☛☛EMD" ,
951+ "\n " ,
952+ // Expand the macro just once.
953+ "MYMACRO≡\n " ,
954+ ) ;
955+ let mut errors = Default :: default ( ) ;
956+ let expected_msg = "T is defined more than once" ;
957+ match dbg ! ( assemble_pass1( input, & mut errors) ) {
958+ Ok ( ( _source_file, _options) ) => {
959+ dbg ! ( & errors) ;
960+ assert ! ( !errors. is_empty( ) ) ;
961+ assert ! ( errors. iter( ) . any( |e| e. to_string( ) . contains( expected_msg) ) ) ;
962+ }
963+ Err ( e) => {
964+ dbg ! ( & errors) ;
965+ dbg ! ( & e) ;
966+ // Although the current implementation successfully parses
967+ // the program but returns an error in `errors`, we also
968+ // accept a hypothetical implementation in which
969+ // assemble_pass1() returns Err.
970+ assert ! ( e. to_string( ) . contains( expected_msg) ) ;
971+ }
972+ }
973+ }
You can’t perform that action at this time.
0 commit comments