| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // VMOptions=---optimization-counter-threshold=10 | 5 // VMOptions=---optimization-counter-threshold=10 |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| 11 int globalVariable = 1; | 11 int globalVariable = 1; |
| 12 int topLevelFoo(int param) => 1; | 12 int topLevelFoo(int param) => 1; |
| 13 int get topLevelGetter => globalVariable; | 13 int get topLevelGetter => globalVariable; |
| 14 void set topLevelSetter(val) { | 14 void set topLevelSetter(val) { |
| 15 globalVariable = val; | 15 globalVariable = val; |
| 16 } | 16 } |
| 17 | 17 |
| 18 class C { | 18 class C { |
| 19 static int staticField = 1; | 19 static int staticField = 1; |
| 20 static int get staticGetter => staticField; | 20 static int get staticGetter => staticField; |
| 21 static void set staticSetter(val) { | 21 static void set staticSetter(val) { |
| 22 staticField = val; | 22 staticField = val; |
| 23 } | 23 } |
| 24 |
| 24 static int staticFoo(int param) => param; | 25 static int staticFoo(int param) => param; |
| 25 | 26 |
| 26 int field = 1; | 27 int field = 1; |
| 27 int get getter => field; | 28 int get getter => field; |
| 28 void set setter(val) { | 29 void set setter(val) { |
| 29 field = val; | 30 field = val; |
| 30 } | 31 } |
| 32 |
| 31 int foo(int param) => param; | 33 int foo(int param) => param; |
| 32 } | 34 } |
| 33 | 35 |
| 34 dummy() => 1; | 36 dummy() => 1; |
| 35 | 37 |
| 36 staticMembers() async { | 38 staticMembers() async { |
| 37 var a = C.staticField + await dummy(); | 39 var a = C.staticField + await dummy(); |
| 38 Expect.equals(a, 2); | 40 Expect.equals(a, 2); |
| 39 var f = (C.staticField = 1) + await dummy(); | 41 var f = (C.staticField = 1) + await dummy(); |
| 40 Expect.equals(f, 2); | 42 Expect.equals(f, 2); |
| 41 var b = C.staticGetter + await dummy(); | 43 var b = C.staticGetter + await dummy(); |
| 42 Expect.equals(b, 2); | 44 Expect.equals(b, 2); |
| 43 var c = (C.staticSetter = 1) + await dummy(); | 45 var c = (C.staticSetter = 1) + await dummy(); |
| 44 Expect.equals(c, 2); | 46 Expect.equals(c, 2); |
| 45 var d = C.staticFoo(2) + await dummy(); | 47 var d = C.staticFoo(2) + await dummy(); |
| 46 Expect.equals(d, 3); | 48 Expect.equals(d, 3); |
| 47 var e = C.staticField + | 49 var e = C.staticField + |
| 48 C.staticGetter + | 50 C.staticGetter + |
| 49 (C.staticSetter = 1) + | 51 (C.staticSetter = 1) + |
| 50 C.staticFoo(1) + | 52 C.staticFoo(1) + |
| 51 await dummy(); | 53 await dummy(); |
| 52 Expect.equals(e, 5); | 54 Expect.equals(e, 5); |
| 53 } | 55 } |
| 54 | 56 |
| 55 topLevelMembers() async { | 57 topLevelMembers() async { |
| 56 var a = globalVariable + await dummy(); | 58 var a = globalVariable + await dummy(); |
| 57 Expect.equals(a, 2); | 59 Expect.equals(a, 2); |
| 58 var b = topLevelGetter + await dummy(); | 60 var b = topLevelGetter + await dummy(); |
| 59 Expect.equals(b, 2); | 61 Expect.equals(b, 2); |
| 60 var c = (topLevelSetter = 1) + await dummy(); | 62 var c = (topLevelSetter = 1) + await dummy(); |
| 61 Expect.equals(c, 2); | 63 Expect.equals(c, 2); |
| 62 var d = topLevelFoo(1) + await dummy(); | 64 var d = topLevelFoo(1) + await dummy(); |
| 63 Expect.equals(d, 2); | 65 Expect.equals(d, 2); |
| 64 var e = globalVariable + | 66 var e = globalVariable + |
| 65 topLevelGetter + | 67 topLevelGetter + |
| 66 (topLevelSetter = 1) + | 68 (topLevelSetter = 1) + |
| 67 topLevelFoo(1) + | 69 topLevelFoo(1) + |
| 68 await dummy(); | 70 await dummy(); |
| 69 Expect.equals(e, 5); | 71 Expect.equals(e, 5); |
| 70 } | 72 } |
| 71 | 73 |
| 72 instanceMembers() async { | 74 instanceMembers() async { |
| 73 var inst = new C(); | 75 var inst = new C(); |
| 74 var a = inst.field + await dummy(); | 76 var a = inst.field + await dummy(); |
| 75 Expect.equals(a, 2); | 77 Expect.equals(a, 2); |
| 76 var b = inst.getter + await dummy(); | 78 var b = inst.getter + await dummy(); |
| 77 Expect.equals(b, 2); | 79 Expect.equals(b, 2); |
| 78 var c = (inst.setter = 1) + await dummy(); | 80 var c = (inst.setter = 1) + await dummy(); |
| 79 Expect.equals(c, 2); | 81 Expect.equals(c, 2); |
| 80 var d = inst.foo(1) + await dummy(); | 82 var d = inst.foo(1) + await dummy(); |
| 81 Expect.equals(d, 2); | 83 Expect.equals(d, 2); |
| 82 var e = inst.field + | 84 var e = inst.field + |
| 83 inst.getter + | 85 inst.getter + |
| 84 (inst.setter = 1) + | 86 (inst.setter = 1) + |
| 85 inst.foo(1) + | 87 inst.foo(1) + |
| 86 await dummy(); | 88 await dummy(); |
| 87 Expect.equals(e, 5); | 89 Expect.equals(e, 5); |
| 88 } | 90 } |
| 89 | 91 |
| 90 await() => 4; | 92 await() => 4; |
| 91 nonAsyncFunction() => await(); | 93 nonAsyncFunction() => await(); |
| 92 | 94 |
| 93 others() async { | 95 others() async { |
| 94 var a = "${globalVariable} ${await dummy()} " + await "someString"; | 96 var a = "${globalVariable} ${await dummy()} " + await "someString"; |
| 95 Expect.equals(a, "1 1 someString"); | 97 Expect.equals(a, "1 1 someString"); |
| 96 try { | 98 try { |
| 97 var c = new C(); | 99 var c = new C(); |
| 98 var d = c.nooooo() + await dummy(); | 100 var d = c.nooooo() + await dummy(); |
| 99 } catch (e) {} | 101 } catch (e) {} |
| 100 var cnt = 2; | 102 var cnt = 2; |
| 101 var b = [1,2,3]; | 103 var b = [1, 2, 3]; |
| 102 b[cnt] = await dummy(); | 104 b[cnt] = await dummy(); |
| 103 Expect.equals(b[cnt], 1); | 105 Expect.equals(b[cnt], 1); |
| 104 var e = b[0] + await dummy(); | 106 var e = b[0] + await dummy(); |
| 105 Expect.equals(e, 2); | 107 Expect.equals(e, 2); |
| 106 Expect.equals(nonAsyncFunction(), 4); | 108 Expect.equals(nonAsyncFunction(), 4); |
| 107 } | 109 } |
| 108 | 110 |
| 109 conditionals() async { | 111 conditionals() async { |
| 110 var a = false; | 112 var a = false; |
| 111 var b = true; | 113 var b = true; |
| 112 var c = (a || b) || await dummy(); | 114 var c = (a || b) || await dummy(); |
| 113 Expect.isTrue(c); | 115 Expect.isTrue(c); |
| 114 var d = (a || b) ? a : await dummy(); | 116 var d = (a || b) ? a : await dummy(); |
| 115 Expect.isFalse(d); | 117 Expect.isFalse(d); |
| 116 var e = (a is int) ? await dummy() : 2; | 118 var e = (a is int) ? await dummy() : 2; |
| 117 Expect.equals(e, 2); | 119 Expect.equals(e, 2); |
| 118 try { | 120 try { |
| 119 var f = (a is int) ? await dummy() : 2; | 121 var f = (a is int) ? await dummy() : 2; |
| 120 } catch(e) {} | 122 } catch (e) {} |
| 121 } | 123 } |
| 122 | 124 |
| 123 main() { | 125 main() { |
| 124 for (int i = 0; i < 10; i++) { | 126 for (int i = 0; i < 10; i++) { |
| 125 staticMembers(); | 127 staticMembers(); |
| 126 topLevelMembers(); | 128 topLevelMembers(); |
| 127 instanceMembers(); | 129 instanceMembers(); |
| 128 conditionals(); | 130 conditionals(); |
| 129 others(); | 131 others(); |
| 130 } | 132 } |
| 131 } | 133 } |
| 132 | |
| OLD | NEW |