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 // Note: These tests rely on specific line endings in the source files. |
| 6 |
5 import "dart:mirrors"; | 7 import "dart:mirrors"; |
6 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
7 | 9 |
8 import "method_mirror_source_line_ending_lf.dart"; | 10 import "method_mirror_source_line_ending_lf.dart"; |
9 import "method_mirror_source_line_ending_cr.dart"; | 11 import "method_mirror_source_line_ending_cr.dart"; |
10 import "method_mirror_source_line_ending_crlf.dart"; | 12 import "method_mirror_source_line_ending_crlf.dart"; |
11 | 13 |
12 main() { | 14 main() { |
13 String sourceOf(Function f) => (reflect(f) as ClosureMirror).function.source; | 15 String sourceOf(Function f) => (reflect(f) as ClosureMirror).function.source; |
14 | 16 |
15 // Source does not cross line breaks. | 17 // Source does not cross line breaks. |
16 Expect.stringEquals('oneLineLF(x) => x;', sourceOf(oneLineLF)); | 18 Expect.stringEquals('oneLineLF(x) => x;', sourceOf(oneLineLF)); |
17 Expect.stringEquals('oneLineCR(x) => x;', sourceOf(oneLineCR)); | 19 Expect.stringEquals('oneLineCR(x) => x;', sourceOf(oneLineCR)); |
18 Expect.stringEquals('oneLineCRLF(x) => x;', sourceOf(oneLineCRLF)); | 20 Expect.stringEquals('oneLineCRLF(x) => x;', sourceOf(oneLineCRLF)); |
19 | 21 |
20 // Source includes line breaks. | 22 // Source includes line breaks. |
21 Expect.stringEquals('multiLineLF(y) {\n return y + 1;\n}', | 23 Expect.stringEquals('multiLineLF(y) {\n return y + 1;\n}', |
22 sourceOf(multiLineLF)); | 24 sourceOf(multiLineLF)); |
23 Expect.stringEquals('multiLineCR(y) {\r return y + 1;\r}', | 25 Expect.stringEquals('multiLineCR(y) {\r return y + 1;\r}', |
24 sourceOf(multiLineCR)); | 26 sourceOf(multiLineCR)); |
25 Expect.stringEquals('multiLineCRLF(y) {\r\n return y + 1;\r\n}', | 27 Expect.stringEquals('multiLineCRLF(y) {\r\n return y + 1;\r\n}', |
26 sourceOf(multiLineCRLF)); | 28 sourceOf(multiLineCRLF)); |
27 | 29 |
28 // First and last characters separated from middle by line breaks. | 30 // First and last characters separated from middle by line breaks. |
29 Expect.stringEquals('a\n(){\n}', sourceOf(a)); | 31 Expect.stringEquals('a\n(){\n}', sourceOf(a)); |
30 Expect.stringEquals('b\r(){\r}', sourceOf(b)); | 32 Expect.stringEquals('b\r(){\r}', sourceOf(b)); |
31 Expect.stringEquals('c\r\n(){\r\n}', sourceOf(c)); | 33 Expect.stringEquals('c\r\n(){\r\n}', sourceOf(c)); |
32 } | 34 } |
OLD | NEW |