blob: 52135ec531b1e24cb2f5512fde252575b104fbcd [file] [log] [blame]
// Copyright (c) 2011, 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 A runtime map literal <K, V>{k1: e1...kn: en} is evaluated as
* follows:
* • First, the expression ki is evaluated yielding object ui, the ei is
* evaluated yielding object oi, for i ∈ 1..n in left to right order, yielding
* objects u1; o1 ... un; on.
* • A fresh instance m whose class implements the built-in class Map<K, V> is
* allocated.
* • The operator []= is invoked on m with first argument ui and second argument
* oi, i ∈ 1..n.
* • The result of the evaluation is m.
* @description Checks that values in a map literal are evaluated in order from
* left to right.
* @author msyabro
*/
import '../../../Utils/expect.dart';
var evalOrder;
Object f(number) {
evalOrder = '$evalOrder$number';
return 0;
}
main() {
evalOrder = "";
<String, Object>{"k1": f(1), "k2": f(2), "k3": f(3)};
Expect.equals("123", evalOrder);
}