blob: ed0142275e2779ecb3e91bf0ab63efd3fab6b710 [file] [log] [blame]
 // Copyright (c) 2018, 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. /// @assertion Let the element type of a list literal be the static type of the /// type argument used to create the list. So [] has an element type of int. /// It may be explicit or filled in by type inference. So [1, 2.0] has an element /// type of num. /// /// @description Checks that element type of the list literals is the static type /// of the type argument used to create the list /// @author sgrekhov@unipro.ru import "../../Utils/expect.dart"; main() { bool b = true; var collection = [3, 1, 4, 1, 5]; List list1 = [ if (b) 1, if (!b) 2, if (b) for (var v in collection) if (v.isOdd) v, for (int i = 5; i < 10; i++) i ]; Expect.isTrue(list1 is List); var list2 = [ if (b) 1, if (!b) 2, if (b) for (var v in collection) if (v.isOdd) v, for (int i = 5; i < 10; i++) i ]; Expect.isTrue(list2 is List); var list3 = [ if (b) 1.0, if (!b) 2, if (b) for (var v in collection) if (v.isOdd) v, for (int i = 5; i < 10; i++) i ]; Expect.isTrue(list3 is List); Expect.isFalse(list3 is List); const list4 = [ if (2 > 1) 1.0, if (1 > 2) 2, 3 ]; Expect.isTrue(list4 is List); Expect.isFalse(list4 is List); var list5 = const [ if (2 > 1) 1.0, if (1 > 2) "2", 3 ]; Expect.isTrue(list5 is List