From a899525bdc6aa1c130cc2e2b2f5e59ef25350559 Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Tue, 17 Aug 2021 17:32:52 +0000 Subject: [PATCH] [tests] Add regression tests Issue: https://github.com/dart-lang/sdk/issues/46867 Change-Id: I7e2912752ac8c48df233f27869599280e2c322fa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209853 Reviewed-by: Mark Zhou Commit-Queue: Nicholas Shahan --- tests/language/regress/regress46867_test.dart | 32 +++++++++++++++++ .../language_2/regress/regress46867_test.dart | 34 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 tests/language/regress/regress46867_test.dart create mode 100644 tests/language_2/regress/regress46867_test.dart diff --git a/tests/language/regress/regress46867_test.dart b/tests/language/regress/regress46867_test.dart new file mode 100644 index 000000000000..7999cc849a61 --- /dev/null +++ b/tests/language/regress/regress46867_test.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2021, 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. + +// Regression test for https://github.com/dart-lang/sdk/issues/46867 + +import 'package:expect/expect.dart'; + +class Interface { + covariant Object x = 'from Interface'; +} + +mixin Mixin implements Interface {} + +class BaseClass { + static var getterCallCount = 0; + static var setterCallCount = 0; + Object get x => getterCallCount++; + set x(Object value) => setterCallCount++; +} + +class SubClass extends BaseClass with Mixin {} + +void main() { + Expect.equals(0, BaseClass.getterCallCount); + SubClass().x; + Expect.equals(1, BaseClass.getterCallCount); + + Expect.equals(0, BaseClass.setterCallCount); + SubClass().x = 42; + Expect.equals(1, BaseClass.setterCallCount); +} diff --git a/tests/language_2/regress/regress46867_test.dart b/tests/language_2/regress/regress46867_test.dart new file mode 100644 index 000000000000..750b2234243c --- /dev/null +++ b/tests/language_2/regress/regress46867_test.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2021, 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. + +// @dart = 2.9 + +// Regression test for https://github.com/dart-lang/sdk/issues/46867 + +import 'package:expect/expect.dart'; + +class Interface { + covariant Object x = 'from Interface'; +} + +mixin Mixin implements Interface {} + +class BaseClass { + static var getterCallCount = 0; + static var setterCallCount = 0; + Object get x => getterCallCount++; + set x(Object value) => setterCallCount++; +} + +class SubClass extends BaseClass with Mixin {} + +void main() { + Expect.equals(0, BaseClass.getterCallCount); + SubClass().x; + Expect.equals(1, BaseClass.getterCallCount); + + Expect.equals(0, BaseClass.setterCallCount); + SubClass().x = 42; + Expect.equals(1, BaseClass.setterCallCount); +}