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

Side by Side Diff: test_reflectable/test/capabilities_test.dart

Issue 1289933004: Implements support for reflection on parameters. (Closed) Base URL: https://github.com/dart-lang/reflectable.git@master
Patch Set: Merging with code from Sigurd, caused several adjustments Created 5 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 unified diff | Download patch
« no previous file with comments | « test_reflectable/test/basic_test.dart ('k') | test_reflectable/test/declarations_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test_reflectable.test.capabilities_test; 5 library test_reflectable.test.capabilities_test;
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'package:reflectable/reflectable.dart' as r; 8 import 'package:reflectable/reflectable.dart' as r;
9 import 'package:reflectable/capability.dart' as c; 9 import 'package:reflectable/capability.dart' as c;
10 10
11 // Tests that reflection is constrained according to capabilities. 11 // Tests that reflection is constrained according to capabilities.
12 // TODO(sigurdm) implement: Write tests that covers all capabilities. 12 // TODO(sigurdm) implement: Write tests that covers all capabilities.
13 // TODO(sigurdm) implement: Write tests that covers top-level invocations. 13 // TODO(sigurdm) implement: Write tests that covers top-level invocations.
14 14
15 class MyReflectableStatic extends r.Reflectable { 15 class MyReflectableStatic extends r.Reflectable {
16 const MyReflectableStatic() : super(const c.StaticInvokeCapability("foo"), 16 const MyReflectableStatic() : super(const c.StaticInvokeCapability("foo"),
17 const c.StaticInvokeCapability("getFoo"), 17 const c.StaticInvokeCapability("getFoo"),
18 const c.StaticInvokeCapability("setFoo="), 18 const c.StaticInvokeCapability("setFoo="),
19 const c.StaticInvokeCapability("nonExisting"), 19 const c.StaticInvokeCapability("nonExisting"),
20 const c.StaticInvokeMetaCapability(C)); 20 const c.StaticInvokeMetaCapability(C),
21 c.declarationsCapability);
21 } 22 }
22 23
23 @MyReflectableStatic() 24 @MyReflectableStatic()
24 class A { 25 class A {
25 static int foo() => 42; 26 static int foo() => 42;
26 static int bar() => 43; 27 static int bar() => 43;
27 static int get getFoo => 44; 28 static int get getFoo => 44;
28 static int get getBar => 45; 29 static int get getBar => 45;
29 static set setFoo(int x) => field = x; 30 static set setFoo(int x) => field = x;
30 static set setBar(int x) => field = x; 31 static set setBar(int x) => field = x;
31 static int field = 46; 32 static int field = 46;
32 @C() 33 @C()
33 static int boo() => 47; 34 static int boo() => 47;
34 } 35 }
35 36
36 class C { 37 class C {
37 const C(); 38 const C();
38 } 39 }
39 40
40 class MyReflectableInstance extends r.Reflectable { 41 class MyReflectableInstance extends r.Reflectable {
41 const MyReflectableInstance() : super(const c.InstanceInvokeCapability("foo"), 42 const MyReflectableInstance() : super(const c.InstanceInvokeCapability("foo"),
42 const c.InstanceInvokeCapability("getFoo"), 43 const c.InstanceInvokeCapability("getFoo"),
43 const c.InstanceInvokeCapability("setFoo="), 44 const c.InstanceInvokeCapability("setFoo="),
44 const c.InstanceInvokeCapability("nonExisting"), 45 const c.InstanceInvokeCapability("nonExisting"),
45 const c.InstanceInvokeMetaCapability(C)); 46 const c.InstanceInvokeMetaCapability(C),
47 c.declarationsCapability);
46 } 48 }
47 49
48 @MyReflectableInstance() 50 @MyReflectableInstance()
49 class B { 51 class B {
50 int foo() => 42; 52 int foo() => 42;
51 int bar() => 43; 53 int bar() => 43;
52 int get getFoo => 44; 54 int get getFoo => 44;
53 int get getBar => 45; 55 int get getBar => 45;
54 set setFoo(int x) => field = x; 56 set setFoo(int x) => field = x;
55 set setBar(int x) => field = x; 57 set setBar(int x) => field = x;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 }); 145 });
144 146
145 test("Can't reflect unnanotated", () { 147 test("Can't reflect unnanotated", () {
146 expect(() { 148 expect(() {
147 expect(const MyReflectableInstance().canReflect(new Object()), false); 149 expect(const MyReflectableInstance().canReflect(new Object()), false);
148 expect(const MyReflectableInstance().canReflectType(Object), false); 150 expect(const MyReflectableInstance().canReflectType(Object), false);
149 const MyReflectableInstance().reflect(new Object()); 151 const MyReflectableInstance().reflect(new Object());
150 }, throwsNoSuchCapabilityError); 152 }, throwsNoSuchCapabilityError);
151 }); 153 });
152 } 154 }
OLDNEW
« no previous file with comments | « test_reflectable/test/basic_test.dart ('k') | test_reflectable/test/declarations_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698