Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.src.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/constant/value.dart'; | 9 import 'package:analyzer/dart/constant/value.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 compareConstAsts(r, o.propertyName, desc); | 466 compareConstAsts(r, o.propertyName, desc); |
| 467 } else if (o is SuperExpression && r is SuperExpression) { | 467 } else if (o is SuperExpression && r is SuperExpression) { |
| 468 // Nothing to compare. | 468 // Nothing to compare. |
| 469 } else if (o is ThisExpression && r is ThisExpression) { | 469 } else if (o is ThisExpression && r is ThisExpression) { |
| 470 // Nothing to compare. | 470 // Nothing to compare. |
| 471 } else if (o is NullLiteral) { | 471 } else if (o is NullLiteral) { |
| 472 expect(r, new isInstanceOf<NullLiteral>(), reason: desc); | 472 expect(r, new isInstanceOf<NullLiteral>(), reason: desc); |
| 473 } else if (o is BooleanLiteral && r is BooleanLiteral) { | 473 } else if (o is BooleanLiteral && r is BooleanLiteral) { |
| 474 expect(r.value, o.value, reason: desc); | 474 expect(r.value, o.value, reason: desc); |
| 475 } else if (o is IntegerLiteral && r is IntegerLiteral) { | 475 } else if (o is IntegerLiteral && r is IntegerLiteral) { |
| 476 expect(r.value, o.value, reason: desc); | 476 expect(r.value ?? 0, o.value ?? 0, reason: desc); |
| 477 } else if (o is DoubleLiteral && r is DoubleLiteral) { | 477 } else if (o is DoubleLiteral && r is DoubleLiteral) { |
| 478 if (r.value != null && | 478 if (r.value != null && |
| 479 r.value.isNaN && | 479 r.value.isNaN && |
| 480 o.value != null && | 480 o.value != null && |
| 481 o.value.isNaN) { | 481 o.value.isNaN) { |
| 482 // NaN is not comparable. | 482 // NaN is not comparable. |
| 483 } else { | 483 } else { |
| 484 expect(r.value, o.value, reason: desc); | 484 expect(r.value, o.value, reason: desc); |
| 485 } | 485 } |
| 486 } else if (o is StringInterpolation && r is StringInterpolation) { | 486 } else if (o is StringInterpolation && r is StringInterpolation) { |
| (...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3286 r''' | 3286 r''' |
| 3287 class C { | 3287 class C { |
| 3288 final dynamic f = | 3288 final dynamic f = |
| 3289 $$invalidConstExpr$$/*location: null*/; | 3289 $$invalidConstExpr$$/*location: null*/; |
| 3290 } | 3290 } |
| 3291 int foo() {} | 3291 int foo() {} |
| 3292 '''); | 3292 '''); |
| 3293 } | 3293 } |
| 3294 } | 3294 } |
| 3295 | 3295 |
| 3296 test_const_invalid_intLiteral() { | |
| 3297 var library = checkLibrary( | |
| 3298 r''' | |
| 3299 const int x = 0x; | |
| 3300 ''', | |
| 3301 allowErrors: true); | |
| 3302 if (isStrongMode) { | |
| 3303 checkElementText( | |
| 3304 library, | |
| 3305 r''' | |
| 3306 const int x = 0; | |
| 3307 '''); | |
| 3308 } else { | |
| 3309 checkElementText( | |
| 3310 library, | |
| 3311 r''' | |
| 3312 const int x = 0; | |
|
scheglov
2017/05/30 17:25:18
I don't think we do this for all the tests, but in
Brian Wilkerson
2017/05/30 17:38:45
Done
| |
| 3313 '''); | |
| 3314 } | |
| 3315 } | |
| 3316 | |
| 3296 test_const_invalid_topLevel() { | 3317 test_const_invalid_topLevel() { |
| 3297 variablesWithNotConstInitializers.add('v'); | 3318 variablesWithNotConstInitializers.add('v'); |
| 3298 var library = checkLibrary( | 3319 var library = checkLibrary( |
| 3299 r''' | 3320 r''' |
| 3300 const v = 1 + foo(); | 3321 const v = 1 + foo(); |
| 3301 int foo() => 42; | 3322 int foo() => 42; |
| 3302 ''', | 3323 ''', |
| 3303 allowErrors: true); | 3324 allowErrors: true); |
| 3304 if (isStrongMode) { | 3325 if (isStrongMode) { |
| 3305 checkElementText( | 3326 checkElementText( |
| (...skipping 11985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15291 fail('Unexpectedly tried to get unlinked summary for $uri'); | 15312 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 15292 } | 15313 } |
| 15293 return serializedUnit; | 15314 return serializedUnit; |
| 15294 } | 15315 } |
| 15295 | 15316 |
| 15296 @override | 15317 @override |
| 15297 bool hasLibrarySummary(String uri) { | 15318 bool hasLibrarySummary(String uri) { |
| 15298 return true; | 15319 return true; |
| 15299 } | 15320 } |
| 15300 } | 15321 } |
| OLD | NEW |