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

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

Issue 682553002: Convert most of the EngineTestCase.createSource invocations into multi-line String literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
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';
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 PREFIX_NOT, 53 PREFIX_NOT,
54 SIMPLE_LEFT, 54 SIMPLE_LEFT,
55 SIMPLE_RIGHT, 55 SIMPLE_RIGHT,
56 NONE]; 56 NONE];
57 57
58 const AssignmentKind(String name, int ordinal) : super(name, ordinal); 58 const AssignmentKind(String name, int ordinal) : super(name, ordinal);
59 } 59 }
60 60
61 class BreadthFirstVisitorTest extends ParserTestCase { 61 class BreadthFirstVisitorTest extends ParserTestCase {
62 void test_it() { 62 void test_it() {
63 String source = EngineTestCase.createSource([ 63 String source = r'''
64 "class A {", 64 class A {
65 " bool get g => true;", 65 bool get g => true;
66 "}", 66 }
67 "class B {", 67 class B {
68 " int f() {", 68 int f() {
69 " num q() {", 69 num q() {
70 " return 3;", 70 return 3;
71 " }", 71 }
72 " return q() + 4;", 72 return q() + 4;
73 " }", 73 }
74 "}", 74 }
75 "A f(var p) {", 75 A f(var p) {
76 " if ((p as A).g) {", 76 if ((p as A).g) {
77 " return p;", 77 return p;
78 " } else {", 78 } else {
79 " return null;", 79 return null;
80 " }", 80 }
81 "}"]); 81 }''';
82 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source, []); 82 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source, []);
83 List<AstNode> nodes = new List<AstNode>(); 83 List<AstNode> nodes = new List<AstNode>();
84 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_BreadthFirstVi sitorTest_testIt(nodes); 84 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_BreadthFirstVi sitorTest_testIt(nodes);
85 visitor.visitAllNodes(unit); 85 visitor.visitAllNodes(unit);
86 EngineTestCase.assertSizeOfList(59, nodes); 86 EngineTestCase.assertSizeOfList(59, nodes);
87 EngineTestCase.assertInstanceOf((obj) => obj is CompilationUnit, Compilation Unit, nodes[0]); 87 EngineTestCase.assertInstanceOf((obj) => obj is CompilationUnit, Compilation Unit, nodes[0]);
88 EngineTestCase.assertInstanceOf((obj) => obj is ClassDeclaration, ClassDecla ration, nodes[2]); 88 EngineTestCase.assertInstanceOf((obj) => obj is ClassDeclaration, ClassDecla ration, nodes[2]);
89 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclaration, Functio nDeclaration, nodes[3]); 89 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclaration, Functio nDeclaration, nodes[3]);
90 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclarationStatement , FunctionDeclarationStatement, nodes[27]); 90 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclarationStatement , FunctionDeclarationStatement, nodes[27]);
91 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter al, nodes[58]); 91 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter al, nodes[58]);
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 NodeLocator locator = new NodeLocator.con2(0, 0); 798 NodeLocator locator = new NodeLocator.con2(0, 0);
799 JUnitTestCase.assertNull(locator.searchWithin(null)); 799 JUnitTestCase.assertNull(locator.searchWithin(null));
800 } 800 }
801 801
802 void test_searchWithin_offset() { 802 void test_searchWithin_offset() {
803 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []); 803 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []);
804 _assertLocate(unit, 10, 10, (node) => node is SimpleIdentifier, SimpleIdenti fier); 804 _assertLocate(unit, 10, 10, (node) => node is SimpleIdentifier, SimpleIdenti fier);
805 } 805 }
806 806
807 void test_searchWithin_offsetAfterNode() { 807 void test_searchWithin_offsetAfterNode() {
808 CompilationUnit unit = ParserTestCase.parseCompilationUnit(EngineTestCase.cr eateSource(["class A {}", "class B {}"]), []); 808 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
809 class A {}
810 class B {}''', []);
809 NodeLocator locator = new NodeLocator.con2(1024, 1024); 811 NodeLocator locator = new NodeLocator.con2(1024, 1024);
810 AstNode node = locator.searchWithin(unit.declarations[0]); 812 AstNode node = locator.searchWithin(unit.declarations[0]);
811 JUnitTestCase.assertNull(node); 813 JUnitTestCase.assertNull(node);
812 } 814 }
813 815
814 void test_searchWithin_offsetBeforeNode() { 816 void test_searchWithin_offsetBeforeNode() {
815 CompilationUnit unit = ParserTestCase.parseCompilationUnit(EngineTestCase.cr eateSource(["class A {}", "class B {}"]), []); 817 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
818 class A {}
819 class B {}''', []);
816 NodeLocator locator = new NodeLocator.con2(0, 0); 820 NodeLocator locator = new NodeLocator.con2(0, 0);
817 AstNode node = locator.searchWithin(unit.declarations[1]); 821 AstNode node = locator.searchWithin(unit.declarations[1]);
818 JUnitTestCase.assertNull(node); 822 JUnitTestCase.assertNull(node);
819 } 823 }
820 824
821 void _assertLocate(CompilationUnit unit, int start, int end, Predicate<AstNode > predicate, Type expectedClass) { 825 void _assertLocate(CompilationUnit unit, int start, int end, Predicate<AstNode > predicate, Type expectedClass) {
822 NodeLocator locator = new NodeLocator.con2(start, end); 826 NodeLocator locator = new NodeLocator.con2(start, end);
823 AstNode node = locator.searchWithin(unit); 827 AstNode node = locator.searchWithin(unit);
824 JUnitTestCase.assertNotNull(node); 828 JUnitTestCase.assertNotNull(node);
825 JUnitTestCase.assertSame(node, locator.foundNode); 829 JUnitTestCase.assertSame(node, locator.foundNode);
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 runReflectiveTests(BreadthFirstVisitorTest); 2599 runReflectiveTests(BreadthFirstVisitorTest);
2596 runReflectiveTests(ClassDeclarationTest); 2600 runReflectiveTests(ClassDeclarationTest);
2597 runReflectiveTests(ClassTypeAliasTest); 2601 runReflectiveTests(ClassTypeAliasTest);
2598 runReflectiveTests(IndexExpressionTest); 2602 runReflectiveTests(IndexExpressionTest);
2599 runReflectiveTests(NodeListTest); 2603 runReflectiveTests(NodeListTest);
2600 runReflectiveTests(SimpleIdentifierTest); 2604 runReflectiveTests(SimpleIdentifierTest);
2601 runReflectiveTests(SimpleStringLiteralTest); 2605 runReflectiveTests(SimpleStringLiteralTest);
2602 runReflectiveTests(StringInterpolationTest); 2606 runReflectiveTests(StringInterpolationTest);
2603 runReflectiveTests(VariableDeclarationTest); 2607 runReflectiveTests(VariableDeclarationTest);
2604 } 2608 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/all_the_rest.dart ('k') | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698