File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
source/fluentasserts/results/source Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ struct SourceResult {
7272 auto result = getScope(fileTokensCache[pathToUse], line);
7373
7474 auto begin = getPreviousIdentifier(fileTokensCache[pathToUse], result.begin);
75+ begin = max(begin, result.begin);
7576 begin = extendToLineStart(fileTokensCache[pathToUse], begin);
7677 auto end = getFunctionEnd(fileTokensCache[pathToUse], begin) + 1 ;
7778
@@ -226,3 +227,28 @@ struct SourceResult {
226227 printer.primary(" \n " );
227228 }
228229}
230+
231+ version (unittest ) {
232+ import fluent.asserts;
233+ import fluentasserts.results.source.tokens;
234+ }
235+
236+ @(" ensureTokensLoaded clamps begin for lambda inside map" )
237+ unittest {
238+ auto source = SourceResult.create(" testdata/values.d" , 108 );
239+ auto toks = source.tokens;
240+ auto output = source.toString();
241+
242+ output.should.not.contain(" auto a = 1" );
243+ output.should.contain(" iota" );
244+ }
245+
246+ @(" ensureTokensLoaded clamps begin for if block" )
247+ unittest {
248+ auto source = SourceResult.create(" testdata/values.d" , 114 );
249+ auto toks = source.tokens;
250+ auto output = source.toString();
251+
252+ output.should.not.contain(" auto a = 1" );
253+ output.should.contain(" if" );
254+ }
Original file line number Diff line number Diff line change @@ -102,3 +102,15 @@ unittest {
102102 });
103103 });
104104}
105+
106+ unittest {
107+ auto a = 1 ;
108+ iota(1 ).map! ((a) { a.should.equal(2 ); return a + 1 ; }).array;
109+ }
110+
111+ unittest {
112+ auto a = 1 ;
113+ if (a == 1 ) {
114+ a.should.equal(2 );
115+ }
116+ }
You can’t perform that action at this time.
0 commit comments