Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: pkg/analyzer2dart/test/end2end_test.dart

Issue 669673006: Add SExpression test and share tests between dart2dart and analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer2dart/test/end2end_data.dart ('k') | pkg/analyzer2dart/test/output_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer2dart/test/end2end_test.dart
diff --git a/pkg/analyzer2dart/test/end2end_test.dart b/pkg/analyzer2dart/test/end2end_test.dart
index 8bdbfffaa2e3b25770a38453e02c4a22054ecc39..3cfde576c7075f0a0724c50cd7182dd49d3642d6 100644
--- a/pkg/analyzer2dart/test/end2end_test.dart
+++ b/pkg/analyzer2dart/test/end2end_test.dart
@@ -3,8 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
/// End-to-end test of the analyzer2dart compiler.
-
-import 'dart:async';
+library test.end2end;
import 'mock_sdk.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
@@ -18,491 +17,17 @@ import '../lib/src/driver.dart';
import '../lib/src/converted_world.dart';
import '../lib/src/dart_backend.dart';
-main() {
- test('Empty main', () {
- String expectedResult = '''
-main() {}
-''';
- checkResult('''
-main() {}''',
- expectedResult);
-
- checkResult('''
-main() {}
-foo() {}''',
- expectedResult);
- });
-
- test('Simple call-chains', () {
- checkResult('''
-foo() {}
-main() {
- foo();
-}
-''');
-
- checkResult('''
-bar() {}
-foo() {
- bar();
-}
-main() {
- foo();
-}
-''');
-
- checkResult('''
-bar() {
- main();
-}
-foo() {
- bar();
-}
-main() {
- foo();
-}
-''');
- });
-
- test('Literals', () {
- checkResult('''
-main() {
- return 0;
-}
-''');
-
- checkResult('''
-main() {
- return 1.5;
-}
-''');
-
- checkResult('''
-main() {
- return true;
-}
-''');
-
- checkResult('''
-main() {
- return false;
-}
-''');
-
- checkResult('''
-main() {
- return "a";
-}
-''');
-
- checkResult('''
-main() {
- return "a" "b";
-}
-''', '''
-main() {
- return "ab";
-}
-''');
- });
-
- test('Parameters', () {
- checkResult('''
-main(args) {}
-''');
-
- checkResult('''
-main(a, b) {}
-''');
- });
-
- test('Typed parameters', () {
- checkResult('''
-void main(args) {}
-''');
-
- checkResult('''
-main(int a, String b) {}
-''');
+import 'test_helper.dart' hide TestSpec;
+import 'output_helper.dart';
+import 'end2end_data.dart';
- checkResult('''
-main(Comparator a, List b) {}
-''');
-
- checkResult('''
-main(Comparator<dynamic> a, List<dynamic> b) {}
-''', '''
-main(Comparator a, List b) {}
-''');
-
- checkResult('''
-main(Map a, Map<dynamic, List<int>> b) {}
-''');
- });
-
- test('Pass arguments', () {
- checkResult('''
-foo(a) {}
-main() {
- foo(null);
-}
-''');
-
- checkResult('''
-bar(b, c) {}
-foo(a) {}
-main() {
- foo(null);
- bar(0, "");
-}
-''');
-
- checkResult('''
-bar(b) {}
-foo(a) {
- bar(a);
-}
main() {
- foo(null);
+ performTests(TEST_DATA, unittester, checkResult);
}
-''');
- });
- test('Top level field access', () {
- checkResult('''
-main(args) {
- return deprecated;
-}
-''');
- });
-
- test('Local variables', () {
- checkResult('''
-main() {
- var a;
- return a;
-}
-''', '''
-main() {}
-''');
-
- checkResult('''
-main() {
- var a = 0;
- return a;
-}
-''', '''
-main() {
- return 0;
-}
-''');
- });
-
- test('Dynamic access', () {
- checkResult('''
-main(a) {
- return a.foo;
-}
-''', '''
-main(a) {
- return a.foo;
-}
-''');
-
- checkResult('''
-main() {
- var a = "";
- return a.foo;
-}
-''', '''
-main() {
- return "".foo;
-}
-''');
- });
-
- test('Dynamic invocation', () {
- checkResult('''
-main(a) {
- return a.foo(0);
-}
-''', '''
-main(a) {
- return a.foo(0);
-}
-''');
-
- checkResult('''
-main() {
- var a = "";
- return a.foo(0, 1);
-}
-''', '''
-main() {
- return "".foo(0, 1);
-}
-''');
- });
-
- test('Binary expressions', () {
- checkResult('''
-main(a) {
- return a + deprecated;
-}
-''', '''
-main(a) {
- return a + deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a - deprecated;
-}
-''', '''
-main(a) {
- return a - deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a * deprecated;
-}
-''', '''
-main(a) {
- return a * deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a / deprecated;
-}
-''', '''
-main(a) {
- return a / deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a ~/ deprecated;
-}
-''', '''
-main(a) {
- return a ~/ deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a % deprecated;
-}
-''', '''
-main(a) {
- return a % deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a < deprecated;
-}
-''', '''
-main(a) {
- return a < deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a <= deprecated;
-}
-''', '''
-main(a) {
- return a <= deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a > deprecated;
-}
-''', '''
-main(a) {
- return a > deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a >= deprecated;
-}
-''', '''
-main(a) {
- return a >= deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a << deprecated;
-}
-''', '''
-main(a) {
- return a << deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a >> deprecated;
-}
-''', '''
-main(a) {
- return a >> deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a & deprecated;
-}
-''', '''
-main(a) {
- return a & deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a | deprecated;
-}
-''', '''
-main(a) {
- return a | deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a ^ deprecated;
-}
-''', '''
-main(a) {
- return a ^ deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a == deprecated;
-}
-''', '''
-main(a) {
- return a == deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a != deprecated;
-}
-''', '''
-main(a) {
- return !(a == deprecated);
-}
-''');
-
- checkResult('''
-main(a) {
- return a || deprecated;
-}
-''', '''
-main(a) {
- return a || deprecated;
-}
-''');
-
- checkResult('''
-main(a) {
- return a && deprecated;
-}
-''', '''
-main(a) {
- return a && deprecated;
-}
-''');
- });
-
- test('If statement', () {
- checkResult('''
-main(a) {
- if (a) {
- print(0);
- }
-}
-''', '''
-main(a) {
- if (a) {
- print(0);
- }
-}
-''');
-
- checkResult('''
-main(a) {
- if (a) {
- print(0);
- } else {
- print(1);
- }
-}
-''', '''
-main(a) {
- a ? print(0) : print(1);
-}
-''');
-
- checkResult('''
-main(a) {
- if (a) {
- print(0);
- } else {
- print(1);
- print(2);
- }
-}
-''', '''
-main(a) {
- if (a) {
- print(0);
- } else {
- print(1);
- print(2);
- }
-}
-''');
- });
-
- test('If statement', () {
- checkResult('''
-main(a) {
- return a ? print(0) : print(1);
-}
-''', '''
-main(a) {
- return a ? print(0) : print(1);
-}
-''');
- });
-}
-
-checkResult(String input, [String expectedOutput]) {
- if (expectedOutput == null) {
- expectedOutput = input;
- }
+checkResult(TestSpec result) {
+ String input = result.input;
+ String expectedOutput = result.output;
CollectingOutputProvider outputProvider = new CollectingOutputProvider();
MemoryResourceProvider provider = new MemoryResourceProvider();
@@ -518,26 +43,3 @@ checkResult(String input, [String expectedOutput]) {
String output = outputProvider.output.text;
expect(output, equals(expectedOutput));
}
-
-class CollectingOutputProvider {
- StringBufferSink output;
-
- EventSink<String> call(String name, String extension) {
- return output = new StringBufferSink();
- }
-}
-
-class StringBufferSink implements EventSink<String> {
- StringBuffer sb = new StringBuffer();
-
- void add(String text) {
- sb.write(text);
- }
-
- void addError(errorEvent, [StackTrace stackTrace]) {}
-
- void close() {}
-
- String get text => sb.toString();
-}
-
« no previous file with comments | « pkg/analyzer2dart/test/end2end_data.dart ('k') | pkg/analyzer2dart/test/output_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698