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

Unified Diff: test/codegen/lib/mirrors/model_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 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 | « test/codegen/lib/mirrors/model.dart ('k') | test/codegen/lib/mirrors/native_class_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/lib/mirrors/model_test.dart
diff --git a/test/codegen/lib/mirrors/model_test.dart b/test/codegen/lib/mirrors/model_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1e3c292b52f20bf7e85cb9d5d48ca9f35bfbf41f
--- /dev/null
+++ b/test/codegen/lib/mirrors/model_test.dart
@@ -0,0 +1,57 @@
+// 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.
+
+library test.model_test;
+
+import 'package:expect/expect.dart';
+
+import 'model.dart';
+
+isNoSuchMethodError(e) => e is NoSuchMethodError;
+
+main() {
+ var a = new A();
+ var b = new B();
+ var c = new C();
+
+ Expect.isNull(a.field);
+ Expect.equals('B:get field', b.field);
+ Expect.equals('B:get field', c.field);
+
+ a.field = 42;
+ b.field = 87;
+ c.field = 89;
+ Expect.equals(42, a.field);
+ Expect.equals('B:get field', b.field);
+ Expect.equals('B:get field', c.field);
+ Expect.equals(89, fieldC);
+
+ Expect.equals('A:instanceMethod(7)', a.instanceMethod(7));
+ Expect.equals('B:instanceMethod(9)', b.instanceMethod(9));
+ Expect.equals('C:instanceMethod(13)', c.instanceMethod(13));
+
+ Expect.equals('A:get accessor', a.accessor);
+ Expect.equals('B:get accessor', b.accessor);
+ Expect.equals('C:get accessor', c.accessor);
+
+ a.accessor = 'foo';
+ b.accessor = 'bar';
+ c.accessor = 'baz';
+
+ Expect.equals('foo', accessorA);
+ Expect.equals('bar', accessorB);
+ Expect.equals('baz', accessorC);
+
+ Expect.equals('aMethod', a.aMethod());
+ Expect.equals('aMethod', b.aMethod());
+ Expect.equals('aMethod', c.aMethod());
+
+ Expect.throws(() { a.bMethod(); }, isNoSuchMethodError);
+ Expect.equals('bMethod', b.bMethod());
+ Expect.equals('bMethod', c.bMethod());
+
+ Expect.throws(() { a.cMethod(); }, isNoSuchMethodError);
+ Expect.throws(() { b.cMethod(); }, isNoSuchMethodError);
+ Expect.equals('cMethod', c.cMethod());
+}
« no previous file with comments | « test/codegen/lib/mirrors/model.dart ('k') | test/codegen/lib/mirrors/native_class_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698