@@ -22,7 +22,6 @@ pub enum SyntaxTestFileResult {
22
22
Success ( usize ) ,
23
23
}
24
24
25
- use std:: collections:: VecDeque ;
26
25
use highlighting:: ScopeSelectors ;
27
26
28
27
#[ derive( Debug ) ]
@@ -35,8 +34,8 @@ struct SyntaxTestAssertionRange {
35
34
scope_selector_text : String ,
36
35
}
37
36
38
- fn get_syntax_test_assertions ( token_start : & str , token_end : Option < & str > , text : & str ) -> VecDeque < SyntaxTestAssertionRange > {
39
- let mut assertions = VecDeque :: new ( ) ;
37
+ fn get_syntax_test_assertions ( token_start : & str , token_end : Option < & str > , text : & str ) -> Vec < SyntaxTestAssertionRange > {
38
+ let mut assertions = Vec :: new ( ) ;
40
39
let mut test_line_offset = 0 ;
41
40
let mut test_line_len = 0 ;
42
41
let mut line_number = 0 ;
@@ -89,10 +88,10 @@ fn get_syntax_test_assertions(token_start: &str, token_end: Option<&str>, text:
89
88
scope_selector_text : assertion. scope_selector_text . clone ( ) ,
90
89
} ;
91
90
assertion. end_char = test_line_len;
92
- assertions. push_back ( assertion) ;
93
- assertions. push_back ( remainder) ;
91
+ assertions. push ( assertion) ;
92
+ assertions. push ( remainder) ;
94
93
} else {
95
- assertions. push_back ( assertion) ;
94
+ assertions. push ( assertion) ;
96
95
}
97
96
98
97
line_has_assertions = true ;
@@ -147,7 +146,7 @@ pub/*(crate)*/ fn process_syntax_test_assertions(syntax: &SyntaxDefinition, text
147
146
results
148
147
}
149
148
150
- let mut assertions = get_syntax_test_assertions ( testtoken_start, testtoken_end, & text) ;
149
+ let assertions = get_syntax_test_assertions ( testtoken_start, testtoken_end, & text) ;
151
150
//println!("{:?}", assertions);
152
151
153
152
// iterate over the lines of the file, testing them
@@ -158,6 +157,7 @@ pub/*(crate)*/ fn process_syntax_test_assertions(syntax: &SyntaxDefinition, text
158
157
let mut scopes_on_line_being_tested = Vec :: new ( ) ;
159
158
let mut line_number = 0 ;
160
159
let mut relevant_assertions = Vec :: new ( ) ;
160
+ let mut assertion_index = 0 ;
161
161
162
162
let mut assertion_failures: usize = 0 ;
163
163
let mut total_assertions: usize = 0 ;
@@ -172,12 +172,13 @@ pub/*(crate)*/ fn process_syntax_test_assertions(syntax: &SyntaxDefinition, text
172
172
let ops = state. parse_line ( & line) ;
173
173
// find all the assertions that relate to the current line
174
174
relevant_assertions. clear ( ) ;
175
- while let Some ( assertion) = assertions. pop_front ( ) {
175
+ while assertion_index < assertions. len ( ) {
176
+ let assertion = & assertions[ assertion_index] ;
176
177
let pos = assertion. test_line_offset + assertion. begin_char ;
177
178
if pos >= offset && pos < eol_offset {
178
179
relevant_assertions. push ( assertion) ;
180
+ assertion_index += 1 ;
179
181
} else {
180
- assertions. push_front ( assertion) ;
181
182
break ;
182
183
}
183
184
}
@@ -245,7 +246,7 @@ pub/*(crate)*/ fn process_syntax_test_assertions(syntax: &SyntaxDefinition, text
245
246
246
247
// no point continuing to parse the file if there are no syntax test assertions left
247
248
// (unless we want to prove that no panics etc. occur while parsing the rest of the file ofc...)
248
- if assertions. is_empty ( ) || ( assertion_failures > 0 && out_opts. failfast ) {
249
+ if assertion_index == assertions. len ( ) || ( assertion_failures > 0 && out_opts. failfast ) {
249
250
// NOTE: the total counts only really show how many assertions were checked when failing fast
250
251
// - they are not accurate total counts
251
252
break ;
0 commit comments