blob: 4eb718523aca50e706c8f3222918f4da920d8893 [file] [log] [blame] [edit]
// 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 Execution of a variable declaration statement of one of the forms
/// var v = e; T v = e; const v = e; const T v = e; final v = e; or
/// final T v = e; proceeds as follows:
/// The expression e is evaluated to an object o. A dynamic type error occurs if
/// the dynamic type of o is not a subtype of the actual declared type of v.
/// Otherwise, the variable v is bound to o.
///
/// @description Checks that an expression e is evaluated correctly in a
/// multiple variable declaration statement.
/// @author msyabro
import '../../../Utils/expect.dart';
foo(p1) {
return p1 + 1;
}
bar(p1, p2) {
return p1 - p2;
}
check(p1) {
var x, y = foo(p1 + 2);
var a = foo(2), b;
var c = bar(p1, p1), d = bar(p1, p1 - 1);
Expect.equals(null, x);
Expect.equals(p1 + 3, y);
Expect.equals(3, a);
Expect.equals(null, b);
Expect.equals(0, c);
Expect.equals(1, d);
}
main() {
check(1);
}