Fix the windows bot and update MockSdk

Fixing the test that's causing the Windows bot to fail required updating
the MockSdk, which cause a lot of other changes. I would have done this
in two separate CLs if I'd known how big this was going to get, but I'm
hoping it isn't too big.

Change-Id: Idee56bab5e73a78ab7857e81177090493aa08b40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151874
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Brian Wilkerson 2020-06-22 14:34:25 +00:00 committed by commit-bot@chromium.org
parent 0cc64fcc7d
commit ab73158758
17 changed files with 80 additions and 74 deletions

View file

@ -695,7 +695,7 @@ void main() {
// + Top level variables.
assertSuggestion(
completion: 'PI',
completion: 'pi',
file: '/sdk/lib/math/math.dart',
element: ElementKind.TOP_LEVEL_VARIABLE,
kind: CompletionSuggestionKind.INVOCATION);

View file

@ -811,23 +811,23 @@ main(A a) {
buildTests('testCompletion_combinator_afterComma', '''
import 'dart:math' show cos, !1;''',
<String>['1+PI', '1+sin', '1+Random', '1-String']);
<String>['1+pi', '1+sin', '1+Random', '1-String']);
buildTests('testCompletion_combinator_ended', '''
import 'dart:math' show !1;"''',
<String>['1+PI', '1+sin', '1+Random', '1-String']);
<String>['1+pi', '1+sin', '1+Random', '1-String']);
buildTests('testCompletion_combinator_export', '''
export 'dart:math' show !1;"''',
<String>['1+PI', '1+sin', '1+Random', '1-String']);
<String>['1+pi', '1+sin', '1+Random', '1-String']);
buildTests('testCompletion_combinator_hide', '''
import 'dart:math' hide !1;"''',
<String>['1+PI', '1+sin', '1+Random', '1-String']);
<String>['1+pi', '1+sin', '1+Random', '1-String']);
buildTests('testCompletion_combinator_notEnded', '''
import 'dart:math' show !1"''',
<String>['1+PI', '1+sin', '1+Random', '1-String']);
<String>['1+pi', '1+sin', '1+Random', '1-String']);
buildTests('testCompletion_combinator_usePrefix', '''
import 'dart:math' show s!1"''',
@ -1615,16 +1615,16 @@ main() {
failingTests: '1');
buildTests('test_importPrefix_hideCombinator', '''
import 'dart:math' as math hide PI;
import 'dart:math' as math hide pi;
main() {
math.!1
}''', <String>['1-PI', '1+LN10']);
}''', <String>['1-pi', '1+ln10']);
buildTests('test_importPrefix_showCombinator', '''
import 'dart:math' as math show PI;
import 'dart:math' as math show pi;
main() {
math.!1
}''', <String>['1+PI', '1-LN10']);
}''', <String>['1+pi', '1-ln10']);
sources.clear();
sources['/lib.dart'] = '''

View file

@ -130,7 +130,7 @@ import 'dart:convert';
import 'dart:collection';
main() {
print(PI);
print(pi);
new HashMap();
}
''');
@ -141,7 +141,7 @@ import 'dart:collection';
import 'dart:math';
main() {
print(PI);
print(pi);
new HashMap();
}
''');

View file

@ -992,9 +992,9 @@ main() {
import 'dart:async' as test;
import 'dart:math' as test;
main() {
test.PI;
test.pi;
}
''', 'test.PI;');
''', 'test.pi;');
}
Future test_rename_hasElement_instanceGetter() {

View file

@ -153,10 +153,10 @@ import 'b.dart' show ^;
assertNotSuggested('B');
}
Future<void> test_Combinator_show_PI() async {
Future<void> test_Combinator_show_pi() async {
addTestSource('import "dart:math" show ^;');
await computeSuggestions();
assertSuggestTopLevelVar('PI', 'double',
assertSuggestTopLevelVar('pi', 'double',
kind: CompletionSuggestionKind.IDENTIFIER);
}

View file

@ -140,7 +140,7 @@ import 'dart:convert';
import 'dart:collection';
main() {
print(PI);
print(pi);
new HashMap();
}
''');
@ -152,7 +152,7 @@ import 'dart:collection';
import 'dart:math';
main() {
print(PI);
print(pi);
new HashMap();
}
''', removeUnused: true);

View file

@ -166,12 +166,12 @@ import 'dart:async' as test;
import 'dart:math' as test;
main() {
test.Future f;
test.PI;
test.E;
test.pi;
test.e;
}
''');
// configure refactoring
createRenameRefactoringAtString('test.PI');
createRenameRefactoringAtString('test.pi');
expect(refactoring.refactoringName, 'Rename Import Prefix');
expect(refactoring.oldName, 'test');
refactoring.newName = 'newName';
@ -181,8 +181,8 @@ import 'dart:async' as test;
import 'dart:math' as newName;
main() {
test.Future f;
newName.PI;
newName.E;
newName.pi;
newName.e;
}
''');
}

View file

@ -21,9 +21,9 @@ class ImportAddShowTest extends AssistProcessorTest {
Future<void> test_hasShow() async {
await resolveTestUnit('''
import 'dart:math' show PI;
import 'dart:math' show pi;
main() {
PI;
pi;
}
''');
await assertNoAssistAt('import ');
@ -33,14 +33,14 @@ main() {
await resolveTestUnit('''
import 'dart:math';
main(x) {
PI;
pi;
return x.foo();
}
''');
await assertHasAssistAt('import ', '''
import 'dart:math' show PI;
import 'dart:math' show pi;
main(x) {
PI;
pi;
return x.foo();
}
''');
@ -50,16 +50,16 @@ main(x) {
await resolveTestUnit('''
import 'dart:math';
main() {
PI;
E;
pi;
e;
max(1, 2);
}
''');
await assertHasAssistAt('import ', '''
import 'dart:math' show E, PI, max;
import 'dart:math' show e, max, pi;
main() {
PI;
E;
pi;
e;
max(1, 2);
}
''');
@ -69,16 +69,16 @@ main() {
await resolveTestUnit('''
import 'dart:math';
main() {
PI;
E;
pi;
e;
max(1, 2);
}
''');
await assertHasAssistAt('art:math', '''
import 'dart:math' show E, PI, max;
import 'dart:math' show e, max, pi;
main() {
PI;
E;
pi;
e;
max(1, 2);
}
''');

View file

@ -63,15 +63,15 @@ void f(p.C c) {
await resolveTestUnit('''
import 'dart:math' as pref;
main() {
print(pref.E);
print(PI);
print(pref.e);
print(pi);
}
''');
await assertHasFix('''
import 'dart:math' as pref;
main() {
print(pref.E);
print(pref.PI);
print(pref.e);
print(pref.pi);
}
''');
}

View file

@ -278,28 +278,28 @@ class MyCompleter with Completer<String> {}
Future<void> test_withTopLevelVariable() async {
await resolveTestUnit('''
main() {
print(PI);
print(pi);
}
''');
await assertHasFix('''
import 'dart:math';
main() {
print(PI);
print(pi);
}
''');
}
Future<void> test_withTopLevelVariable_annotation() async {
await resolveTestUnit('''
@PI
@pi
main() {
}
''');
await assertHasFix('''
import 'dart:math';
@PI
@pi
main() {
}
''');

View file

@ -9955,7 +9955,7 @@ class StaticWarningCode extends AnalyzerErrorCode {
// when `part.dart` is a part of a different library:
//
// ```dart
// part [!'part.dart'!];
// part [!'package:a/part.dart'!];
// ```
//
// #### Common fixes

View file

@ -1020,9 +1020,9 @@ final MockSdkLibrary _LIB_MATH = MockSdkLibrary(
'''
library dart.math;
const double E = 2.718281828459045;
const double PI = 3.1415926535897932;
const double LN10 = 2.302585092994046;
const double e = 2.718281828459045;
const double pi = 3.1415926535897932;
const double ln10 = 2.302585092994046;
T min<T extends num>(T a, T b) => throw 0;
T max<T extends num>(T a, T b) => throw 0;

View file

@ -541,10 +541,10 @@ main() {
test_searchReferences_ImportElement_noPrefix() async {
await _resolveTestUnit('''
import 'dart:math' show max, PI, Random hide min;
export 'dart:math' show max, PI, Random hide min;
import 'dart:math' show max, pi, Random hide min;
export 'dart:math' show max, pi, Random hide min;
main() {
print(PI);
print(pi);
print(new Random());
print(max(1, 2));
}
@ -555,7 +555,7 @@ Random bar() => null;
var bar = findElement.function('bar');
var kind = SearchResultKind.REFERENCE;
var expected = [
_expectId(main, kind, 'PI);', length: 0),
_expectId(main, kind, 'pi);', length: 0),
_expectId(main, kind, 'Random()', length: 0),
_expectId(main, kind, 'max(', length: 0),
_expectId(bar, kind, 'Random bar()', length: 0),
@ -566,10 +566,10 @@ Random bar() => null;
test_searchReferences_ImportElement_noPrefix_inPackage() async {
testFile = convertPath('/aaa/lib/a.dart');
await _resolveTestUnit('''
import 'dart:math' show max, PI, Random hide min;
export 'dart:math' show max, PI, Random hide min;
import 'dart:math' show max, pi, Random hide min;
export 'dart:math' show max, pi, Random hide min;
main() {
PI;
pi;
new Random();
max(1, 2);
}
@ -580,7 +580,7 @@ Random bar() => null;
var bar = findElement.function('bar');
var kind = SearchResultKind.REFERENCE;
var expected = [
_expectId(main, kind, 'PI;', length: 0),
_expectId(main, kind, 'pi;', length: 0),
_expectId(main, kind, 'Random();', length: 0),
_expectId(main, kind, 'max(1, 2);', length: 0),
_expectId(bar, kind, 'Random bar()', length: 0),
@ -590,10 +590,10 @@ Random bar() => null;
test_searchReferences_ImportElement_withPrefix() async {
await _resolveTestUnit('''
import 'dart:math' as math show max, PI, Random hide min;
export 'dart:math' show max, PI, Random hide min;
import 'dart:math' as math show max, pi, Random hide min;
export 'dart:math' show max, pi, Random hide min;
main() {
print(math.PI);
print(math.pi);
print(new math.Random());
print(math.max(1, 2));
}
@ -605,7 +605,7 @@ math.Random bar() => null;
var kind = SearchResultKind.REFERENCE;
var length = 'math.'.length;
var expected = [
_expectId(main, kind, 'math.PI);', length: length),
_expectId(main, kind, 'math.pi);', length: length),
_expectId(main, kind, 'math.Random()', length: length),
_expectId(main, kind, 'math.max(', length: length),
_expectId(bar, kind, 'math.Random bar()', length: length),
@ -1728,19 +1728,19 @@ class A {} // A
class B = Object with A;
mixin C {}
typedef D();
e() {}
var f = null;
f() {}
var g = null;
class NoMatchABCDEF {}
''');
var a = findElement.class_('A');
var b = findElement.class_('B');
var c = findElement.mixin('C');
var d = findElement.functionTypeAlias('D');
var e = findElement.function('e');
var f = findElement.topVar('f');
RegExp regExp = RegExp(r'^[ABCDef]$');
var f = findElement.function('f');
var g = findElement.topVar('g');
RegExp regExp = RegExp(r'^[ABCDfg]$');
expect(await driver.search.topLevelElements(regExp),
unorderedEquals([a, b, c, d, e, f]));
unorderedEquals([a, b, c, d, f, g]));
}
ExpectedResult _expectId(

View file

@ -62,7 +62,7 @@ import 'package:aaa/a.dart';
var x = 0;
var y = a;
var z = PI;
var z = pi;
''');
assertType(findElement.topVar('x').type, 'int*');
assertType(findElement.topVar('y').type, 'int*');
@ -99,7 +99,7 @@ import 'package:aaa/a.dart';
var x = 0;
var y = a;
var z = PI;
var z = pi;
''');
assertType(findElement.topVar('x').type, 'int');
assertType(findElement.topVar('y').type, 'int');

View file

@ -40,6 +40,10 @@ class DocumentationValidator {
static const List<String> unverifiedDocs = [
// Produces two diagnostics when it should only produce one.
'CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE',
// Produces two diagnostics when it should only produce one. We could get
// rid of the invalid error by adding a declaration of a top-level variable
// (such as `JSBool b;`), but that would complicate the example.
'CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY',
// Produces two diagnostics when it should only produce one.
'CompileTimeErrorCode.INVALID_URI',
// Need a way to make auxiliary files that (a) are not included in the
@ -51,6 +55,8 @@ class DocumentationValidator {
'StaticWarningCode.AMBIGUOUS_IMPORT',
// Produces two diagnostics when it should only produce one.
'StaticWarningCode.INVALID_USE_OF_NULL_VALUE',
// Produces the diagnostic HintCode.UNUSED_LOCAL_VARIABLE when it shouldn't.
'StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT',
];
/// The prefix used on directive lines to specify the experiments that should

View file

@ -5699,7 +5699,7 @@ diagnostic because it attempts to include `part.dart` as a part of itself
when `part.dart` is a part of a different library:
{% prettify dart %}
part [!'part.dart'!];
part [!'package:a/part.dart'!];
{% endprettify %}
#### Common fixes

View file

@ -6222,8 +6222,8 @@ C<int> f(C<int> c) {
Future<void> test_prefixedIdentifier_bangHint() async {
await analyze('''
import 'dart:math' as m;
double f1() => m.PI;
double f2() => m.PI/*!*/;
double f1() => m.pi;
double f2() => m.pi/*!*/;
''');
expect(
assertEdge(anyNode, decoratedTypeAnnotation('double f1').node,
@ -6235,7 +6235,7 @@ double f2() => m.PI/*!*/;
hard: false)
.sourceNode,
never);
expect(hasNullCheckHint(findNode.prefixed('m.PI/*!*/')), isTrue);
expect(hasNullCheckHint(findNode.prefixed('m.pi/*!*/')), isTrue);
}
Future<void> test_prefixedIdentifier_field_type() async {