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

Side by Side Diff: tests/lib_strong/mirrors/field_metadata_test.dart

Issue 2986673002: Fix getSetterType in presence of metadata (Closed)
Patch Set: Rebase Created 3 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 | « pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart ('k') | no next file » | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:mirrors'; 5 import 'dart:mirrors';
6 import 'package:expect/expect.dart'; 6 import 'package:expect/expect.dart';
7 7
8 class Bar { 8 class Bar {
9 final String name; 9 final String name;
10 10
11 const Bar(this.name); 11 const Bar(this.name);
12 } 12 }
13 13
14 class Foo { 14 class Foo {
15 @Bar('bar') 15 @Bar('bar')
16 int x = 40; 16 int x = 40;
17 17
18 @Bar('baz') 18 @Bar('baz')
19 final String y = 'hi'; 19 final String y = 'hi';
20
21 @Bar('foo')
22 void set z(int val) {
23 x = val;
24 }
20 } 25 }
21 26
22 void main() { 27 void main() {
23 dynamic f = new Foo(); 28 dynamic f = new Foo();
24 Expect.throws(() { 29 Expect.throws(() {
25 f.x = 'hello'; 30 f.x = 'hello';
26 }); 31 });
27 f.x += 2; 32 f.x += 2;
28 Expect.equals(f.x, 42); 33 Expect.equals(f.x, 42);
29 Expect.equals(f.y, 'hi'); 34 Expect.equals(f.y, 'hi');
30 35
36 Expect.throws(() {
37 f.z = 'hello';
38 });
39 f.z = 0;
40 Expect.equals(f.x, 0);
41
31 var members = reflect(f).type.declarations; 42 var members = reflect(f).type.declarations;
32 var x = members[#x] as VariableMirror; 43 var x = members[#x] as VariableMirror;
33 var y = members[#y] as VariableMirror; 44 var y = members[#y] as VariableMirror;
34 Expect.equals(x.type.simpleName, #int); 45 Expect.equals(x.type.simpleName, #int);
35 Expect.equals(y.type.simpleName, #String); 46 Expect.equals(y.type.simpleName, #String);
36 } 47 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698