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

Unified Diff: runtime/tests/vm/dart/mirrored_compilation_error_test.dart

Issue 28053005: Hide MirroredCompilationErrror behind a flag until post-1.0. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
Index: runtime/tests/vm/dart/mirrored_compilation_error_test.dart
diff --git a/runtime/tests/vm/dart/mirrored_compilation_error_test.dart b/runtime/tests/vm/dart/mirrored_compilation_error_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b661afe6517d24884b3a04bacd1c8e0f7b23ad73
--- /dev/null
+++ b/runtime/tests/vm/dart/mirrored_compilation_error_test.dart
@@ -0,0 +1,103 @@
+// 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.
+
+// VMOptions=--use_mirrored_compilation_error=true
+
+@notDefined
+library mirrored_compilation_error_test;
+
+import 'dart:mirrors';
+import "package:expect/expect.dart";
+
+@notDefined
+class Class<@notDefined T> {
+ @notDefined
+ var field;
+
+ @notDefined
+ method(@notDefined param) {}
+}
+
+class Class2 {
+ method() { +++; }
+ get getter { +++; }
+ set setter(x) { +++; }
+
+ static staticFunction() { +++; }
+ static get staticGetter { +++; }
+ static set staticSetter(x) { +++; }
+
+ Class2() {}
+ Class2.constructor() { +++; }
+}
+
+toplevelFunction() { +++; }
+get toplevelGetter { +++; }
+set toplevelSetter(x) { +++; }
+
+
+class G<A extends int, B extends String> {
+ G();
+ factory G.swap() = G<B,A>; /// static type warning
+}
+
+raises(closure) {
+ Expect.throws(closure,
+ (e) => e is MirroredCompilationError,
+ 'Expected a deferred compilation error');
+}
+
+bool get inCheckedMode {
+ try {
+ var i = 1;
+ String s = i;
+ return false;
+ } catch (e) {
+ return true;
+ }
+}
+
+main() {
+
+ // Metadata.
+
+ raises(() => reflectClass(Class).metadata);
+ raises(() => reflectClass(Class).typeVariables.single.metadata);
+ raises(() => reflectClass(Class).variables[#field].metadata);
+ raises(() => reflectClass(Class).methods[#method].metadata);
+ raises(() => reflectClass(Class).methods[#method].parameters.single.metadata);
+ raises(() => reflectClass(Class).owner.metadata);
+
+
+ // Invocation.
+
+ InstanceMirror im = reflect(new Class2());
+ raises(() => im.invoke(#method, []));
+ raises(() => im.getField(#getter));
+ raises(() => im.setField(#setter, 'some value'));
+ // The implementation is within its right to defer the compilation even
+ // further here, so we apply the tear-off to force compilation.
+ raises(() => im.getField(#method).apply([]));
+
+ ClassMirror cm = reflectClass(Class2);
+ raises(() => cm.invoke(#staticFunction, []));
+ raises(() => cm.getField(#staticGetter));
+ raises(() => cm.setField(#staticSetter, 'some value'));
+ raises(() => cm.getField(#staticFunction).apply([]));
+ raises(() => cm.newInstance(#constructor, []));
+
+ LibraryMirror lm = reflectClass(Class2).owner;
+ raises(() => lm.invoke(#toplevelFunction, []));
+ raises(() => lm.getField(#toplevelGetter));
+ raises(() => lm.setField(#toplevelSetter, 'some value'));
+ raises(() => lm.getField(#toplevelFunction).apply([]));
+
+
+ // Bounds violation.
+
+ if (inCheckedMode) {
+ ClassMirror cm = reflect(new G<int, String>()).type;
+ raises(() => cm.newInstance(#swap, []));
+ }
+}
« no previous file with comments | « runtime/tests/vm/dart/isolate_mirror_local_test.dart ('k') | runtime/tests/vm/dart/redirection_type_shuffling_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698