mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
![Nicholas Shahan](/assets/img/avatar_default.png)
This happened to work in both type systems because the property of the same name exists in both, but technically `unwrapType()` is part of the old type system and will be deleted soon. Change-Id: I5620c5f409f0c6fe486b9a4c7a6872ee8deabc09 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348800 Reviewed-by: Mark Zhou <markzipan@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>
31 lines
861 B
Dart
31 lines
861 B
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.
|
|
|
|
import "package:expect/expect.dart";
|
|
import 'dart:_foreign_helper' show JS, TYPE_REF;
|
|
import 'dart:_runtime' as dart;
|
|
|
|
void main() {
|
|
dynamic data = JS('', '[1, 2, 3, 4]');
|
|
Expect.isFalse(data is List<int>);
|
|
|
|
var list = dart.constList(data, TYPE_REF<int>());
|
|
Expect.isTrue(list is List<int>);
|
|
Expect.throws(() {
|
|
list[0] = 0;
|
|
});
|
|
|
|
var set = dart.constSet<int>(data);
|
|
Expect.isTrue(set is Set<int>);
|
|
Expect.isTrue(set.contains(3));
|
|
Expect.throws(() => set.clear());
|
|
|
|
var map = dart.constMap<int, int>(data);
|
|
Expect.isTrue(map is Map<int, int>);
|
|
Expect.equals(map[1], 2);
|
|
Expect.throws(() {
|
|
map[1] = 42;
|
|
});
|
|
}
|