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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1616023002: Add named arguments support into constant ASTs. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
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 analyzer.test.src.summary.summary_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 } 1437 }
1438 UnlinkedVariable variable = serializeVariableText(''' 1438 UnlinkedVariable variable = serializeVariableText('''
1439 class C { 1439 class C {
1440 const C.named(); 1440 const C.named();
1441 } 1441 }
1442 const v = const C.named(); 1442 const v = const C.named();
1443 '''); 1443 ''');
1444 _assertUnlinkedConst(variable.constExpr, operators: [ 1444 _assertUnlinkedConst(variable.constExpr, operators: [
1445 UnlinkedConstOperation.invokeConstructor, 1445 UnlinkedConstOperation.invokeConstructor,
1446 ], ints: [ 1446 ], ints: [
1447 0,
1447 0 1448 0
1448 ], strings: [ 1449 ], strings: [
1449 'named' 1450 'named'
1450 ], referenceValidators: [ 1451 ], referenceValidators: [
1451 (TypeRef r) => checkTypeRef(r, null, null, 'C', 1452 (TypeRef r) => checkTypeRef(r, null, null, 'C',
1452 expectedKind: ReferenceKind.classOrEnum) 1453 expectedKind: ReferenceKind.classOrEnum)
1453 ]); 1454 ]);
1454 } 1455 }
1455 1456
1456 test_constExpr_invokeConstructor_named_imported() { 1457 test_constExpr_invokeConstructor_named_imported() {
1457 if (checkAstDerivedData) { 1458 if (checkAstDerivedData) {
1458 // TODO(scheglov) at the moment we cannot link class member references 1459 // TODO(scheglov) at the moment we cannot link class member references
1459 return; 1460 return;
1460 } 1461 }
1461 addNamedSource( 1462 addNamedSource(
1462 '/a.dart', 1463 '/a.dart',
1463 ''' 1464 '''
1464 class C { 1465 class C {
1465 const C.named(); 1466 const C.named();
1466 } 1467 }
1467 '''); 1468 ''');
1468 UnlinkedVariable variable = serializeVariableText(''' 1469 UnlinkedVariable variable = serializeVariableText('''
1469 import 'a.dart'; 1470 import 'a.dart';
1470 const v = const C.named(); 1471 const v = const C.named();
1471 '''); 1472 ''');
1472 _assertUnlinkedConst(variable.constExpr, operators: [ 1473 _assertUnlinkedConst(variable.constExpr, operators: [
1473 UnlinkedConstOperation.invokeConstructor, 1474 UnlinkedConstOperation.invokeConstructor,
1474 ], ints: [ 1475 ], ints: [
1476 0,
1475 0 1477 0
1476 ], strings: [ 1478 ], strings: [
1477 'named' 1479 'named'
1478 ], referenceValidators: [ 1480 ], referenceValidators: [
1479 (TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', 1481 (TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
1480 expectedKind: ReferenceKind.classOrEnum) 1482 expectedKind: ReferenceKind.classOrEnum)
1481 ]); 1483 ]);
1482 } 1484 }
1483 1485
1484 test_constExpr_invokeConstructor_named_imported_withPrefix() { 1486 test_constExpr_invokeConstructor_named_imported_withPrefix() {
1485 addNamedSource( 1487 addNamedSource(
1486 '/a.dart', 1488 '/a.dart',
1487 ''' 1489 '''
1488 class C { 1490 class C {
1489 const C.named(); 1491 const C.named();
1490 } 1492 }
1491 '''); 1493 ''');
1492 UnlinkedVariable variable = serializeVariableText(''' 1494 UnlinkedVariable variable = serializeVariableText('''
1493 import 'a.dart' as p; 1495 import 'a.dart' as p;
1494 const v = const p.C.named(); 1496 const v = const p.C.named();
1495 '''); 1497 ''');
1496 _assertUnlinkedConst(variable.constExpr, operators: [ 1498 _assertUnlinkedConst(variable.constExpr, operators: [
1497 UnlinkedConstOperation.invokeConstructor, 1499 UnlinkedConstOperation.invokeConstructor,
1498 ], ints: [ 1500 ], ints: [
1501 0,
1499 0 1502 0
1500 ], strings: [ 1503 ], strings: [
1501 'named' 1504 'named'
1502 ], referenceValidators: [ 1505 ], referenceValidators: [
1503 (TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', 1506 (TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
1504 expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'p') 1507 expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'p')
1505 ]); 1508 ]);
1506 } 1509 }
1507 1510
1508 test_constExpr_invokeConstructor_unnamed() { 1511 test_constExpr_invokeConstructor_unnamed() {
1509 UnlinkedVariable variable = serializeVariableText(''' 1512 UnlinkedVariable variable = serializeVariableText('''
1510 class C { 1513 class C {
1511 const C(int a, String b); 1514 const C(a, b, c, d, {e, f, g});
1512 } 1515 }
1513 const v = const C(42, 'sss'); 1516 const v = const C(11, 22, 3.3, '444', e: 55, g: '777', f: 66);
1514 '''); 1517 ''');
1518 // Stack: 11 22 3.3 '444' 55 '777' 66 ^head
1519 // Ints: ^pointer 3 4
1520 // Doubles: ^pointer
1521 // Strings: ^pointer 'e' 'g' 'f' ''
1515 _assertUnlinkedConst(variable.constExpr, operators: [ 1522 _assertUnlinkedConst(variable.constExpr, operators: [
1516 UnlinkedConstOperation.pushInt, 1523 UnlinkedConstOperation.pushInt,
1524 UnlinkedConstOperation.pushInt,
1525 UnlinkedConstOperation.pushDouble,
1517 UnlinkedConstOperation.pushString, 1526 UnlinkedConstOperation.pushString,
1527 UnlinkedConstOperation.pushInt,
1528 UnlinkedConstOperation.pushString,
1529 UnlinkedConstOperation.pushInt,
1518 UnlinkedConstOperation.invokeConstructor, 1530 UnlinkedConstOperation.invokeConstructor,
1519 ], ints: [ 1531 ], ints: [
1520 42, 1532 11,
1521 2 1533 22,
1534 55,
1535 66,
1536 3,
1537 4,
1538 ], doubles: [
1539 3.3
1522 ], strings: [ 1540 ], strings: [
1523 'sss', 1541 '444',
1542 '777',
1543 'e',
1544 'g',
1545 'f',
1524 '' 1546 ''
1525 ], referenceValidators: [ 1547 ], referenceValidators: [
1526 (TypeRef r) => checkTypeRef(r, null, null, 'C', 1548 (TypeRef r) => checkTypeRef(r, null, null, 'C',
1527 expectedKind: ReferenceKind.classOrEnum) 1549 expectedKind: ReferenceKind.classOrEnum)
1528 ]); 1550 ]);
1529 } 1551 }
1530 1552
1531 test_constExpr_length() { 1553 test_constExpr_length() {
1532 UnlinkedVariable variable = 1554 UnlinkedVariable variable =
1533 serializeVariableText('const v = "abc".length;'); 1555 serializeVariableText('const v = "abc".length;');
(...skipping 2670 matching lines...) Expand 10 before | Expand all | Expand 10 after
4204 expect(constExpr.operations, operators); 4226 expect(constExpr.operations, operators);
4205 expect(constExpr.ints, ints); 4227 expect(constExpr.ints, ints);
4206 expect(constExpr.doubles, doubles); 4228 expect(constExpr.doubles, doubles);
4207 expect(constExpr.strings, strings); 4229 expect(constExpr.strings, strings);
4208 expect(constExpr.references, hasLength(referenceValidators.length)); 4230 expect(constExpr.references, hasLength(referenceValidators.length));
4209 for (int i = 0; i < referenceValidators.length; i++) { 4231 for (int i = 0; i < referenceValidators.length; i++) {
4210 referenceValidators[i](constExpr.references[i]); 4232 referenceValidators[i](constExpr.references[i]);
4211 } 4233 }
4212 } 4234 }
4213 } 4235 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_const_expr.dart ('k') | pkg/analyzer/tool/summary/idl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698