| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 // Regression test for Issue 12320, Issue 12363. | 7 // Regression test for Issue 12320, Issue 12363. |
| 8 | 8 |
| 9 String log = ''; | 9 String log = ''; |
| 10 int x; | 10 int x; |
| 11 | 11 |
| 12 void main() { | 12 void main() { |
| 13 (run)(run); | 13 (run)(run); |
| 14 // The little dance with passing [run] as an argument to confuse the optimizer | 14 // The little dance with passing [run] as an argument to confuse the optimizer |
| 15 // so that [run] is not inlined. If [run] is inlined, the bug (Issue 12320) | 15 // so that [run] is not inlined. If [run] is inlined, the bug (Issue 12320) |
| 16 // eliminates the following 'Expect', making the test appear to pass! | 16 // eliminates the following 'Expect', making the test appear to pass! |
| 17 Expect.equals('[Foo][Foo 1][Bar][Foo][Foo 0]', log); | 17 Expect.equals('[Foo][Foo 1][Bar][Foo][Foo 0]', log); |
| 18 } | 18 } |
| 19 | 19 |
| 20 void run(f) { | 20 void run(f) { |
| 21 if (f is !int) { | 21 if (f is! int) { |
| 22 f(1); | 22 f(1); |
| 23 } else { | 23 } else { |
| 24 x = f; | 24 x = f; |
| 25 callFoo(); | 25 callFoo(); |
| 26 x = 2; | 26 x = 2; |
| 27 callBar(); | 27 callBar(); |
| 28 callFoo(); | 28 callFoo(); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 void callFoo() { | 32 void callFoo() { |
| 33 log += '[Foo]'; | 33 log += '[Foo]'; |
| 34 switch(x) { | 34 switch (x) { |
| 35 case 0: | 35 case 0: |
| 36 log += '[Foo 0]'; | 36 log += '[Foo 0]'; |
| 37 break; | 37 break; |
| 38 case 1: | 38 case 1: |
| 39 log += '[Foo 1]'; | 39 log += '[Foo 1]'; |
| 40 break; | 40 break; |
| 41 default: | 41 default: |
| 42 throw 'invalid x'; | 42 throw 'invalid x'; |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 void callBar() { | 46 void callBar() { |
| 47 log += '[Bar]'; | 47 log += '[Bar]'; |
| 48 x = 0; | 48 x = 0; |
| 49 } | 49 } |
| OLD | NEW |