Test case reproducing issue #35940

Change-Id: I6ec0556c0ec42971dee67a784c7c5f884862ac03
Reviewed-on: https://dart-review.googlesource.com/c/93284
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Paul Berry 2019-02-14 20:22:31 +00:00 committed by commit-bot@chromium.org
parent 3b2144fa93
commit 6c96ff0145
2 changed files with 81 additions and 0 deletions

View file

@ -0,0 +1,78 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/driver_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(ConstConstructorParamTypeMismatchTest);
});
}
/// TODO(paulberry): move other tests from [CheckedModeCompileTimeErrorCodeTest]
/// to this class.
@reflectiveTest
class ConstConstructorParamTypeMismatchTest extends DriverResolutionTest {
test_int_to_double_reference_from_other_library_other_file_after() async {
addTestFile('''
class C {
final double d;
const C(this.d);
}
const C constant = const C(0);
''');
newFile('/test/lib/other.dart', content: '''
import 'test.dart';
class D {
final C c;
const D(this.c);
}
const D constant2 = const D(constant);
''');
await resolveTestFile();
assertNoTestErrors();
var otherFileResult =
await resolveFile(convertPath('/test/lib/other.dart'));
expect(otherFileResult.errors, isEmpty);
}
@failingTest
test_int_to_double_reference_from_other_library_other_file_before() async {
addTestFile('''
class C {
final double d;
const C(this.d);
}
const C constant = const C(0);
''');
newFile('/test/lib/other.dart', content: '''
import 'test.dart';
class D {
final C c;
const D(this.c);
}
const D constant2 = const D(constant);
''');
var otherFileResult =
await resolveFile(convertPath('/test/lib/other.dart'));
expect(otherFileResult.errors, isEmpty);
await resolveTestFile();
assertNoTestErrors();
}
test_int_to_double_single_library() async {
addTestFile('''
class C {
final double d;
const C(this.d);
}
const C constant = const C(0);
''');
await resolveTestFile();
assertNoTestErrors();
}
}

View file

@ -6,6 +6,8 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'argument_type_not_assignable_test.dart' as argument_type_not_assignable;
import 'can_be_null_after_null_aware_test.dart' as can_be_null_after_null_aware;
import 'const_constructor_param_type_mismatch_test.dart'
as const_constructor_param_type_mismatch;
import 'deprecated_member_use_test.dart' as deprecated_member_use;
import 'division_optimization_test.dart' as division_optimization;
import 'invalid_assignment_test.dart' as invalid_assignment;
@ -43,6 +45,7 @@ main() {
defineReflectiveSuite(() {
argument_type_not_assignable.main();
can_be_null_after_null_aware.main();
const_constructor_param_type_mismatch.main();
deprecated_member_use.main();
division_optimization.main();
invalid_assignment.main();