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

Side by Side Diff: pkg/analyzer/test/generated/ast_test.dart

Issue 186153005: New analzyer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use meaningful name instead of '_' in predicate. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/pubspec.yaml ('k') | pkg/analyzer/test/generated/element_test.dart » ('j') | 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) 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.ast_test; 8 library engine.ast_test;
9 9
10 import 'package:analyzer/src/generated/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
11 import 'package:analyzer/src/generated/java_engine.dart';
11 import 'package:analyzer/src/generated/java_junit.dart'; 12 import 'package:analyzer/src/generated/java_junit.dart';
13 import 'package:analyzer/src/generated/java_engine.dart' show Predicate;
12 import 'package:analyzer/src/generated/scanner.dart'; 14 import 'package:analyzer/src/generated/scanner.dart';
13 import 'package:analyzer/src/generated/ast.dart'; 15 import 'package:analyzer/src/generated/ast.dart';
14 import 'package:analyzer/src/generated/utilities_dart.dart'; 16 import 'package:analyzer/src/generated/utilities_dart.dart';
15 import 'package:analyzer/src/generated/element.dart' show ClassElement; 17 import 'package:analyzer/src/generated/element.dart' show ClassElement;
16 import 'package:unittest/unittest.dart' as _ut; 18 import 'package:unittest/unittest.dart' as _ut;
17 import 'parser_test.dart' show ParserTestCase; 19 import 'parser_test.dart' show ParserTestCase;
18 import 'test_support.dart'; 20 import 'test_support.dart';
19 import 'scanner_test.dart' show TokenFactory; 21 import 'scanner_test.dart' show TokenFactory;
20 22
21 class NodeLocatorTest extends ParserTestCase { 23 class NodeLocatorTest extends ParserTestCase {
22 void test_range() { 24 void test_range() {
23 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []); 25 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []);
24 assertLocate2(unit, 4, 10, LibraryDirective); 26 assertLocate(unit, 4, 10, (node) => node is LibraryDirective, LibraryDirecti ve);
25 } 27 }
26 28
27 void test_searchWithin_null() { 29 void test_searchWithin_null() {
28 NodeLocator locator = new NodeLocator.con2(0, 0); 30 NodeLocator locator = new NodeLocator.con2(0, 0);
29 JUnitTestCase.assertNull(locator.searchWithin(null)); 31 JUnitTestCase.assertNull(locator.searchWithin(null));
30 } 32 }
31 33
32 void test_searchWithin_offset() { 34 void test_searchWithin_offset() {
33 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []); 35 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []);
34 assertLocate(unit, 10, SimpleIdentifier); 36 assertLocate(unit, 10, 10, (node) => node is SimpleIdentifier, SimpleIdentif ier);
35 } 37 }
36 38
37 void test_searchWithin_offsetAfterNode() { 39 void test_searchWithin_offsetAfterNode() {
38 CompilationUnit unit = ParserTestCase.parseCompilationUnit(EngineTestCase.cr eateSource(["class A {}", "class B {}"]), []); 40 CompilationUnit unit = ParserTestCase.parseCompilationUnit(EngineTestCase.cr eateSource(["class A {}", "class B {}"]), []);
39 NodeLocator locator = new NodeLocator.con2(1024, 1024); 41 NodeLocator locator = new NodeLocator.con2(1024, 1024);
40 AstNode node = locator.searchWithin(unit.declarations[0]); 42 AstNode node = locator.searchWithin(unit.declarations[0]);
41 JUnitTestCase.assertNull(node); 43 JUnitTestCase.assertNull(node);
42 } 44 }
43 45
44 void test_searchWithin_offsetBeforeNode() { 46 void test_searchWithin_offsetBeforeNode() {
45 CompilationUnit unit = ParserTestCase.parseCompilationUnit(EngineTestCase.cr eateSource(["class A {}", "class B {}"]), []); 47 CompilationUnit unit = ParserTestCase.parseCompilationUnit(EngineTestCase.cr eateSource(["class A {}", "class B {}"]), []);
46 NodeLocator locator = new NodeLocator.con2(0, 0); 48 NodeLocator locator = new NodeLocator.con2(0, 0);
47 AstNode node = locator.searchWithin(unit.declarations[1]); 49 AstNode node = locator.searchWithin(unit.declarations[1]);
48 JUnitTestCase.assertNull(node); 50 JUnitTestCase.assertNull(node);
49 } 51 }
50 52
51 void assertLocate(CompilationUnit unit, int offset, Type expectedClass) { 53 void assertLocate(CompilationUnit unit, int start, int end, Predicate<AstNode> predicate, Type expectedClass) {
52 assertLocate2(unit, offset, offset, expectedClass);
53 }
54
55 void assertLocate2(CompilationUnit unit, int start, int end, Type expectedClas s) {
56 NodeLocator locator = new NodeLocator.con2(start, end); 54 NodeLocator locator = new NodeLocator.con2(start, end);
57 AstNode node = locator.searchWithin(unit); 55 AstNode node = locator.searchWithin(unit);
58 JUnitTestCase.assertNotNull(node); 56 JUnitTestCase.assertNotNull(node);
59 JUnitTestCase.assertSame(node, locator.foundNode); 57 JUnitTestCase.assertSame(node, locator.foundNode);
60 JUnitTestCase.assertTrueMsg("Node starts after range", node.offset <= start) ; 58 JUnitTestCase.assertTrueMsg("Node starts after range", node.offset <= start) ;
61 JUnitTestCase.assertTrueMsg("Node ends before range", node.offset + node.len gth > end); 59 JUnitTestCase.assertTrueMsg("Node ends before range", node.offset + node.len gth > end);
62 EngineTestCase.assertInstanceOf(expectedClass, node); 60 EngineTestCase.assertInstanceOf(predicate, expectedClass, node);
63 } 61 }
64 62
65 static dartSuite() { 63 static dartSuite() {
66 _ut.group('NodeLocatorTest', () { 64 _ut.group('NodeLocatorTest', () {
67 _ut.test('test_range', () { 65 _ut.test('test_range', () {
68 final __test = new NodeLocatorTest(); 66 final __test = new NodeLocatorTest();
69 runJUnitTest(__test, __test.test_range); 67 runJUnitTest(__test, __test.test_range);
70 }); 68 });
71 _ut.test('test_searchWithin_null', () { 69 _ut.test('test_searchWithin_null', () {
72 final __test = new NodeLocatorTest(); 70 final __test = new NodeLocatorTest();
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 " return p;", 1076 " return p;",
1079 " } else {", 1077 " } else {",
1080 " return null;", 1078 " return null;",
1081 " }", 1079 " }",
1082 "}"]); 1080 "}"]);
1083 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source, []); 1081 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source, []);
1084 List<AstNode> nodes = new List<AstNode>(); 1082 List<AstNode> nodes = new List<AstNode>();
1085 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_BreadthFirstVi sitorTest_testIt(nodes); 1083 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_BreadthFirstVi sitorTest_testIt(nodes);
1086 visitor.visitAllNodes(unit); 1084 visitor.visitAllNodes(unit);
1087 EngineTestCase.assertSize(59, nodes); 1085 EngineTestCase.assertSize(59, nodes);
1088 EngineTestCase.assertInstanceOf(CompilationUnit, nodes[0]); 1086 EngineTestCase.assertInstanceOf((obj) => obj is CompilationUnit, Compilation Unit, nodes[0]);
1089 EngineTestCase.assertInstanceOf(ClassDeclaration, nodes[2]); 1087 EngineTestCase.assertInstanceOf((obj) => obj is ClassDeclaration, ClassDecla ration, nodes[2]);
1090 EngineTestCase.assertInstanceOf(FunctionDeclaration, nodes[3]); 1088 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclaration, Functio nDeclaration, nodes[3]);
1091 EngineTestCase.assertInstanceOf(FunctionDeclarationStatement, nodes[27]); 1089 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclarationStatement , FunctionDeclarationStatement, nodes[27]);
1092 EngineTestCase.assertInstanceOf(IntegerLiteral, nodes[58]); 1090 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter al, nodes[58]);
1093 } 1091 }
1094 1092
1095 static dartSuite() { 1093 static dartSuite() {
1096 _ut.group('BreadthFirstVisitorTest', () { 1094 _ut.group('BreadthFirstVisitorTest', () {
1097 _ut.test('testIt', () { 1095 _ut.test('testIt', () {
1098 final __test = new BreadthFirstVisitorTest(); 1096 final __test = new BreadthFirstVisitorTest();
1099 runJUnitTest(__test, __test.testIt); 1097 runJUnitTest(__test, __test.testIt);
1100 }); 1098 });
1101 }); 1099 });
1102 } 1100 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 JUnitTestCase.assertEquals(null, value); 1448 JUnitTestCase.assertEquals(null, value);
1451 } 1449 }
1452 1450
1453 void fail_identifier_typeParameter() { 1451 void fail_identifier_typeParameter() {
1454 Object value = getConstantValue("?"); 1452 Object value = getConstantValue("?");
1455 JUnitTestCase.assertEquals(null, value); 1453 JUnitTestCase.assertEquals(null, value);
1456 } 1454 }
1457 1455
1458 void test_binary_bitAnd() { 1456 void test_binary_bitAnd() {
1459 Object value = getConstantValue("74 & 42"); 1457 Object value = getConstantValue("74 & 42");
1460 EngineTestCase.assertInstanceOf(int, value); 1458 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1461 JUnitTestCase.assertEquals(74 & 42, value as int); 1459 JUnitTestCase.assertEquals(74 & 42, value as int);
1462 } 1460 }
1463 1461
1464 void test_binary_bitOr() { 1462 void test_binary_bitOr() {
1465 Object value = getConstantValue("74 | 42"); 1463 Object value = getConstantValue("74 | 42");
1466 EngineTestCase.assertInstanceOf(int, value); 1464 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1467 JUnitTestCase.assertEquals(74 | 42, value as int); 1465 JUnitTestCase.assertEquals(74 | 42, value as int);
1468 } 1466 }
1469 1467
1470 void test_binary_bitXor() { 1468 void test_binary_bitXor() {
1471 Object value = getConstantValue("74 ^ 42"); 1469 Object value = getConstantValue("74 ^ 42");
1472 EngineTestCase.assertInstanceOf(int, value); 1470 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1473 JUnitTestCase.assertEquals(74 ^ 42, value as int); 1471 JUnitTestCase.assertEquals(74 ^ 42, value as int);
1474 } 1472 }
1475 1473
1476 void test_binary_divide_double() { 1474 void test_binary_divide_double() {
1477 Object value = getConstantValue("3.2 / 2.3"); 1475 Object value = getConstantValue("3.2 / 2.3");
1478 EngineTestCase.assertInstanceOf(double, value); 1476 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
1479 JUnitTestCase.assertEquals(3.2 / 2.3, value as double); 1477 JUnitTestCase.assertEquals(3.2 / 2.3, value as double);
1480 } 1478 }
1481 1479
1482 void test_binary_divide_integer() { 1480 void test_binary_divide_integer() {
1483 Object value = getConstantValue("3 / 2"); 1481 Object value = getConstantValue("3 / 2");
1484 EngineTestCase.assertInstanceOf(int, value); 1482 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1485 JUnitTestCase.assertEquals(1, value as int); 1483 JUnitTestCase.assertEquals(1, value as int);
1486 } 1484 }
1487 1485
1488 void test_binary_equal_boolean() { 1486 void test_binary_equal_boolean() {
1489 Object value = getConstantValue("true == false"); 1487 Object value = getConstantValue("true == false");
1490 JUnitTestCase.assertEquals(false, value); 1488 JUnitTestCase.assertEquals(false, value);
1491 } 1489 }
1492 1490
1493 void test_binary_equal_integer() { 1491 void test_binary_equal_integer() {
1494 Object value = getConstantValue("2 == 3"); 1492 Object value = getConstantValue("2 == 3");
(...skipping 20 matching lines...) Expand all
1515 JUnitTestCase.assertEquals(false, value); 1513 JUnitTestCase.assertEquals(false, value);
1516 } 1514 }
1517 1515
1518 void test_binary_greaterThanOrEqual() { 1516 void test_binary_greaterThanOrEqual() {
1519 Object value = getConstantValue("2 >= 3"); 1517 Object value = getConstantValue("2 >= 3");
1520 JUnitTestCase.assertEquals(false, value); 1518 JUnitTestCase.assertEquals(false, value);
1521 } 1519 }
1522 1520
1523 void test_binary_leftShift() { 1521 void test_binary_leftShift() {
1524 Object value = getConstantValue("16 << 2"); 1522 Object value = getConstantValue("16 << 2");
1525 EngineTestCase.assertInstanceOf(int, value); 1523 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1526 JUnitTestCase.assertEquals(64, value as int); 1524 JUnitTestCase.assertEquals(64, value as int);
1527 } 1525 }
1528 1526
1529 void test_binary_lessThan() { 1527 void test_binary_lessThan() {
1530 Object value = getConstantValue("2 < 3"); 1528 Object value = getConstantValue("2 < 3");
1531 JUnitTestCase.assertEquals(true, value); 1529 JUnitTestCase.assertEquals(true, value);
1532 } 1530 }
1533 1531
1534 void test_binary_lessThanOrEqual() { 1532 void test_binary_lessThanOrEqual() {
1535 Object value = getConstantValue("2 <= 3"); 1533 Object value = getConstantValue("2 <= 3");
1536 JUnitTestCase.assertEquals(true, value); 1534 JUnitTestCase.assertEquals(true, value);
1537 } 1535 }
1538 1536
1539 void test_binary_logicalAnd() { 1537 void test_binary_logicalAnd() {
1540 Object value = getConstantValue("true && false"); 1538 Object value = getConstantValue("true && false");
1541 JUnitTestCase.assertEquals(false, value); 1539 JUnitTestCase.assertEquals(false, value);
1542 } 1540 }
1543 1541
1544 void test_binary_logicalOr() { 1542 void test_binary_logicalOr() {
1545 Object value = getConstantValue("true || false"); 1543 Object value = getConstantValue("true || false");
1546 JUnitTestCase.assertEquals(true, value); 1544 JUnitTestCase.assertEquals(true, value);
1547 } 1545 }
1548 1546
1549 void test_binary_minus_double() { 1547 void test_binary_minus_double() {
1550 Object value = getConstantValue("3.2 - 2.3"); 1548 Object value = getConstantValue("3.2 - 2.3");
1551 EngineTestCase.assertInstanceOf(double, value); 1549 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
1552 JUnitTestCase.assertEquals(3.2 - 2.3, value as double); 1550 JUnitTestCase.assertEquals(3.2 - 2.3, value as double);
1553 } 1551 }
1554 1552
1555 void test_binary_minus_integer() { 1553 void test_binary_minus_integer() {
1556 Object value = getConstantValue("3 - 2"); 1554 Object value = getConstantValue("3 - 2");
1557 EngineTestCase.assertInstanceOf(int, value); 1555 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1558 JUnitTestCase.assertEquals(1, value as int); 1556 JUnitTestCase.assertEquals(1, value as int);
1559 } 1557 }
1560 1558
1561 void test_binary_notEqual_boolean() { 1559 void test_binary_notEqual_boolean() {
1562 Object value = getConstantValue("true != false"); 1560 Object value = getConstantValue("true != false");
1563 JUnitTestCase.assertEquals(true, value); 1561 JUnitTestCase.assertEquals(true, value);
1564 } 1562 }
1565 1563
1566 void test_binary_notEqual_integer() { 1564 void test_binary_notEqual_integer() {
1567 Object value = getConstantValue("2 != 3"); 1565 Object value = getConstantValue("2 != 3");
(...skipping 10 matching lines...) Expand all
1578 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); 1576 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value);
1579 } 1577 }
1580 1578
1581 void test_binary_notEqual_string() { 1579 void test_binary_notEqual_string() {
1582 Object value = getConstantValue("'a' != 'b'"); 1580 Object value = getConstantValue("'a' != 'b'");
1583 JUnitTestCase.assertEquals(true, value); 1581 JUnitTestCase.assertEquals(true, value);
1584 } 1582 }
1585 1583
1586 void test_binary_plus_double() { 1584 void test_binary_plus_double() {
1587 Object value = getConstantValue("2.3 + 3.2"); 1585 Object value = getConstantValue("2.3 + 3.2");
1588 EngineTestCase.assertInstanceOf(double, value); 1586 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
1589 JUnitTestCase.assertEquals(2.3 + 3.2, value as double); 1587 JUnitTestCase.assertEquals(2.3 + 3.2, value as double);
1590 } 1588 }
1591 1589
1592 void test_binary_plus_integer() { 1590 void test_binary_plus_integer() {
1593 Object value = getConstantValue("2 + 3"); 1591 Object value = getConstantValue("2 + 3");
1594 EngineTestCase.assertInstanceOf(int, value); 1592 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1595 JUnitTestCase.assertEquals(5, value as int); 1593 JUnitTestCase.assertEquals(5, value as int);
1596 } 1594 }
1597 1595
1598 void test_binary_remainder_double() { 1596 void test_binary_remainder_double() {
1599 Object value = getConstantValue("3.2 % 2.3"); 1597 Object value = getConstantValue("3.2 % 2.3");
1600 EngineTestCase.assertInstanceOf(double, value); 1598 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
1601 JUnitTestCase.assertEquals(3.2 % 2.3, value as double); 1599 JUnitTestCase.assertEquals(3.2 % 2.3, value as double);
1602 } 1600 }
1603 1601
1604 void test_binary_remainder_integer() { 1602 void test_binary_remainder_integer() {
1605 Object value = getConstantValue("8 % 3"); 1603 Object value = getConstantValue("8 % 3");
1606 EngineTestCase.assertInstanceOf(int, value); 1604 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1607 JUnitTestCase.assertEquals(2, value as int); 1605 JUnitTestCase.assertEquals(2, value as int);
1608 } 1606 }
1609 1607
1610 void test_binary_rightShift() { 1608 void test_binary_rightShift() {
1611 Object value = getConstantValue("64 >> 2"); 1609 Object value = getConstantValue("64 >> 2");
1612 EngineTestCase.assertInstanceOf(int, value); 1610 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1613 JUnitTestCase.assertEquals(16, value as int); 1611 JUnitTestCase.assertEquals(16, value as int);
1614 } 1612 }
1615 1613
1616 void test_binary_times_double() { 1614 void test_binary_times_double() {
1617 Object value = getConstantValue("2.3 * 3.2"); 1615 Object value = getConstantValue("2.3 * 3.2");
1618 EngineTestCase.assertInstanceOf(double, value); 1616 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
1619 JUnitTestCase.assertEquals(2.3 * 3.2, value as double); 1617 JUnitTestCase.assertEquals(2.3 * 3.2, value as double);
1620 } 1618 }
1621 1619
1622 void test_binary_times_integer() { 1620 void test_binary_times_integer() {
1623 Object value = getConstantValue("2 * 3"); 1621 Object value = getConstantValue("2 * 3");
1624 EngineTestCase.assertInstanceOf(int, value); 1622 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1625 JUnitTestCase.assertEquals(6, value as int); 1623 JUnitTestCase.assertEquals(6, value as int);
1626 } 1624 }
1627 1625
1628 void test_binary_truncatingDivide_double() { 1626 void test_binary_truncatingDivide_double() {
1629 Object value = getConstantValue("3.2 ~/ 2.3"); 1627 Object value = getConstantValue("3.2 ~/ 2.3");
1630 EngineTestCase.assertInstanceOf(int, value); 1628 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1631 JUnitTestCase.assertEquals(1, value as int); 1629 JUnitTestCase.assertEquals(1, value as int);
1632 } 1630 }
1633 1631
1634 void test_binary_truncatingDivide_integer() { 1632 void test_binary_truncatingDivide_integer() {
1635 Object value = getConstantValue("10 ~/ 3"); 1633 Object value = getConstantValue("10 ~/ 3");
1636 EngineTestCase.assertInstanceOf(int, value); 1634 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1637 JUnitTestCase.assertEquals(3, value as int); 1635 JUnitTestCase.assertEquals(3, value as int);
1638 } 1636 }
1639 1637
1640 void test_literal_boolean_false() { 1638 void test_literal_boolean_false() {
1641 Object value = getConstantValue("false"); 1639 Object value = getConstantValue("false");
1642 JUnitTestCase.assertEquals(false, value); 1640 JUnitTestCase.assertEquals(false, value);
1643 } 1641 }
1644 1642
1645 void test_literal_boolean_true() { 1643 void test_literal_boolean_true() {
1646 Object value = getConstantValue("true"); 1644 Object value = getConstantValue("true");
1647 JUnitTestCase.assertEquals(true, value); 1645 JUnitTestCase.assertEquals(true, value);
1648 } 1646 }
1649 1647
1650 void test_literal_list() { 1648 void test_literal_list() {
1651 Object value = getConstantValue("['a', 'b', 'c']"); 1649 Object value = getConstantValue("['a', 'b', 'c']");
1652 EngineTestCase.assertInstanceOf(List, value); 1650 EngineTestCase.assertInstanceOf((obj) => obj is List, List, value);
1653 List list = value as List; 1651 List list = value as List;
1654 JUnitTestCase.assertEquals(3, list.length); 1652 JUnitTestCase.assertEquals(3, list.length);
1655 JUnitTestCase.assertEquals("a", list[0]); 1653 JUnitTestCase.assertEquals("a", list[0]);
1656 JUnitTestCase.assertEquals("b", list[1]); 1654 JUnitTestCase.assertEquals("b", list[1]);
1657 JUnitTestCase.assertEquals("c", list[2]); 1655 JUnitTestCase.assertEquals("c", list[2]);
1658 } 1656 }
1659 1657
1660 void test_literal_map() { 1658 void test_literal_map() {
1661 Object value = getConstantValue("{'a' : 'm', 'b' : 'n', 'c' : 'o'}"); 1659 Object value = getConstantValue("{'a' : 'm', 'b' : 'n', 'c' : 'o'}");
1662 EngineTestCase.assertInstanceOf(Map, value); 1660 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, value);
1663 Map map = value as Map; 1661 Map map = value as Map;
1664 JUnitTestCase.assertEquals(3, map.length); 1662 JUnitTestCase.assertEquals(3, map.length);
1665 JUnitTestCase.assertEquals("m", map["a"]); 1663 JUnitTestCase.assertEquals("m", map["a"]);
1666 JUnitTestCase.assertEquals("n", map["b"]); 1664 JUnitTestCase.assertEquals("n", map["b"]);
1667 JUnitTestCase.assertEquals("o", map["c"]); 1665 JUnitTestCase.assertEquals("o", map["c"]);
1668 } 1666 }
1669 1667
1670 void test_literal_null() { 1668 void test_literal_null() {
1671 Object value = getConstantValue("null"); 1669 Object value = getConstantValue("null");
1672 JUnitTestCase.assertEquals(null, value); 1670 JUnitTestCase.assertEquals(null, value);
1673 } 1671 }
1674 1672
1675 void test_literal_number_double() { 1673 void test_literal_number_double() {
1676 Object value = getConstantValue("3.45"); 1674 Object value = getConstantValue("3.45");
1677 EngineTestCase.assertInstanceOf(double, value); 1675 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
1678 JUnitTestCase.assertEquals(3.45, value as double); 1676 JUnitTestCase.assertEquals(3.45, value as double);
1679 } 1677 }
1680 1678
1681 void test_literal_number_integer() { 1679 void test_literal_number_integer() {
1682 Object value = getConstantValue("42"); 1680 Object value = getConstantValue("42");
1683 EngineTestCase.assertInstanceOf(int, value); 1681 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1684 JUnitTestCase.assertEquals(42, value as int); 1682 JUnitTestCase.assertEquals(42, value as int);
1685 } 1683 }
1686 1684
1687 void test_literal_string_adjacent() { 1685 void test_literal_string_adjacent() {
1688 Object value = getConstantValue("'abc' 'def'"); 1686 Object value = getConstantValue("'abc' 'def'");
1689 JUnitTestCase.assertEquals("abcdef", value); 1687 JUnitTestCase.assertEquals("abcdef", value);
1690 } 1688 }
1691 1689
1692 void test_literal_string_interpolation_invalid() { 1690 void test_literal_string_interpolation_invalid() {
1693 Object value = getConstantValue("'a\${f()}c'"); 1691 Object value = getConstantValue("'a\${f()}c'");
(...skipping 10 matching lines...) Expand all
1704 JUnitTestCase.assertEquals("abc", value); 1702 JUnitTestCase.assertEquals("abc", value);
1705 } 1703 }
1706 1704
1707 void test_parenthesizedExpression() { 1705 void test_parenthesizedExpression() {
1708 Object value = getConstantValue("('a')"); 1706 Object value = getConstantValue("('a')");
1709 JUnitTestCase.assertEquals("a", value); 1707 JUnitTestCase.assertEquals("a", value);
1710 } 1708 }
1711 1709
1712 void test_unary_bitNot() { 1710 void test_unary_bitNot() {
1713 Object value = getConstantValue("~42"); 1711 Object value = getConstantValue("~42");
1714 EngineTestCase.assertInstanceOf(int, value); 1712 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1715 JUnitTestCase.assertEquals(~42, value as int); 1713 JUnitTestCase.assertEquals(~42, value as int);
1716 } 1714 }
1717 1715
1718 void test_unary_logicalNot() { 1716 void test_unary_logicalNot() {
1719 Object value = getConstantValue("!true"); 1717 Object value = getConstantValue("!true");
1720 JUnitTestCase.assertEquals(false, value); 1718 JUnitTestCase.assertEquals(false, value);
1721 } 1719 }
1722 1720
1723 void test_unary_negated_double() { 1721 void test_unary_negated_double() {
1724 Object value = getConstantValue("-42.3"); 1722 Object value = getConstantValue("-42.3");
1725 EngineTestCase.assertInstanceOf(double, value); 1723 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
1726 JUnitTestCase.assertEquals(-42.3, value as double); 1724 JUnitTestCase.assertEquals(-42.3, value as double);
1727 } 1725 }
1728 1726
1729 void test_unary_negated_integer() { 1727 void test_unary_negated_integer() {
1730 Object value = getConstantValue("-42"); 1728 Object value = getConstantValue("-42");
1731 EngineTestCase.assertInstanceOf(int, value); 1729 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
1732 JUnitTestCase.assertEquals(-42, value as int); 1730 JUnitTestCase.assertEquals(-42, value as int);
1733 } 1731 }
1734 1732
1735 Object getConstantValue(String source) => ParserTestCase.parseExpression(sourc e, []).accept(new ConstantEvaluator()); 1733 Object getConstantValue(String source) => ParserTestCase.parseExpression(sourc e, []).accept(new ConstantEvaluator());
1736 1734
1737 static dartSuite() { 1735 static dartSuite() {
1738 _ut.group('ConstantEvaluatorTest', () { 1736 _ut.group('ConstantEvaluatorTest', () {
1739 _ut.test('test_binary_bitAnd', () { 1737 _ut.test('test_binary_bitAnd', () {
1740 final __test = new ConstantEvaluatorTest(); 1738 final __test = new ConstantEvaluatorTest();
1741 runJUnitTest(__test, __test.test_binary_bitAnd); 1739 runJUnitTest(__test, __test.test_binary_bitAnd);
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 NodeLocatorTest.dartSuite(); 4087 NodeLocatorTest.dartSuite();
4090 ToSourceVisitorTest.dartSuite(); 4088 ToSourceVisitorTest.dartSuite();
4091 BreadthFirstVisitorTest.dartSuite(); 4089 BreadthFirstVisitorTest.dartSuite();
4092 ClassDeclarationTest.dartSuite(); 4090 ClassDeclarationTest.dartSuite();
4093 IndexExpressionTest.dartSuite(); 4091 IndexExpressionTest.dartSuite();
4094 NodeListTest.dartSuite(); 4092 NodeListTest.dartSuite();
4095 SimpleIdentifierTest.dartSuite(); 4093 SimpleIdentifierTest.dartSuite();
4096 SimpleStringLiteralTest.dartSuite(); 4094 SimpleStringLiteralTest.dartSuite();
4097 VariableDeclarationTest.dartSuite(); 4095 VariableDeclarationTest.dartSuite();
4098 } 4096 }
OLDNEW
« no previous file with comments | « pkg/analyzer/pubspec.yaml ('k') | pkg/analyzer/test/generated/element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698