[dart2js] Test for http://dartbug.com/51955
Change-Id: I6602497f01e95688f5bd2225e1ce8ea804b7c31d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293402
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/tests/web/regress/issue/51955_lib1.dart b/tests/web/regress/issue/51955_lib1.dart
new file mode 100644
index 0000000..d496f1a
--- /dev/null
+++ b/tests/web/regress/issue/51955_lib1.dart
@@ -0,0 +1,8 @@
+// Copyright (c) 2023, 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.
+
+String work() {
+ final list = [for (int i = 0; i < 10; i++) (1, i)];
+ return list.reduce((a, b) => (a.$1 + b.$1, a.$2 + b.$2)).toString();
+}
diff --git a/tests/web/regress/issue/51955_lib2.dart b/tests/web/regress/issue/51955_lib2.dart
new file mode 100644
index 0000000..7bffc5b
--- /dev/null
+++ b/tests/web/regress/issue/51955_lib2.dart
@@ -0,0 +1,10 @@
+// Copyright (c) 2023, 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.
+
+String work() {
+ final list = [for (int i = 0; i < 10; i++) (1, i, i * i)];
+ return list
+ .reduce((a, b) => (a.$1 + b.$1, a.$2 + b.$2, a.$3 + b.$3))
+ .toString();
+}
diff --git a/tests/web/regress/issue/51955_test.dart b/tests/web/regress/issue/51955_test.dart
new file mode 100644
index 0000000..ca7253a
--- /dev/null
+++ b/tests/web/regress/issue/51955_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2023, 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.
+
+// This test uses Records with different shapes, but only in deferred libraries.
+
+import '51955_lib1.dart' deferred as lib1;
+import '51955_lib2.dart' deferred as lib2;
+
+void main() async {
+ await lib1.loadLibrary();
+ print(lib1.work());
+ await lib2.loadLibrary();
+ print(lib2.work());
+}