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

Unified Diff: tests/compiler/dart2js/expect_annotations_test.dart

Issue 903753002: Add test annotations to package:expect (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update use_unused_api.dart Created 5 years, 10 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
« pkg/expect/lib/expect.dart ('K') | « pkg/expect/lib/expect.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/expect_annotations_test.dart
diff --git a/tests/compiler/dart2js/expect_annotations_test.dart b/tests/compiler/dart2js/expect_annotations_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ed8889ae13d7f74e6648f88f4fdce57a9097d94e
--- /dev/null
+++ b/tests/compiler/dart2js/expect_annotations_test.dart
@@ -0,0 +1,81 @@
+// Copyright (c) 2015, 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 'dart:io';
+import 'package:expect/expect.dart';
+import 'package:async_helper/async_helper.dart';
+import 'package:compiler/src/dart2jslib.dart';
+import 'package:compiler/src/elements/elements.dart';
+import 'package:compiler/src/js_backend/js_backend.dart';
+import 'memory_compiler.dart';
+
+const Map MEMORY_SOURCE_FILES = const {
+ 'main.dart': r"""
+import 'package:expect/expect.dart';
+
+int method(String arg) => arg.length;
+
+@AssumeDynamic()
+int methodAssumeDynamic(String arg) => arg.length;
+
+@TrustTypeAnnotations()
+int methodTrustTypeAnnotations(String arg) => arg.length;
+
+@NoInlining()
+int methodNoInlining(String arg) => arg.length;
+
+@NoInlining() @TrustTypeAnnotations()
+int methodNoInliningTrustTypeAnnotations(String arg) => arg.length;
+
+void main(List<String> args) {
+ print(method(args[0]));
+ print(methodAssumeDynamic('foo'));
+ print(methodTrustTypeAnnotations(null));
+ print(methodNoInlining('bar'));
+ print(methodNoInliningTrustTypeAnnotations(null));
+}
+"""
+};
+
+main() {
+ Compiler compiler = compilerFor(MEMORY_SOURCE_FILES);
+ asyncTest(() => compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) {
+ Expect.isFalse(compiler.compilationFailed, 'Unsuccessful compilation');
+ JavaScriptBackend backend = compiler.backend;
+ Expect.isNotNull(backend.annotations.expectNoInliningClass,
+ 'NoInliningClass is unresolved.');
+ Expect.isNotNull(backend.annotations.expectTrustTypeAnnotationsClass,
+ 'TrustTypeAnnotations is unresolved.');
+ Expect.isNotNull(backend.annotations.expectAssumeDynamicClass,
+ 'AssumeDynamicClass is unresolved.');
+
+ void test(String name,
+ {bool expectNoInlining: false,
+ bool expectTrustTypeAnnotations: false,
+ bool expectAssumeDynamic: false}) {
+ Element method = compiler.mainApp.find(name);
+ Expect.isNotNull(method);
+ Expect.equals(
+ expectNoInlining,
+ backend.annotations.noInlining(method),
+ "Unexpected annotation of @NoInlining on '$method'.");
+ Expect.equals(
+ expectTrustTypeAnnotations,
+ backend.annotations.trustTypeAnnotations(method),
+ "Unexpected annotation of @TrustTypeAnnotations on '$method'.");
+ Expect.equals(
+ expectAssumeDynamic,
+ backend.annotations.assumeDynamic(method),
+ "Unexpected annotation of @AssumeDynamic on '$method'.");
+ }
+
+ test('method');
+ test('methodAssumeDynamic', expectAssumeDynamic: true);
+ test('methodTrustTypeAnnotations', expectTrustTypeAnnotations: true);
+ test('methodNoInlining', expectNoInlining: true);
+ test('methodNoInliningTrustTypeAnnotations',
+ expectNoInlining: true,
+ expectTrustTypeAnnotations: true);
+ }));
+}
« pkg/expect/lib/expect.dart ('K') | « pkg/expect/lib/expect.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698