mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:37:12 +00:00
40e18905f2
Closes https://github.com/dart-lang/sdk/pull/49478 TEST=Manual GitOrigin-RevId: f4c9c6869dfe73639295e86574a021523b3d374d Change-Id: I134a97caed4eec59d70e9cbca16b7e9a472cf2c1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251902 Reviewed-by: Michael Thomsen <mit@google.com> Commit-Queue: Alexander Thomas <athom@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com> Reviewed-by: Kevin Chisholm <kevinjchisholm@google.com> Reviewed-by: Alexander Thomas <athom@google.com>
41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
// 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.
|
|
|
|
@JS()
|
|
library array_test;
|
|
|
|
import 'package:expect/expect.dart';
|
|
import 'package:js/js.dart';
|
|
import 'package:js/js_util.dart' as js;
|
|
|
|
main() {
|
|
testArrayConstructor();
|
|
}
|
|
|
|
/// Test that we can access .constructor() on a JS Array instance, regardless
|
|
/// of the reified generic type.
|
|
///
|
|
/// Regression test for https://github.com/dart-lang/sdk/issues/36372
|
|
testArrayConstructor() {
|
|
var list = <int>[1, 2, 3];
|
|
testArray = list;
|
|
|
|
// Call the constructor with `new`.
|
|
var array = js.callConstructor(js.getProperty(testArray, 'constructor'), []);
|
|
var list2 = array as List;
|
|
Expect.listEquals(list2, []);
|
|
Expect.notEquals(list, list2, '$list2 should be a new list');
|
|
|
|
// We could return a reified type here, but currently does not to match
|
|
// dart2js, and because the Array is being returned to JS.
|
|
Expect.isFalse(list2 is List<int>,
|
|
'$list2 should not have a reified generic type (it was allocated by JS)');
|
|
|
|
list2.addAll([1, 2, 3]);
|
|
Expect.listEquals(list, list2);
|
|
}
|
|
|
|
external Object get testArray;
|
|
external set testArray(value);
|