Skip to content

Commit a899525

Browse files
nshahancommit-bot@chromium.org
authored andcommitted
[tests] Add regression tests
Issue: dart-lang/sdk#46867 Change-Id: I7e2912752ac8c48df233f27869599280e2c322fa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209853 Reviewed-by: Mark Zhou <[email protected]> Commit-Queue: Nicholas Shahan <[email protected]>
1 parent d904834 commit a899525

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Regression test for https://github.com/dart-lang/sdk/issues/46867
6+
7+
import 'package:expect/expect.dart';
8+
9+
class Interface {
10+
covariant Object x = 'from Interface';
11+
}
12+
13+
mixin Mixin implements Interface {}
14+
15+
class BaseClass {
16+
static var getterCallCount = 0;
17+
static var setterCallCount = 0;
18+
Object get x => getterCallCount++;
19+
set x(Object value) => setterCallCount++;
20+
}
21+
22+
class SubClass extends BaseClass with Mixin {}
23+
24+
void main() {
25+
Expect.equals(0, BaseClass.getterCallCount);
26+
SubClass().x;
27+
Expect.equals(1, BaseClass.getterCallCount);
28+
29+
Expect.equals(0, BaseClass.setterCallCount);
30+
SubClass().x = 42;
31+
Expect.equals(1, BaseClass.setterCallCount);
32+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// @dart = 2.9
6+
7+
// Regression test for https://github.com/dart-lang/sdk/issues/46867
8+
9+
import 'package:expect/expect.dart';
10+
11+
class Interface {
12+
covariant Object x = 'from Interface';
13+
}
14+
15+
mixin Mixin implements Interface {}
16+
17+
class BaseClass {
18+
static var getterCallCount = 0;
19+
static var setterCallCount = 0;
20+
Object get x => getterCallCount++;
21+
set x(Object value) => setterCallCount++;
22+
}
23+
24+
class SubClass extends BaseClass with Mixin {}
25+
26+
void main() {
27+
Expect.equals(0, BaseClass.getterCallCount);
28+
SubClass().x;
29+
Expect.equals(1, BaseClass.getterCallCount);
30+
31+
Expect.equals(0, BaseClass.setterCallCount);
32+
SubClass().x = 42;
33+
Expect.equals(1, BaseClass.setterCallCount);
34+
}

0 commit comments

Comments
 (0)