| 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 library formatter_test; |
| 6 |
| 5 import 'dart:io'; | 7 import 'dart:io'; |
| 6 | 8 |
| 7 import 'package:path/path.dart'; | 9 import 'package:path/path.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 9 | 11 |
| 10 import 'package:analyzer/src/generated/scanner.dart'; | 12 import 'package:analyzer/src/generated/scanner.dart'; |
| 11 import 'package:analyzer/src/services/formatter_impl.dart'; | 13 import 'package:analyzer/src/services/formatter_impl.dart'; |
| 12 import 'package:analyzer/src/services/writer.dart'; | 14 import 'package:analyzer/src/services/writer.dart'; |
| 13 | 15 |
| 14 // Test data location ('pkg/analyzer/test/services/data') | 16 // Test data location ('pkg/analyzer/test/services/data') |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 ' foo(int x) {\n' | 59 ' foo(int x) {\n' |
| 58 ' if (x == 0) {\n' | 60 ' if (x == 0) {\n' |
| 59 ' return true;\n' | 61 ' return true;\n' |
| 60 ' }\n' | 62 ' }\n' |
| 61 ' }\n' | 63 ' }\n' |
| 62 '}\n'; | 64 '}\n'; |
| 63 expectCUFormatsTo( | 65 expectCUFormatsTo( |
| 64 original, | 66 original, |
| 65 original | 67 original |
| 66 ); | 68 ); |
| 67 // expectIndentFormatsTo(3, false, | 69 expectIndentFormatsTo(3, false, |
| 68 // original, | 70 original, |
| 69 // 'class A {\n' | 71 'class A {\n' |
| 70 // ' var z;\n' | 72 ' var z;\n' |
| 71 // ' inc(int x) => ++x;\n' | 73 ' inc(int x) => ++x;\n' |
| 72 // ' foo(int x) {\n' | 74 ' foo(int x) {\n' |
| 73 // ' if (x == 0) {\n' | 75 ' if (x == 0) {\n' |
| 74 // ' return true;\n' | 76 ' return true;\n' |
| 75 // ' }\n' | 77 ' }\n' |
| 76 // ' }\n' | 78 ' }\n' |
| 77 // '}\n' | 79 '}\n' |
| 78 // ); | 80 ); |
| 79 // expectIndentFormatsTo(1, true, | 81 expectIndentFormatsTo(1, true, |
| 80 // original, | 82 original, |
| 81 // 'class A {\n' | 83 'class A {\n' |
| 82 // '\tvar z;\n' | 84 '\tvar z;\n' |
| 83 // '\tinc(int x) => ++x;\n' | 85 '\tinc(int x) => ++x;\n' |
| 84 // '\tfoo(int x) {\n' | 86 '\tfoo(int x) {\n' |
| 85 // '\t\tif (x == 0) {\n' | 87 '\t\tif (x == 0) {\n' |
| 86 // '\t\t\treturn true;\n' | 88 '\t\t\treturn true;\n' |
| 87 // '\t\t}\n' | 89 '\t\t}\n' |
| 88 // '\t}\n' | 90 '\t}\n' |
| 89 // '}\n' | 91 '}\n' |
| 90 // ); | 92 ); |
| 91 }); | 93 }); |
| 92 | 94 |
| 93 test('CU (1)', () { | 95 test('CU (1)', () { |
| 94 expectCUFormatsTo( | 96 expectCUFormatsTo( |
| 95 'class A {\n' | 97 'class A {\n' |
| 96 ' var z;\n' | 98 ' var z;\n' |
| 97 ' inc(int x) => ++x;\n' | 99 ' inc(int x) => ++x;\n' |
| 98 '}\n', | 100 '}\n', |
| 99 'class A {\n' | 101 'class A {\n' |
| 100 ' var z;\n' | 102 ' var z;\n' |
| (...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 input += lines[i++] + '\n'; | 1485 input += lines[i++] + '\n'; |
| 1484 } | 1486 } |
| 1485 while(++i < lines.length && !lines[i].startsWith('>>>')) { | 1487 while(++i < lines.length && !lines[i].startsWith('>>>')) { |
| 1486 expectedOutput += lines[i] + '\n'; | 1488 expectedOutput += lines[i] + '\n'; |
| 1487 } | 1489 } |
| 1488 test('test - (${testIndex++})', () { | 1490 test('test - (${testIndex++})', () { |
| 1489 expectClause(input, expectedOutput); | 1491 expectClause(input, expectedOutput); |
| 1490 }); | 1492 }); |
| 1491 } | 1493 } |
| 1492 } | 1494 } |
| OLD | NEW |