@@ -658,15 +658,25 @@ fn test_array_sort_expression_key_avoids_sanitized_name_collisions() {
658658 assert res.output.trim_space ().replace ('\r\n ' , '\n ' ) == 'nested-ok\n flat-ok'
659659}
660660
661- // generated_c_symbol_with_prefix extracts one generated C symbol from compiler output.
662- fn generated_c_symbol_with_prefix (output string , prefix string ) string {
663- idx := output.index (prefix) or { return '' }
664- rest := output[idx..]
665- mut end := 0
666- for end < rest.len && (rest[end].is_letter () || rest[end].is_digit () || rest[end] == `_` ) {
667- end++
661+ // generated_c_symbols_with_prefix extracts generated C symbols from compiler output.
662+ fn generated_c_symbols_with_prefix (output string , prefix string ) []string {
663+ mut symbols := []string {}
664+ mut start := 0
665+ for start < output.len {
666+ idx := output[start..].index (prefix) or { break }
667+ rest := output[start + idx..]
668+ mut end := 0
669+ for end < rest.len && (rest[end].is_letter () || rest[end].is_digit () || rest[end] == `_` ) {
670+ end++
671+ }
672+ symbol := rest[..end]
673+ if symbol ! in symbols {
674+ symbols << symbol
675+ }
676+ start + = idx + end
668677 }
669- return rest[..end]
678+ symbols.sort ()
679+ return symbols
670680}
671681
672682fn test_auxiliary_c_symbols_use_stable_type_hashes () {
@@ -711,14 +721,14 @@ fn test_auxiliary_c_symbols_use_stable_type_hashes() {
711721 compilation_b := os.execute (cmd_b)
712722 ensure_compilation_succeeded (compilation_a, cmd_a)
713723 ensure_compilation_succeeded (compilation_b, cmd_b)
714- compare_a := generated_c_symbol_with_prefix (compilation_a.output, 'compare_' )
715- compare_b := generated_c_symbol_with_prefix (compilation_b.output, 'compare_' )
716- keepalive_a := generated_c_symbol_with_prefix (compilation_a.output,
724+ compare_a := generated_c_symbols_with_prefix (compilation_a.output, 'compare_' )
725+ compare_b := generated_c_symbols_with_prefix (compilation_b.output, 'compare_' )
726+ keepalive_a := generated_c_symbols_with_prefix (compilation_a.output,
717727 '__v_boehm_collect_keepalive_' )
718- keepalive_b := generated_c_symbol_with_prefix (compilation_b.output,
728+ keepalive_b := generated_c_symbols_with_prefix (compilation_b.output,
719729 '__v_boehm_collect_keepalive_' )
720- assert compare_a != ''
721- assert keepalive_a != ''
730+ assert compare_a.len > 0
731+ assert keepalive_a.len > 0
722732 assert compare_a == compare_b
723733 assert keepalive_a == keepalive_b
724734}
0 commit comments