2014-08-18 18:41:12 +00:00
|
|
|
// Copyright (c) 2014, 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.
|
|
|
|
|
2016-08-16 01:28:11 +00:00
|
|
|
// VMOptions=--optimization-counter-threshold=10 --no-background-compilation
|
2017-03-21 16:31:11 +00:00
|
|
|
// VMOptions=--optimization-counter-threshold=10 --no-background-compilation --stress-async-stacks
|
2014-08-18 18:41:12 +00:00
|
|
|
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
int globalVariable = 1;
|
|
|
|
int topLevelFoo(int param) => 1;
|
|
|
|
int get topLevelGetter => globalVariable;
|
2015-01-29 16:01:58 +00:00
|
|
|
void set topLevelSetter(val) {
|
2014-08-18 18:41:12 +00:00
|
|
|
globalVariable = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
class C {
|
|
|
|
static int staticField = 1;
|
|
|
|
static int get staticGetter => staticField;
|
2015-01-29 16:01:58 +00:00
|
|
|
static void set staticSetter(val) {
|
2014-08-18 18:41:12 +00:00
|
|
|
staticField = val;
|
|
|
|
}
|
2017-04-17 21:52:57 +00:00
|
|
|
|
2014-08-18 18:41:12 +00:00
|
|
|
static int staticFoo(int param) => param;
|
2015-01-07 19:42:59 +00:00
|
|
|
|
2014-08-18 18:41:12 +00:00
|
|
|
int field = 1;
|
|
|
|
int get getter => field;
|
2015-01-29 16:01:58 +00:00
|
|
|
void set setter(val) {
|
2014-08-18 18:41:12 +00:00
|
|
|
field = val;
|
|
|
|
}
|
2017-04-17 21:52:57 +00:00
|
|
|
|
2014-08-18 18:41:12 +00:00
|
|
|
int foo(int param) => param;
|
|
|
|
}
|
|
|
|
|
|
|
|
dummy() => 1;
|
|
|
|
|
|
|
|
staticMembers() async {
|
|
|
|
var a = C.staticField + await dummy();
|
|
|
|
Expect.equals(a, 2);
|
|
|
|
var f = (C.staticField = 1) + await dummy();
|
|
|
|
Expect.equals(f, 2);
|
|
|
|
var b = C.staticGetter + await dummy();
|
|
|
|
Expect.equals(b, 2);
|
|
|
|
var c = (C.staticSetter = 1) + await dummy();
|
|
|
|
Expect.equals(c, 2);
|
|
|
|
var d = C.staticFoo(2) + await dummy();
|
|
|
|
Expect.equals(d, 3);
|
|
|
|
var e = C.staticField +
|
2017-04-17 21:52:57 +00:00
|
|
|
C.staticGetter +
|
|
|
|
(C.staticSetter = 1) +
|
|
|
|
C.staticFoo(1) +
|
|
|
|
await dummy();
|
2014-08-18 18:41:12 +00:00
|
|
|
Expect.equals(e, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
topLevelMembers() async {
|
|
|
|
var a = globalVariable + await dummy();
|
|
|
|
Expect.equals(a, 2);
|
|
|
|
var b = topLevelGetter + await dummy();
|
|
|
|
Expect.equals(b, 2);
|
|
|
|
var c = (topLevelSetter = 1) + await dummy();
|
|
|
|
Expect.equals(c, 2);
|
|
|
|
var d = topLevelFoo(1) + await dummy();
|
|
|
|
Expect.equals(d, 2);
|
|
|
|
var e = globalVariable +
|
2017-04-17 21:52:57 +00:00
|
|
|
topLevelGetter +
|
|
|
|
(topLevelSetter = 1) +
|
|
|
|
topLevelFoo(1) +
|
|
|
|
await dummy();
|
2014-08-18 18:41:12 +00:00
|
|
|
Expect.equals(e, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
instanceMembers() async {
|
|
|
|
var inst = new C();
|
|
|
|
var a = inst.field + await dummy();
|
|
|
|
Expect.equals(a, 2);
|
|
|
|
var b = inst.getter + await dummy();
|
|
|
|
Expect.equals(b, 2);
|
|
|
|
var c = (inst.setter = 1) + await dummy();
|
|
|
|
Expect.equals(c, 2);
|
|
|
|
var d = inst.foo(1) + await dummy();
|
|
|
|
Expect.equals(d, 2);
|
|
|
|
var e = inst.field +
|
2017-04-17 21:52:57 +00:00
|
|
|
inst.getter +
|
|
|
|
(inst.setter = 1) +
|
|
|
|
inst.foo(1) +
|
|
|
|
await dummy();
|
2014-08-18 18:41:12 +00:00
|
|
|
Expect.equals(e, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
await() => 4;
|
|
|
|
nonAsyncFunction() => await();
|
|
|
|
|
|
|
|
others() async {
|
|
|
|
var a = "${globalVariable} ${await dummy()} " + await "someString";
|
|
|
|
Expect.equals(a, "1 1 someString");
|
|
|
|
try {
|
|
|
|
var c = new C();
|
2015-01-29 16:01:58 +00:00
|
|
|
var d = c.nooooo() + await dummy();
|
2014-08-18 18:41:12 +00:00
|
|
|
} catch (e) {}
|
|
|
|
var cnt = 2;
|
2017-04-17 21:52:57 +00:00
|
|
|
var b = [1, 2, 3];
|
2014-08-18 18:41:12 +00:00
|
|
|
b[cnt] = await dummy();
|
|
|
|
Expect.equals(b[cnt], 1);
|
|
|
|
var e = b[0] + await dummy();
|
|
|
|
Expect.equals(e, 2);
|
|
|
|
Expect.equals(nonAsyncFunction(), 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
conditionals() async {
|
|
|
|
var a = false;
|
|
|
|
var b = true;
|
|
|
|
var c = (a || b) || await dummy();
|
|
|
|
Expect.isTrue(c);
|
|
|
|
var d = (a || b) ? a : await dummy();
|
|
|
|
Expect.isFalse(d);
|
|
|
|
var e = (a is int) ? await dummy() : 2;
|
|
|
|
Expect.equals(e, 2);
|
|
|
|
try {
|
2015-01-29 16:01:58 +00:00
|
|
|
var f = (a is int) ? await dummy() : 2;
|
2017-04-17 21:52:57 +00:00
|
|
|
} catch (e) {}
|
2014-08-18 18:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
staticMembers();
|
|
|
|
topLevelMembers();
|
|
|
|
instanceMembers();
|
|
|
|
conditionals();
|
|
|
|
others();
|
|
|
|
}
|
|
|
|
}
|