| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('dart:uri'); | 5 #import('dart:uri'); |
| 6 | 6 |
| 7 #import("../../../lib/compiler/implementation/leg.dart"); | 7 #import("../../../lib/compiler/implementation/leg.dart"); |
| 8 #import('../../../lib/compiler/implementation/source_file.dart'); | 8 #import('../../../lib/compiler/implementation/source_file.dart'); |
| 9 #import("mock_compiler.dart"); | 9 #import("mock_compiler.dart"); |
| 10 #import('parser_helper.dart'); | 10 #import('parser_helper.dart'); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 String message = sourceFileWithMarkers.getLocationMessage( | 44 String message = sourceFileWithMarkers.getLocationMessage( |
| 45 'Missing location', originalLocation, originalLocation + 1, true, | 45 'Missing location', originalLocation, originalLocation + 1, true, |
| 46 (s) => s); | 46 (s) => s); |
| 47 Expect.fail(message); | 47 Expect.fail(message); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 String FUNCTIONS_TEST = ''' | 52 String FUNCTIONS_TEST = ''' |
| 53 @void main() { print(test(15)); @} | 53 @void main() { print(test(15)); @} |
| 54 @int test(int x) { return x; @}'''; | 54 // The 'if' has been added to avoid inlining of 'test'. |
| 55 @int test(int x) { if (x != null) return x; else return null; @}'''; |
| 55 | 56 |
| 56 String RETURN_TEST = 'void main() { print(((x) { @return x; })(0)); }'; | 57 String RETURN_TEST = 'void main() { print(((x) { @return x; })(0)); }'; |
| 57 | 58 |
| 58 String NOT_TEST = 'void main() { ((x) { if (@!x) print(x); })(false); }'; | 59 String NOT_TEST = 'void main() { ((x) { if (@!x) print(x); })(false); }'; |
| 59 | 60 |
| 60 String UNARY_TEST = 'void main() { ((x, y) { print(@-x + @~y); })(1,2); }'; | 61 String UNARY_TEST = 'void main() { ((x, y) { print(@-x + @~y); })(1,2); }'; |
| 61 | 62 |
| 62 String BINARY_TEST = 'void main() { ((x, y) { if (x @!== y) print(x @* y); })(1,
2); }'; | 63 String BINARY_TEST = 'void main() { ((x, y) { if (x @!== y) print(x @* y); })(1,
2); }'; |
| 63 | 64 |
| 64 String SEND_TEST = ''' | 65 String SEND_TEST = ''' |
| 65 void main() { | 66 void main() { |
| 66 @staticSend(0); | 67 @staticSend(0); |
| 67 NewSend o = new @NewSend(); | 68 NewSend o = new @NewSend(); |
| 68 @o.dynamicSend(0); | 69 @o.dynamicSend(0); |
| 69 var closureSend = (x) { print(x); }; | 70 var closureSend = (x) { print(x); }; |
| 70 @closureSend(0); | 71 @closureSend(0); |
| 71 } | 72 } |
| 72 void staticSend(x) { print(x); } | 73 // The 'if' has been added to avoid inlining of 'staticSend'. |
| 74 void staticSend(x) { if (x == null) return; print(x); } |
| 73 class NewSend { void dynamicSend(x) { print(x); } } | 75 class NewSend { void dynamicSend(x) { print(x); } } |
| 74 '''; | 76 '''; |
| 75 | 77 |
| 76 String LOOP_TEST = ''' | 78 String LOOP_TEST = ''' |
| 77 void main() { | 79 void main() { |
| 78 @for (int i = 0; i < 100; ++i) { print(test(13)); @} | 80 @for (int i = 0; i < 100; ++i) { print(test(13)); @} |
| 79 } | 81 } |
| 80 int test(int x) { | 82 int test(int x) { |
| 81 int result = 1; @while (result < x) { result <<= 1; @} return result; | 83 int result = 1; @while (result < x) { result <<= 1; @} return result; |
| 82 }'''; | 84 }'''; |
| 83 | 85 |
| 84 | 86 |
| 85 main() { | 87 main() { |
| 86 // These tests are fragile, since mappings for specific source locations | 88 // These tests are fragile, since mappings for specific source locations |
| 87 // could disappear due to various optimizations like code elimination, | 89 // could disappear due to various optimizations like code elimination, |
| 88 // function inlining, etc. If you broke the test, please try to rewrite it | 90 // function inlining, etc. If you broke the test, please try to rewrite it |
| 89 // so that the new code is not optimized, otherwise just remove the marker | 91 // so that the new code is not optimized, otherwise just remove the marker |
| 90 // from problematic location. | 92 // from problematic location. |
| 91 testSourceMapLocations(FUNCTIONS_TEST); | 93 testSourceMapLocations(FUNCTIONS_TEST); |
| 92 testSourceMapLocations(RETURN_TEST); | 94 testSourceMapLocations(RETURN_TEST); |
| 93 testSourceMapLocations(NOT_TEST); | 95 testSourceMapLocations(NOT_TEST); |
| 94 testSourceMapLocations(UNARY_TEST); | 96 testSourceMapLocations(UNARY_TEST); |
| 95 testSourceMapLocations(BINARY_TEST); | 97 testSourceMapLocations(BINARY_TEST); |
| 96 testSourceMapLocations(SEND_TEST); | 98 testSourceMapLocations(SEND_TEST); |
| 97 testSourceMapLocations(LOOP_TEST); | 99 testSourceMapLocations(LOOP_TEST); |
| 98 } | 100 } |
| OLD | NEW |