Skip to content

Commit 9d61a35

Browse files
srawlinsCommit Queue
authored and
Commit Queue
committed
DAS: add some tests for digit separators in DocumentColor feature
Work towards #56188 Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try Change-Id: Id3d56ad5870208e15e89ad014a668a1e659b7d75 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380621 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 570ed43 commit 9d61a35

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

pkg/analysis_server/test/lsp/document_color_test.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,24 @@ const white = [!Color(0xFFFFFFFF)!];
176176
);
177177
}
178178

179+
/// If a color is in a const context, we should not insert 'const'.
180+
Future<void> test_colorConstructor_constContext_withSeparators() async {
181+
content = '''
182+
import 'package:flutter/material.dart';
183+
184+
const white = [!Color(0xFF_FF_FF_FF)!];
185+
''';
186+
187+
await _checkPresentations(
188+
select: Color(alpha: 1, red: 1, green: 0, blue: 0),
189+
expectPresentations: [
190+
_color('Color.fromARGB(255, 255, 0, 0)'),
191+
_color('Color.fromRGBO(255, 0, 0, 1)'),
192+
_color('Color(0xFFFF0000)'),
193+
],
194+
);
195+
}
196+
179197
/// If a color already has 'const' ahead of it, we should include it in the
180198
/// replacement also.
181199
Future<void> test_colorConstructor_constKeyword() async {
@@ -212,6 +230,23 @@ var white = [!Color(0xFFFFFFFF)!];
212230
);
213231
}
214232

233+
Future<void> test_colorConstructor_nonConst_withSeparators() async {
234+
content = '''
235+
import 'package:flutter/material.dart';
236+
237+
var white = [!Color(0xFF_FF_FF_FF)!];
238+
''';
239+
240+
await _checkPresentations(
241+
select: Color(alpha: 1, red: 1, green: 0, blue: 0),
242+
expectPresentations: [
243+
_color('Color.fromARGB(255, 255, 0, 0)'),
244+
_color('Color.fromRGBO(255, 0, 0, 1)'),
245+
_color('Color(0xFFFF0000)'),
246+
],
247+
);
248+
}
249+
215250
Future<void> test_includesImportEdit() async {
216251
failTestOnErrorDiagnostic = false; // Tests with missing import.
217252

0 commit comments

Comments
 (0)