blob: 75ba04ab7f23cfb8b1434ee12372621726fb5ca7 [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 If s does not start with const and it does not occur in a constant
* context, then it evaluates to a mutable set object as follows:
* Let e1 … en be the constant element expressions of s in source order.
* Evaluation of s proceeds as follows:
* First evaluate e1 … en, in source order, to values v1 … vn.
* Create a new LinkedHashSet<T> instance, o.
* For each i in 1 … n in numeric order, invoke the add method on o with vi as
* argument. Then s evaluates to an object implementing LinkedHashSet which has
* the same elements as o, and in the same iteration order. (Iteration order is
* insertion order, where adding an element equal to one already in the set does
* not change the set in any way).
* @description Check that if set literal is not constant then it is mutable
* @author
import "../../Utils/expect.dart";
main() {
var s1 = <int> {};
Expect.iterableEquals({1}, s1);
Expect.iterableEquals(<int>{}, s1);
var s2 = <int> {3, 1, 4};
Expect.iterableEquals({3, 1, 4, 5}, s2);
Expect.iterableEquals(<int>{}, s2);
var s3 = {1, 2, 3.14, null, true, 1};
Expect.iterableEquals({1, 2, 3.14, null, true, "x"}, s3);
Expect.iterableEquals(<Object>{}, s3);