OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Unit test of the [NativeBehavior.processSpecString] method. | 5 // Unit test of the [NativeBehavior.processSpecString] method. |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import 'package:compiler/src/native/native.dart'; | 8 import 'package:compiler/src/native/native.dart'; |
9 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; | 9 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; |
| 10 import 'package:compiler/src/diagnostics/messages.dart'; |
10 import 'package:compiler/src/universe/side_effects.dart' | 11 import 'package:compiler/src/universe/side_effects.dart' |
11 show SideEffects; | 12 show SideEffects; |
12 | 13 |
13 const OBJECT = 'Object'; | 14 const OBJECT = 'Object'; |
14 const NULL = 'Null'; | 15 const NULL = 'Null'; |
15 | 16 |
16 class Listener implements DiagnosticListener { | 17 class Listener extends DiagnosticListener { |
17 String errorMessage; | 18 String errorMessage; |
18 internalError(spannable, message) { | 19 internalError(spannable, message) { |
19 errorMessage = message; | 20 errorMessage = message; |
20 throw "error"; | 21 throw "error"; |
21 } | 22 } |
22 reportError(spannable, kind, [arguments]) { | 23 reportError(message, [infos]) { |
23 errorMessage = '$arguments'; // E.g. "{text: Duplicate tag 'new'.}" | 24 |
| 25 errorMessage = |
| 26 '${message.message.arguments}'; // E.g. "{text: Duplicate tag 'new'.}" |
24 throw "error"; | 27 throw "error"; |
25 } | 28 } |
26 | 29 |
| 30 @override |
| 31 DiagnosticMessage createMessage(spannable, messageKind, [arguments]) { |
| 32 return new DiagnosticMessage(null, spannable, |
| 33 MessageTemplate.TEMPLATES[messageKind].message(arguments)); |
| 34 } |
| 35 |
27 noSuchMethod(_) => null; | 36 noSuchMethod(_) => null; |
28 } | 37 } |
29 | 38 |
30 void test(String specString, | 39 void test(String specString, |
31 {List returns, | 40 {List returns, |
32 List creates, | 41 List creates, |
33 SideEffects expectedSideEffects, | 42 SideEffects expectedSideEffects, |
34 NativeThrowBehavior expectedThrows, | 43 NativeThrowBehavior expectedThrows, |
35 bool expectedNew, | 44 bool expectedNew, |
36 bool expectedGvn, | 45 bool expectedGvn, |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 test('gvn:false', expectedGvn: false); | 284 test('gvn:false', expectedGvn: false); |
276 test('returns:A;gvn:true', returns: ['A'], expectedGvn: true); | 285 test('returns:A;gvn:true', returns: ['A'], expectedGvn: true); |
277 test(' gvn : true ; returns:A;', returns: ['A'], expectedGvn: true); | 286 test(' gvn : true ; returns:A;', returns: ['A'], expectedGvn: true); |
278 test('gvn:true;returns:A;gvn:true', expectError: true); | 287 test('gvn:true;returns:A;gvn:true', expectError: true); |
279 | 288 |
280 test('gvn: true; new: true', expectError: true); | 289 test('gvn: true; new: true', expectError: true); |
281 test('gvn: true; new: false', expectedGvn: true, expectedNew: false); | 290 test('gvn: true; new: false', expectedGvn: true, expectedNew: false); |
282 test('gvn: false; new: true', expectedGvn: false, expectedNew: true); | 291 test('gvn: false; new: true', expectedGvn: false, expectedNew: true); |
283 test('gvn: false; new: false', expectedGvn: false, expectedNew: false); | 292 test('gvn: false; new: false', expectedGvn: false, expectedNew: false); |
284 } | 293 } |
OLD | NEW |