| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 'package:test/test.dart'; | 5 import 'package:test/test.dart'; |
| 6 | 6 |
| 7 import 'helper.dart' show check; | 7 import 'helper.dart' show check; |
| 8 | 8 |
| 9 main() { | 9 main() { |
| 10 group('compile getters with kernel', () { | 10 group('compile getters with kernel', () { |
| 11 test('top-level', () { | 11 test('top-level', () { |
| 12 String code = ''' | 12 String code = ''' |
| 13 int get foo => 1; | 13 int get foo => 1; |
| 14 main() => foo; | 14 main() => foo; |
| 15 '''; | 15 '''; |
| 16 return check(code); | 16 return check(code); |
| 17 }); | 17 }); |
| 18 | 18 |
| 19 test('static', () { | 19 test('static', () { |
| 20 String code = ''' | 20 String code = ''' |
| 21 class A { | 21 class A { |
| 22 static int get foo => 1; | 22 static int get foo => 1; |
| 23 } | 23 } |
| 24 main() => A.foo; | 24 main() => A.foo; |
| 25 '''; | 25 '''; |
| 26 return check(code); | 26 return check(code); |
| 27 }); | 27 }); |
| 28 |
| 29 test('super get', () { |
| 30 String code = ''' |
| 31 class A { |
| 32 int get foo => 1; |
| 33 } |
| 34 |
| 35 class B extends A { |
| 36 |
| 37 int get rotations => super.foo * 3; |
| 38 } |
| 39 |
| 40 main() => new B().foo; |
| 41 '''; |
| 42 return check(code); |
| 43 }); |
| 44 |
| 45 test('super get no such method', () { |
| 46 String code = ''' |
| 47 class A { |
| 48 static int get foo => 1; |
| 49 } |
| 50 |
| 51 class B extends A { |
| 52 |
| 53 int get rotations => super.nothing * 3; |
| 54 } |
| 55 |
| 56 main() => new B().foo; |
| 57 '''; |
| 58 return check(code); |
| 59 }); |
| 60 |
| 28 }); | 61 }); |
| 29 | 62 |
| 30 group('compile setters with kernel', () { | 63 group('compile setters with kernel', () { |
| 31 test('top-level', () { | 64 test('top-level', () { |
| 32 String code = ''' | 65 String code = ''' |
| 33 set foo(int newFoo) { | 66 set foo(int newFoo) { |
| 34 // do nothing | 67 // do nothing |
| 35 } | 68 } |
| 36 main() { | 69 main() { |
| 37 foo = 1; | 70 foo = 1; |
| 38 }'''; | 71 }'''; |
| 39 return check(code); | 72 return check(code); |
| 40 }); | 73 }); |
| 41 | 74 |
| 42 test('static', () { | 75 test('static', () { |
| 43 String code = ''' | 76 String code = ''' |
| 44 class A { | 77 class A { |
| 45 static set foo(int newFoo) { | 78 static set foo(int newFoo) { |
| 46 // do nothing | 79 // do nothing |
| 47 } | 80 } |
| 48 } | 81 } |
| 49 main() { | 82 main() { |
| 50 A.foo = 1; | 83 A.foo = 1; |
| 51 } | 84 } |
| 52 '''; | 85 '''; |
| 53 return check(code); | 86 return check(code); |
| 54 }); | 87 }); |
| 55 }); | 88 }); |
| 89 |
| 90 test('super set', () { |
| 91 String code = ''' |
| 92 class A { |
| 93 set ferocious(int newFerocious) {} |
| 56 } | 94 } |
| 95 |
| 96 class B extends A { |
| 97 bar() { |
| 98 super.ferocious = 87; |
| 99 } |
| 100 } |
| 101 main() { |
| 102 new B().bar(); |
| 103 }'''; |
| 104 return check(code); |
| 105 }); |
| 106 |
| 107 test('super set no such method', () { |
| 108 String code = ''' |
| 109 class A { |
| 110 final ferocious = 0; |
| 111 noSuchMethod(_) => 42; |
| 112 } |
| 113 |
| 114 class B extends A { |
| 115 bar() { |
| 116 super.ferocious = 87; |
| 117 } |
| 118 } |
| 119 main() { |
| 120 new B().bar(); |
| 121 }'''; |
| 122 return check(code); |
| 123 }); |
| 124 } |
| OLD | NEW |