| 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 library test.completion.support; | 5 library test.completion.support; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 import 'completion_test_support.dart'; | 12 import 'completion_test_support.dart'; |
| 13 | 13 |
| 14 /** |
| 15 * Assigning the name of a single test to this string causes just that test to |
| 16 * be run. Assigning null to this string causes all tests to be run. |
| 17 */ |
| 18 const String SOLO_TEST = null; |
| 19 |
| 14 main() { | 20 main() { |
| 15 CompletionTestBuilder builder = new CompletionTestBuilder(); | 21 CompletionTestBuilder builder = new CompletionTestBuilder(); |
| 16 builder.buildAll(); | 22 builder.buildAll(); |
| 17 } | 23 } |
| 18 | 24 |
| 19 /** | 25 /** |
| 26 * Type of functions used to create tests. |
| 27 */ |
| 28 typedef void _Tester(String spec, TestFunction body); |
| 29 |
| 30 /** |
| 20 * A builder that builds the completion tests. | 31 * A builder that builds the completion tests. |
| 21 */ | 32 */ |
| 22 class CompletionTestBuilder { | 33 class CompletionTestBuilder { |
| 23 /** | 34 /** |
| 24 * Number of tests that have been built that are expected to pass. | 35 * Number of tests that have been built that are expected to pass. |
| 25 */ | 36 */ |
| 26 int expectedPassCount = 0; | 37 int expectedPassCount = 0; |
| 27 | 38 |
| 28 /** | 39 /** |
| 29 * Number of tests that have been built that are expected to fail. | 40 * Number of tests that have been built that are expected to fail. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 97 |
| 87 // space, char, eol are important | 98 // space, char, eol are important |
| 88 buildTests('testCommentSnippets011', ''' | 99 buildTests('testCommentSnippets011', ''' |
| 89 class x implements M!1{}''', <String>["1+Map"]); | 100 class x implements M!1{}''', <String>["1+Map"]); |
| 90 | 101 |
| 91 // space, char, eol are important | 102 // space, char, eol are important |
| 92 buildTests('testCommentSnippets012', ''' | 103 buildTests('testCommentSnippets012', ''' |
| 93 class x implements M!1\n{}''', <String>["1+Map"]); | 104 class x implements M!1\n{}''', <String>["1+Map"]); |
| 94 | 105 |
| 95 buildTests('testCommentSnippets013', ''' | 106 buildTests('testCommentSnippets013', ''' |
| 96 class x !2{!1}!3''', <String>["1+num", "2-num", "3-num"], failingTests: '3'); | 107 class x !2{!1}!3''', <String>["1+num", "2-num", "3+num"]); |
| 97 | 108 |
| 98 // trailing space is important | 109 // trailing space is important |
| 99 buildTests('testCommentSnippets014', ''' | 110 buildTests('testCommentSnippets014', ''' |
| 100 typedef n!1 ;''', <String>["1+num"]); | 111 typedef n!1 ;''', <String>["1+num"]); |
| 101 | 112 |
| 102 buildTests('testCommentSnippets015', ''' | 113 buildTests('testCommentSnippets015', ''' |
| 103 class D {f(){} g(){f!1(f!2);}}''', <String>["1+f", "2+f"]); | 114 class D {f(){} g(){f!1(f!2);}}''', <String>["1+f", "2+f"]); |
| 104 | 115 |
| 105 buildTests('testCommentSnippets016', ''' | 116 buildTests('testCommentSnippets016', ''' |
| 106 class F {m() { m(); !1}}''', <String>["1+m"]); | 117 class F {m() { m(); !1}}''', <String>["1+m"]); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 238 |
| 228 buildTests('testCommentSnippets044', ''' | 239 buildTests('testCommentSnippets044', ''' |
| 229 class List{}class XXX {XXX.fisk();}main() {main(); new !1}}''', | 240 class List{}class XXX {XXX.fisk();}main() {main(); new !1}}''', |
| 230 <String>["1+List", "1+XXX.fisk"], | 241 <String>["1+List", "1+XXX.fisk"], |
| 231 failingTests: '1'); | 242 failingTests: '1'); |
| 232 | 243 |
| 233 buildTests('testCommentSnippets047', ''' | 244 buildTests('testCommentSnippets047', ''' |
| 234 f(){int x;int y=!1;}''', <String>["1+x"]); | 245 f(){int x;int y=!1;}''', <String>["1+x"]); |
| 235 | 246 |
| 236 buildTests('testCommentSnippets048', ''' | 247 buildTests('testCommentSnippets048', ''' |
| 237 import 'dart:convert' as json;f() {var x=new js!1}''', | 248 import 'dart:convert' as json;f() {var x=new js!1}''', <String>["1+json"]); |
| 238 <String>["1+json"]); | |
| 239 | 249 |
| 240 buildTests('testCommentSnippets049', ''' | 250 buildTests('testCommentSnippets049', ''' |
| 241 import 'dart:convert' as json; | 251 import 'dart:convert' as json; |
| 242 import 'dart:convert' as jxx; | 252 import 'dart:convert' as jxx; |
| 243 class JsonDecoderX{} | 253 class JsonDecoderX{} |
| 244 f1() {var x=new !2j!1s!3}''', | 254 f1() {var x=new !2j!1s!3}''', |
| 245 <String>[ | 255 <String>[ |
| 246 "1+json", | 256 "1+json", |
| 247 "1+jxx", | 257 "1+jxx", |
| 248 "2+json", | 258 "2+json", |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 837 |
| 828 main(A p) { | 838 main(A p) { |
| 829 var v = p.as!1; | 839 var v = p.as!1; |
| 830 }''', <String>["1+asVisible"]); | 840 }''', <String>["1+asVisible"]); |
| 831 | 841 |
| 832 buildTests('testCompletion_as_incompleteStatement', ''' | 842 buildTests('testCompletion_as_incompleteStatement', ''' |
| 833 class MyClass {} | 843 class MyClass {} |
| 834 main(p) { | 844 main(p) { |
| 835 var justSomeVar; | 845 var justSomeVar; |
| 836 var v = p as !1 | 846 var v = p as !1 |
| 837 }''', <String>["1+MyClass", "1-justSomeVar"], failingTests: '1'); | 847 }''', <String>["1+MyClass", "1-justSomeVar"]); |
| 838 | 848 |
| 839 buildTests('testCompletion_cascade', ''' | 849 buildTests('testCompletion_cascade', ''' |
| 840 class A { | 850 class A { |
| 841 aaa() {} | 851 aaa() {} |
| 842 } | 852 } |
| 843 | 853 |
| 844 | 854 |
| 845 main(A a) { | 855 main(A a) { |
| 846 a..!1 aaa(); | 856 a..!1 aaa(); |
| 847 }''', <String>["1+aaa", "1-main"]); | 857 }''', <String>["1+aaa", "1-main"]); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 class B {} | 991 class B {} |
| 982 /** | 992 /** |
| 983 * [!3] some text | 993 * [!3] some text |
| 984 */ | 994 */ |
| 985 class C {}''', | 995 class C {}''', |
| 986 <String>["1+double", "1-int", "2+int", "2+String", "3+int", "3+String"])
; | 996 <String>["1+double", "1-int", "2+int", "2+String", "3+int", "3+String"])
; |
| 987 | 997 |
| 988 buildTests('testCompletion_double_inFractionPart', ''' | 998 buildTests('testCompletion_double_inFractionPart', ''' |
| 989 main() { | 999 main() { |
| 990 1.0!1 | 1000 1.0!1 |
| 991 }''', <String>["1-abs", "1-main"], failingTests: '1'); | 1001 }''', <String>["1-abs", "1-main"]); |
| 992 | 1002 |
| 993 buildTests('testCompletion_enum', ''' | 1003 buildTests('testCompletion_enum', ''' |
| 994 enum MyEnum {A, B, C} | 1004 enum MyEnum {A, B, C} |
| 995 main() { | 1005 main() { |
| 996 MyEnum.!1; | 1006 MyEnum.!1; |
| 997 }''', <String>["1+values", "1+A", "1+B", "1+C"], failingTests: '1'); | 1007 }''', <String>["1+values", "1+A", "1+B", "1+C"], failingTests: '1'); |
| 998 | 1008 |
| 999 buildTests('testCompletion_exactPrefix_hasHigherRelevance', ''' | 1009 buildTests('testCompletion_exactPrefix_hasHigherRelevance', ''' |
| 1000 var STR; | 1010 var STR; |
| 1001 main(p) { | 1011 main(p) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 main(A p) { | 1209 main(A p) { |
| 1200 var v1 = p.is!1; | 1210 var v1 = p.is!1; |
| 1201 var v2 = p.is!2 | 1211 var v2 = p.is!2 |
| 1202 }''', <String>["1+isVisible", "2+isVisible"]); | 1212 }''', <String>["1+isVisible", "2+isVisible"]); |
| 1203 | 1213 |
| 1204 buildTests('testCompletion_is_incompleteStatement1', ''' | 1214 buildTests('testCompletion_is_incompleteStatement1', ''' |
| 1205 class MyClass {} | 1215 class MyClass {} |
| 1206 main(p) { | 1216 main(p) { |
| 1207 var justSomeVar; | 1217 var justSomeVar; |
| 1208 var v = p is !1 | 1218 var v = p is !1 |
| 1209 }''', <String>["1+MyClass", "1-justSomeVar"], failingTests: '1'); | 1219 }''', <String>["1+MyClass", "1-justSomeVar"]); |
| 1210 | 1220 |
| 1211 buildTests('testCompletion_is_incompleteStatement2', ''' | 1221 buildTests('testCompletion_is_incompleteStatement2', ''' |
| 1212 class MyClass {} | 1222 class MyClass {} |
| 1213 main(p) { | 1223 main(p) { |
| 1214 var isVariable; | 1224 var isVariable; |
| 1215 var v = p is!1 | 1225 var v = p is!1 |
| 1216 }''', <String>["1+is", "1-isVariable"], failingTests: '1'); | 1226 }''', <String>["1+is", "1-isVariable"], failingTests: '1'); |
| 1217 | 1227 |
| 1218 buildTests('testCompletion_keyword_in', ''' | 1228 buildTests('testCompletion_keyword_in', ''' |
| 1219 class Foo { int input = 7; mth() { if (in!1) {}}}''', <String>["1+input"]); | 1229 class Foo { int input = 7; mth() { if (in!1) {}}}''', <String>["1+input"]); |
| 1220 | 1230 |
| 1221 buildTests('testCompletion_keyword_syntheticIdentifier', ''' | 1231 buildTests('testCompletion_keyword_syntheticIdentifier', ''' |
| 1222 main() { | 1232 main() { |
| 1223 var caseVar; | 1233 var caseVar; |
| 1224 var otherVar; | 1234 var otherVar; |
| 1225 var v = case!1 | 1235 var v = case!1 |
| 1226 }''', <String>["1+caseVar", "1-otherVar"]); | 1236 }''', <String>["1+caseVar", "1-otherVar"]); |
| 1227 | 1237 |
| 1228 buildTests('testCompletion_libraryIdentifier_atEOF', ''' | 1238 buildTests('testCompletion_libraryIdentifier_atEOF', ''' |
| 1229 library int.!1''', <String>["1-parse", "1-bool"], failingTests: '1'); | 1239 library int.!1''', <String>["1-parse", "1-bool"]); |
| 1230 | 1240 |
| 1231 buildTests('testCompletion_libraryIdentifier_notEOF', ''' | 1241 buildTests('testCompletion_libraryIdentifier_notEOF', ''' |
| 1232 library int.!1''', <String>["1-parse", "1-bool"], failingTests: '1'); | 1242 library int.!1''', <String>["1-parse", "1-bool"]); |
| 1233 | 1243 |
| 1234 buildTests('testCompletion_methodRef_asArg_incompatibleFunctionType', ''' | 1244 buildTests('testCompletion_methodRef_asArg_incompatibleFunctionType', ''' |
| 1235 foo( f(int p) ) {} | 1245 foo( f(int p) ) {} |
| 1236 class Functions { | 1246 class Functions { |
| 1237 static myFuncInt(int p) {} | 1247 static myFuncInt(int p) {} |
| 1238 static myFuncDouble(double p) {} | 1248 static myFuncDouble(double p) {} |
| 1239 } | 1249 } |
| 1240 bar(p) {} | 1250 bar(p) {} |
| 1241 main(p) { | 1251 main(p) { |
| 1242 foo( Functions.!1; ); | 1252 foo( Functions.!1; ); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 | 1434 |
| 1425 buildTests('testCompletion_return_withIdentifierPrefix', ''' | 1435 buildTests('testCompletion_return_withIdentifierPrefix', ''' |
| 1426 f() { var vvv = 42; return v!1 }''', <String>["1+vvv"]); | 1436 f() { var vvv = 42; return v!1 }''', <String>["1+vvv"]); |
| 1427 | 1437 |
| 1428 buildTests('testCompletion_return_withoutExpression', ''' | 1438 buildTests('testCompletion_return_withoutExpression', ''' |
| 1429 f() { var vvv = 42; return !1 }''', <String>["1+vvv"]); | 1439 f() { var vvv = 42; return !1 }''', <String>["1+vvv"]); |
| 1430 | 1440 |
| 1431 buildTests('testCompletion_staticField1', ''' | 1441 buildTests('testCompletion_staticField1', ''' |
| 1432 class num{}class Sunflower {static final n!2um MAX_D = 300;nu!3m xc, yc;Sun!4flo
wer() {x!Xc = y!Yc = MA!1 }}''', | 1442 class num{}class Sunflower {static final n!2um MAX_D = 300;nu!3m xc, yc;Sun!4flo
wer() {x!Xc = y!Yc = MA!1 }}''', |
| 1433 <String>["1+MAX_D", "X+xc", "Y+yc", "2+num", "3+num", "4+Sunflower"], | 1443 <String>["1+MAX_D", "X+xc", "Y+yc", "2+num", "3+num", "4+Sunflower"], |
| 1434 failingTests: '234'); | 1444 failingTests: '23'); |
| 1435 | 1445 |
| 1436 buildTests('testCompletion_super_superType', ''' | 1446 buildTests('testCompletion_super_superType', ''' |
| 1437 class A { | 1447 class A { |
| 1438 var fa; | 1448 var fa; |
| 1439 ma() {} | 1449 ma() {} |
| 1440 } | 1450 } |
| 1441 class B extends A { | 1451 class B extends A { |
| 1442 var fb; | 1452 var fb; |
| 1443 mb() {} | 1453 mb() {} |
| 1444 main() { | 1454 main() { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 <String>["1-_f", "1+f"], | 1611 <String>["1-_f", "1+f"], |
| 1602 extraFiles: sources, | 1612 extraFiles: sources, |
| 1603 failingTests: '1'); | 1613 failingTests: '1'); |
| 1604 | 1614 |
| 1605 sources.clear(); | 1615 sources.clear(); |
| 1606 sources["/firth.dart"] = ''' | 1616 sources["/firth.dart"] = ''' |
| 1607 library firth; | 1617 library firth; |
| 1608 class SerializationException { | 1618 class SerializationException { |
| 1609 const SerializationException(); | 1619 const SerializationException(); |
| 1610 }'''; | 1620 }'''; |
| 1611 buildTests('test001', ''' | 1621 buildTests('testLibrary001', ''' |
| 1612 import 'firth.dart'; | 1622 import 'firth.dart'; |
| 1613 main() { | 1623 main() { |
| 1614 throw new Seria!1lizationException();}''', | 1624 throw new Seria!1lizationException();}''', |
| 1615 <String>["1+SerializationException"], | 1625 <String>["1+SerializationException"], |
| 1616 extraFiles: sources, | 1626 extraFiles: sources, |
| 1617 failingTests: '1'); | 1627 failingTests: '1'); |
| 1618 | 1628 |
| 1619 // Type propagation. | 1629 // Type propagation. |
| 1620 // TODO Include corelib analysis (this works in the editor) | 1630 // TODO Include corelib analysis (this works in the editor) |
| 1621 buildTests( | 1631 buildTests( |
| 1622 'test002', | 1632 'testLibrary002', |
| 1623 '''t2() {var q=[0],z=q.!1length;q.!2clear();}''', | 1633 '''t2() {var q=[0],z=q.!1length;q.!2clear();}''', |
| 1624 <String>["1+length", "1+isEmpty", "2+clear"], | 1634 <String>["1+length", "1+isEmpty", "2+clear"], |
| 1625 failingTests: '1'); | 1635 failingTests: '1'); |
| 1626 | 1636 |
| 1627 // TODO Include corelib analysis | 1637 // TODO Include corelib analysis |
| 1628 buildTests( | 1638 buildTests( |
| 1629 'test003', | 1639 'testLibrary003', |
| 1630 '''class X{var q; f() {q.!1a!2}}''', | 1640 '''class X{var q; f() {q.!1a!2}}''', |
| 1631 <String>["1+end", "2+abs", "2-end"], | 1641 <String>["1+end", "2+abs", "2-end"], |
| 1632 failingTests: '12'); | 1642 failingTests: '12'); |
| 1633 | 1643 |
| 1634 // TODO Include corelib analysis | 1644 // TODO Include corelib analysis |
| 1635 // Resolving dart:html takes between 2.5s and 30s; json, about 0.12s | 1645 // Resolving dart:html takes between 2.5s and 30s; json, about 0.12s |
| 1636 buildTests('test004', ''' | 1646 buildTests('testLibrary004', ''' |
| 1637 library foo; | 1647 library foo; |
| 1638 import 'dart:convert' as json; | 1648 import 'dart:convert' as json; |
| 1639 class JsonDecoderX{} | 1649 class JsonDecoderX{} |
| 1640 f1() {var x=new json.!1} | 1650 f1() {var x=new json.!1} |
| 1641 f2() {var x=new json.JsonDe!2} | 1651 f2() {var x=new json.JsonDe!2} |
| 1642 f3() {var x=new json.JsonDecoder!3}''', | 1652 f3() {var x=new json.JsonDecoder!3}''', |
| 1643 <String>[ | 1653 <String>[ |
| 1644 "1+JsonDecoder", | 1654 "1+JsonDecoder", |
| 1645 "1-JsonDecoderX", | 1655 "1-JsonDecoderX", |
| 1646 "2+JsonDecoder", | 1656 "2+JsonDecoder", |
| 1647 "2-JsonDecoderX", | 1657 "2-JsonDecoderX", |
| 1648 "3+JsonDecoder", | 1658 "3+JsonDecoder", |
| 1649 "3-JsonDecoderX"]); | 1659 "3-JsonDecoderX"]); |
| 1650 | 1660 |
| 1651 // TODO Enable after type propagation is implemented. Not yet. | 1661 // TODO Enable after type propagation is implemented. Not yet. |
| 1652 // TODO Include corelib analysis | 1662 // TODO Include corelib analysis |
| 1653 buildTests( | 1663 buildTests( |
| 1654 'test005', | 1664 'testLibrary005', |
| 1655 '''var PHI;main(){PHI=5.3;PHI.abs().!1 Object x;}''', | 1665 '''var PHI;main(){PHI=5.3;PHI.abs().!1 Object x;}''', |
| 1656 <String>["1+abs"], | 1666 <String>["1+abs"], |
| 1657 failingTests: '1'); | 1667 failingTests: '1'); |
| 1658 | 1668 |
| 1659 // Exercise import and export handling. | 1669 // Exercise import and export handling. |
| 1660 // Libraries are defined in partial order of increasing dependency. | 1670 // Libraries are defined in partial order of increasing dependency. |
| 1661 sources.clear(); | 1671 sources.clear(); |
| 1662 sources["/exp2a.dart"] = ''' | 1672 sources["/exp2a.dart"] = ''' |
| 1663 library exp2a; | 1673 library exp2a; |
| 1664 e2a() {}'''; | 1674 e2a() {}'''; |
| 1665 sources["/exp1b.dart"] = ''' | 1675 sources["/exp1b.dart"] = ''' |
| 1666 library exp1b;", | 1676 library exp1b;", |
| 1667 e1b() {}'''; | 1677 e1b() {}'''; |
| 1668 sources["/exp1a.dart"] = ''' | 1678 sources["/exp1a.dart"] = ''' |
| 1669 library exp1a;", | 1679 library exp1a;", |
| 1670 export 'exp1b.dart';", | 1680 export 'exp1b.dart';", |
| 1671 e1a() {}'''; | 1681 e1a() {}'''; |
| 1672 sources["/imp1.dart"] = ''' | 1682 sources["/imp1.dart"] = ''' |
| 1673 library imp1; | 1683 library imp1; |
| 1674 export 'exp1a.dart'; | 1684 export 'exp1a.dart'; |
| 1675 i1() {}'''; | 1685 i1() {}'''; |
| 1676 sources["/imp2.dart"] = ''' | 1686 sources["/imp2.dart"] = ''' |
| 1677 library imp2; | 1687 library imp2; |
| 1678 export 'exp2a.dart'; | 1688 export 'exp2a.dart'; |
| 1679 i2() {}'''; | 1689 i2() {}'''; |
| 1680 buildTests('test006', ''' | 1690 buildTests('testLibrary006', ''' |
| 1681 import 'imp1.dart'; | 1691 import 'imp1.dart'; |
| 1682 import 'imp2.dart'; | 1692 import 'imp2.dart'; |
| 1683 main() {!1 | 1693 main() {!1 |
| 1684 i1(); | 1694 i1(); |
| 1685 i2(); | 1695 i2(); |
| 1686 e1a(); | 1696 e1a(); |
| 1687 e1b(); | 1697 e1b(); |
| 1688 e2a(); | 1698 e2a(); |
| 1689 }''', | 1699 }''', |
| 1690 <String>["1+i1", "1+i2", "1+e1a", "1+e2a", "1+e1b"], | 1700 <String>["1+i1", "1+i2", "1+e1a", "1+e2a", "1+e1b"], |
| 1691 extraFiles: sources, | 1701 extraFiles: sources, |
| 1692 failingTests: '1'); | 1702 failingTests: '1'); |
| 1693 | 1703 |
| 1694 // Exercise import and export handling. | 1704 // Exercise import and export handling. |
| 1695 // Libraries are defined in partial order of increasing dependency. | 1705 // Libraries are defined in partial order of increasing dependency. |
| 1696 sources.clear(); | 1706 sources.clear(); |
| 1697 sources["/l1.dart"] = ''' | 1707 sources["/l1.dart"] = ''' |
| 1698 library l1; | 1708 library l1; |
| 1699 var _l1t; var l1t;'''; | 1709 var _l1t; var l1t;'''; |
| 1700 buildTests('test007', ''' | 1710 buildTests('testLibrary007', ''' |
| 1701 import 'l1.dart'; | 1711 import 'l1.dart'; |
| 1702 main() { | 1712 main() { |
| 1703 var x = l!1 | 1713 var x = l!1 |
| 1704 var y = _!2 | 1714 var y = _!2 |
| 1705 }''', | 1715 }''', |
| 1706 <String>["1+l1t", "1-_l1t", "2-_l1t"], | 1716 <String>["1+l1t", "1-_l1t", "2-_l1t"], |
| 1707 extraFiles: sources, | 1717 extraFiles: sources, |
| 1708 failingTests: '1'); | 1718 failingTests: '1'); |
| 1709 | 1719 |
| 1710 // Check private library exclusion | 1720 // Check private library exclusion |
| 1711 sources.clear(); | 1721 sources.clear(); |
| 1712 sources["/public.dart"] = ''' | 1722 sources["/public.dart"] = ''' |
| 1713 library public; | 1723 library public; |
| 1714 class NonPrivate { | 1724 class NonPrivate { |
| 1715 void publicMethod() { | 1725 void publicMethod() { |
| 1716 } | 1726 } |
| 1717 }'''; | 1727 }'''; |
| 1718 sources["/private.dart"] = ''' | 1728 sources["/private.dart"] = ''' |
| 1719 library _private; | 1729 library _private; |
| 1720 import 'public.dart'; | 1730 import 'public.dart'; |
| 1721 class Private extends NonPrivate { | 1731 class Private extends NonPrivate { |
| 1722 void privateMethod() { | 1732 void privateMethod() { |
| 1723 } | 1733 } |
| 1724 }'''; | 1734 }'''; |
| 1725 buildTests('test008', ''' | 1735 buildTests('testLibrary008', ''' |
| 1726 import 'private.dart'; | 1736 import 'private.dart'; |
| 1727 import 'public.dart'; | 1737 import 'public.dart'; |
| 1728 class Test { | 1738 class Test { |
| 1729 void test() { | 1739 void test() { |
| 1730 NonPrivate x = new NonPrivate(); | 1740 NonPrivate x = new NonPrivate(); |
| 1731 x.!1 //publicMethod but not privateMethod should appear | 1741 x.!1 //publicMethod but not privateMethod should appear |
| 1732 } | 1742 } |
| 1733 }''', | 1743 }''', |
| 1734 <String>["1-privateMethod", "1+publicMethod"], | 1744 <String>["1-privateMethod", "1+publicMethod"], |
| 1735 extraFiles: sources, | 1745 extraFiles: sources, |
| 1736 failingTests: '1'); | 1746 failingTests: '1'); |
| 1737 | 1747 |
| 1738 // Exercise library prefixes. | 1748 // Exercise library prefixes. |
| 1739 sources.clear(); | 1749 sources.clear(); |
| 1740 sources["/lib.dart"] = ''' | 1750 sources["/lib.dart"] = ''' |
| 1741 library lib; | 1751 library lib; |
| 1742 int X = 1; | 1752 int X = 1; |
| 1743 void m(){} | 1753 void m(){} |
| 1744 class Y {}'''; | 1754 class Y {}'''; |
| 1745 buildTests('test009', ''' | 1755 buildTests('testLibrary009', ''' |
| 1746 import 'lib.dart' as Q; | 1756 import 'lib.dart' as Q; |
| 1747 void a() { | 1757 void a() { |
| 1748 var x = Q.!1 | 1758 var x = Q.!1 |
| 1749 } | 1759 } |
| 1750 void b() { | 1760 void b() { |
| 1751 var x = [Q.!2] | 1761 var x = [Q.!2] |
| 1752 } | 1762 } |
| 1753 void c() { | 1763 void c() { |
| 1754 var x = new List([Q.!3]) | 1764 var x = new List([Q.!3]) |
| 1755 } | 1765 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 "4-dynamic", | 1904 "4-dynamic", |
| 1895 "5+TestFn2", | 1905 "5+TestFn2", |
| 1896 "6+num", | 1906 "6+num", |
| 1897 "7+typedef"], | 1907 "7+typedef"], |
| 1898 failingTests: '12347'); | 1908 failingTests: '12347'); |
| 1899 | 1909 |
| 1900 buildTests('test010', ''' | 1910 buildTests('test010', ''' |
| 1901 class test !8<!1t !2 !3extends String,!4 List,!5 !6>!7 {} | 1911 class test !8<!1t !2 !3extends String,!4 List,!5 !6>!7 {} |
| 1902 class tezetst !9<!BString,!C !DList>!A {}''', | 1912 class tezetst !9<!BString,!C !DList>!A {}''', |
| 1903 <String>[ | 1913 <String>[ |
| 1904 "1+String", | 1914 "1-String", |
| 1905 "1+List", | 1915 "1-List", |
| 1906 "1-test", | 1916 "1-test", |
| 1907 "2-String", | 1917 "2-String", |
| 1908 "2-test", | 1918 "2-test", |
| 1909 "3+extends", | 1919 "3+extends", |
| 1910 "4+tezetst", | 1920 "4-tezetst", |
| 1911 "4-test", | 1921 "4-test", |
| 1912 "5+String", | 1922 "5-String", |
| 1913 "6+List", | 1923 "6-List", |
| 1914 "7-List", | 1924 "7-List", |
| 1915 "8-List", | 1925 "8-List", |
| 1916 "9-String", | 1926 "9-String", |
| 1917 "A-String", | 1927 "A-String", |
| 1918 "B+String", | 1928 "B-String", |
| 1919 "C+List", | 1929 "C-List", |
| 1920 "C-tezetst", | 1930 "C-tezetst", |
| 1921 "D+List", | 1931 "D-List", |
| 1922 "D+test"], | 1932 "D-test"], |
| 1923 failingTests: '12345C'); | 1933 failingTests: '23'); |
| 1924 | 1934 |
| 1925 // name generation with conflicts | 1935 // name generation with conflicts |
| 1926 buildTests( | 1936 buildTests( |
| 1927 'test011', | 1937 'test011', |
| 1928 '''r2(var object, Object object1, Object !1);''', | 1938 '''r2(var object, Object object1, Object !1);''', |
| 1929 <String>["1+object2"], | 1939 <String>["1+object2"], |
| 1930 failingTests: '1'); | 1940 failingTests: '1'); |
| 1931 | 1941 |
| 1932 // reserved words | 1942 // reserved words |
| 1933 buildTests('test012', ''' | 1943 buildTests('test012', ''' |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2358 completionTests.map((LocationSpec spec) => spec.id).toSet(); | 2368 completionTests.map((LocationSpec spec) => spec.id).toSet(); |
| 2359 for (String id in failingTests.split('')) { | 2369 for (String id in failingTests.split('')) { |
| 2360 if (!allSpecIds.contains(id)) { | 2370 if (!allSpecIds.contains(id)) { |
| 2361 test("$baseName-$id", () { | 2371 test("$baseName-$id", () { |
| 2362 fail( | 2372 fail( |
| 2363 "Test case '$id' included in failingTests, but this id does not ex
ist."); | 2373 "Test case '$id' included in failingTests, but this id does not ex
ist."); |
| 2364 }); | 2374 }); |
| 2365 } | 2375 } |
| 2366 } | 2376 } |
| 2367 for (LocationSpec spec in completionTests) { | 2377 for (LocationSpec spec in completionTests) { |
| 2378 String testName = '$baseName-${spec.id}'; |
| 2379 _Tester tester = testName == SOLO_TEST ? solo_test : test; |
| 2368 if (failingTests.contains(spec.id)) { | 2380 if (failingTests.contains(spec.id)) { |
| 2369 ++expectedFailCount; | 2381 ++expectedFailCount; |
| 2370 test("$baseName-${spec.id} (expected failure)", () { | 2382 tester("$testName (expected failure $expectedFailCount)", () { |
| 2371 CompletionTestCase test = new CompletionTestCase(); | 2383 CompletionTestCase test = new CompletionTestCase(); |
| 2372 return new Future(() => test.runTest(spec, extraFiles)).then((_) { | 2384 return new Future(() => test.runTest(spec, extraFiles)).then((_) { |
| 2373 fail('Test passed - expected to fail.'); | 2385 fail('Test passed - expected to fail.'); |
| 2374 }, onError: (_) {}); | 2386 }, onError: (_) {}); |
| 2375 }); | 2387 }); |
| 2376 } else { | 2388 } else { |
| 2377 ++expectedPassCount; | 2389 ++expectedPassCount; |
| 2378 test("$baseName-${spec.id}", () { | 2390 tester(testName, () { |
| 2379 CompletionTestCase test = new CompletionTestCase(); | 2391 CompletionTestCase test = new CompletionTestCase(); |
| 2380 return test.runTest(spec, extraFiles); | 2392 return test.runTest(spec, extraFiles); |
| 2381 }); | 2393 }); |
| 2382 } | 2394 } |
| 2383 } | 2395 } |
| 2384 } | 2396 } |
| 2385 } | 2397 } |
| OLD | NEW |