Skip to content

Commit

Permalink
[ddc] Add test for super calls after hot reload
Browse files Browse the repository at this point in the history
Regression test for broken super calls after a hot reload.

Issue: #59628
Change-Id: I799cac6babb45f0a8f7d2dd63fdfbaea72dba9b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398041
Reviewed-by: Nate Biggs <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
  • Loading branch information
nshahan authored and Commit Queue committed Nov 28, 2024
1 parent 47e3ad7 commit 0055f0a
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/hot_reload/super_call_regress_59628/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"exclude": []
}
31 changes: 31 additions & 0 deletions tests/hot_reload/super_call_regress_59628/main.0.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2024, 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:expect/expect.dart';
import 'package:reload_test/reload_test_utils.dart';

// Regression test for https://github.com/dart-lang/sdk/issues/59628.

class A {
method() {
return 'A.method';
}
}

class B extends A {
method() {
return '${super.method()} - B.method';
}
}

String unrelatedChange() => 'before';

Future<void> main() async {
Expect.equals('before', unrelatedChange());
var b = B();
Expect.equals('A.method - B.method', b.method());
await hotReload();
Expect.equals('after', unrelatedChange());
Expect.equals('A.method - B.method', b.method());
}
49 changes: 49 additions & 0 deletions tests/hot_reload/super_call_regress_59628/main.1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2024, 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:expect/expect.dart';
import 'package:reload_test/reload_test_utils.dart';

// Regression test for https://github.com/dart-lang/sdk/issues/59628.

class A {
method() {
return 'A.method';
}
}

class B extends A {
method() {
return '${super.method()} - B.method';
}
}

String unrelatedChange() => 'after';

Future<void> main() async {
Expect.equals('before', unrelatedChange());
var b = B();
Expect.equals('A.method - B.method', b.method());
await hotReload();
Expect.equals('after', unrelatedChange());
Expect.equals('A.method - B.method', b.method());
}

/** DIFF **/
/*
@@ -19,7 +19,7 @@
}
}
-String unrelatedChange() => 'before';
+String unrelatedChange() => 'after';
Future<void> main() async {
Expect.equals('before', unrelatedChange());
@@ -29,3 +29,4 @@
Expect.equals('after', unrelatedChange());
Expect.equals('A.method - B.method', b.method());
}
+
*/

0 comments on commit 0055f0a

Please sign in to comment.