blob: 09ba7a359cfc1309f402a1da4655d6a34e75fb3b [file] [log] [blame]
// Copyright (c) 2015, 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 e evaluates to an object o that is not an instance of Future,
/// then let f be the result of calling Future.value() with o as its argument;
/// otherwise let f be the result of evaluating e.
/// Next, execution of the function m immediately enclosing a is suspended
/// until after f completes. The stream associated with the innermost enclosing
/// asynchronous for loop, if any, is paused. At some time after f is completed,
/// control returns to the current invocation. The stream associated with the
/// innermost enclosing asynchronous for loop , if any, is resumed. If f has
/// completed with an exception x, a raises x. If f completes with a value v,
/// a evaluates to v.
///
/// @description Check that if e is a call to asynchronous function, then await
/// expression value equals value produced by that function.
///
/// @author a.semenov@unipro.ru
import 'dart:async';
import '../../../Utils/expect.dart';
const String HELLO = 'hello';
Future<int> f1() async {
return int.parse('100' + '500');
}
Future<String> f2() async {
return HELLO;
}
Future<String> f3() async {
return (100000 + 500).toString();
}
test() async {
Expect.equals(100500, await f1());
Expect.identical(HELLO, await f2());
Expect.equals('100500', await f3());
}
main() {
asyncStart();
test().then( (value) => asyncEnd() );
}