// 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'; // Typed as dynamic to also test spreading a value of type dynamic. final dynamic list = [1, 2, 3, 4]; final dynamic map = {1: 1, 2: 2, 3: 3, 4: 4}; final dynamic set = {1, 2, 3, 4}; void main() { dynamic nonIterable = 3; Expect.throwsTypeError(() => [...nonIterable]); Expect.throwsTypeError(() => {...nonIterable}); dynamic nonMap = 3; Expect.throwsTypeError(() => {...nonMap}); dynamic wrongIterableType = ["s"]; Expect.throwsTypeError(() => [...wrongIterableType]); Expect.throwsTypeError(() => {...wrongIterableType}); dynamic wrongKeyType = {"s": 1}; dynamic wrongValueType = {1: "s"}; Expect.throwsTypeError(() => {...wrongKeyType}); Expect.throwsTypeError(() => {...wrongValueType}); // Mismatched collection types. Expect.throwsTypeError(() => [...map]); Expect.throwsTypeError(() => {...list}); Expect.throwsTypeError(() => {...set}); Expect.throwsTypeError(() => {...map}); }