| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 |
| 7 // Regression test for Issue 12320, Issue 12363. |
| 8 |
| 9 String log = ''; |
| 10 int x; |
| 11 |
| 12 void main() { |
| 13 (run)(run); |
| 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) |
| 16 // eliminates the following 'Expect', making the test appear to pass! |
| 17 Expect.equals('[Foo][Foo 1][Bar][Foo][Foo 0]', log); |
| 18 } |
| 19 |
| 20 void run(f) { |
| 21 if (f is !int) { |
| 22 f(1); |
| 23 } else { |
| 24 x = f; |
| 25 callFoo(); |
| 26 x = 2; |
| 27 callBar(); |
| 28 callFoo(); |
| 29 } |
| 30 } |
| 31 |
| 32 void callFoo() { |
| 33 log += '[Foo]'; |
| 34 switch(x) { |
| 35 case 0: |
| 36 log += '[Foo 0]'; |
| 37 break; |
| 38 case 1: |
| 39 log += '[Foo 1]'; |
| 40 break; |
| 41 default: |
| 42 throw 'invalid x'; |
| 43 } |
| 44 } |
| 45 |
| 46 void callBar() { |
| 47 log += '[Bar]'; |
| 48 x = 0; |
| 49 } |
| OLD | NEW |