OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @TestOn("vm") | 5 @TestOn("vm") |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
9 | 9 |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 contains('-1: load error'), | 125 contains('-1: load error'), |
126 contains( | 126 contains( |
127 ' Failed to load "${p.relative(testPath, from: _sandbox)}":\n' | 127 ' Failed to load "${p.relative(testPath, from: _sandbox)}":\n' |
128 " line 1 pos 1: unexpected token 'invalid'\n" | 128 " line 1 pos 1: unexpected token 'invalid'\n" |
129 " invalid Dart file\n" | 129 " invalid Dart file\n" |
130 " ^\n") | 130 " ^\n") |
131 ])); | 131 ])); |
132 expect(result.exitCode, equals(1)); | 132 expect(result.exitCode, equals(1)); |
133 }); | 133 }); |
134 | 134 |
| 135 // This syntax error is detected lazily, and so requires some extra |
| 136 // machinery to support. |
| 137 test("a test file fails to parse due to a missing semicolon", () { |
| 138 var testPath = p.join(_sandbox, "test.dart"); |
| 139 new File(testPath).writeAsStringSync("void main() {foo}"); |
| 140 var result = _runTest(["test.dart"]); |
| 141 |
| 142 expect(result.stdout, allOf([ |
| 143 contains('-1: load error'), |
| 144 contains( |
| 145 ' Failed to load "${p.relative(testPath, from: _sandbox)}":\n' |
| 146 " line 1 pos 17: semicolon expected\n" |
| 147 " void main() {foo}\n" |
| 148 " ^\n") |
| 149 ])); |
| 150 expect(result.exitCode, equals(1)); |
| 151 }); |
| 152 |
135 // This is slightly different from the above test because it's an error | 153 // This is slightly different from the above test because it's an error |
136 // that's caught first by the analyzer when it's used to parse the file. | 154 // that's caught first by the analyzer when it's used to parse the file. |
137 test("a test file fails to parse", () { | 155 test("a test file fails to parse", () { |
138 var testPath = p.join(_sandbox, "test.dart"); | 156 var testPath = p.join(_sandbox, "test.dart"); |
139 new File(testPath).writeAsStringSync("@TestOn)"); | 157 new File(testPath).writeAsStringSync("@TestOn)"); |
140 var result = _runTest(["test.dart"]); | 158 var result = _runTest(["test.dart"]); |
141 | 159 |
142 expect(result.stdout, allOf([ | 160 expect(result.stdout, allOf([ |
143 contains('-1: load error'), | 161 contains('-1: load error'), |
144 contains( | 162 contains( |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 }); | 685 }); |
668 }); | 686 }); |
669 }); | 687 }); |
670 } | 688 } |
671 | 689 |
672 ProcessResult _runTest(List<String> args) => | 690 ProcessResult _runTest(List<String> args) => |
673 runTest(args, workingDirectory: _sandbox); | 691 runTest(args, workingDirectory: _sandbox); |
674 | 692 |
675 ProcessResult _runDart(List<String> args) => | 693 ProcessResult _runDart(List<String> args) => |
676 runDart(args, workingDirectory: _sandbox); | 694 runDart(args, workingDirectory: _sandbox); |
OLD | NEW |