e84b9dba61
R=brianwilkerson@google.com, scheglov@google.com Review URL: https://codereview.chromium.org//22865035 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26673 260f80e4-7a28-3924-810f-c04153c831b5
33 lines
1.2 KiB
Dart
33 lines
1.2 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:analyzer_experimental/analyzer.dart';
|
|
import 'package:unittest/unittest.dart';
|
|
|
|
void main() {
|
|
test("parses a valid compilation unit successfully", () {
|
|
var unit = parseCompilationUnit("void main() => print('Hello, world!');");
|
|
expect(unit.toString(), equals("void main() => print('Hello, world!');"));
|
|
});
|
|
|
|
test("throws errors for an invalid compilation unit", () {
|
|
expect(() {
|
|
parseCompilationUnit("void main() => print('Hello, world!')",
|
|
name: 'test.dart');
|
|
}, throwsA(predicate((error) {
|
|
return error is AnalyzerErrorGroup &&
|
|
error.toString().contains("line 1 of test.dart");
|
|
})));
|
|
});
|
|
|
|
test("defaults to '<unknown source>' if no name is provided", () {
|
|
expect(() {
|
|
parseCompilationUnit("void main() => print('Hello, world!')");
|
|
}, throwsA(predicate((error) {
|
|
return error is AnalyzerErrorGroup &&
|
|
error.toString().contains("line 1 of <unknown source>");
|
|
})));
|
|
});
|
|
}
|