brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 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 |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | library test.completion.support; |
| 6 | |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 7 | import 'dart:async'; |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 8 | import 'dart:collection'; |
| 9 | |
Konstantin Shcheglov | de4d8b3 | 2016-10-06 08:47:15 -0700 | [diff] [blame] | 10 | import 'package:test/test.dart'; |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 11 | |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 12 | import 'completion_test_support.dart'; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 13 | |
| 14 | main() { |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 15 | CompletionTestBuilder builder = new CompletionTestBuilder(); |
| 16 | builder.buildAll(); |
| 17 | } |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 18 | |
paulberry@google.com | 6d7155d | 2014-12-20 15:47:25 +0000 | [diff] [blame] | 19 | /** |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 20 | * A builder that builds the completion tests. |
| 21 | */ |
| 22 | class CompletionTestBuilder { |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 23 | /** |
| 24 | * Number of tests that have been built that are expected to pass. |
| 25 | */ |
| 26 | int expectedPassCount = 0; |
| 27 | |
| 28 | /** |
| 29 | * Number of tests that have been built that are expected to fail. |
| 30 | */ |
| 31 | int expectedFailCount = 0; |
| 32 | |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 33 | void buildAll() { |
| 34 | buildNumberedTests(); |
| 35 | buildCommentSnippetTests(); |
| 36 | buildCompletionTests(); |
| 37 | buildOtherTests(); |
| 38 | buildLibraryTests(); |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 39 | int testCount = expectedPassCount + expectedFailCount; |
| 40 | print( |
| 41 | 'Total $testCount tests, of which $expectedFailCount are expected to fail.'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void buildCommentSnippetTests() { |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 45 | buildTests( |
| 46 | 'testCommentSnippets001', |
| 47 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 48 | class X {static final num MAX = 0;num yc,xc;mth() {xc = yc = MA!1X;x!2c.abs();num f = M!3AX;}}''', |
| 49 | <String>["1+MAX", "2+xc", "3+MAX"]); |
| 50 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 51 | buildTests( |
| 52 | 'testCommentSnippets002', |
| 53 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 54 | class Y {String x='hi';mth() {x.l!1ength;int n = 0;x!2.codeUnitAt(n!3);}}''', |
| 55 | <String>["1+length", "2+x", "3+n"]); |
| 56 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 57 | buildTests( |
| 58 | 'testCommentSnippets004', |
| 59 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 60 | class A {!1int x; !2mth() {!3int y = this.!5x!6;}}class B{}''', |
danrubel@google.com | 438aa44 | 2014-12-15 17:48:00 +0000 | [diff] [blame] | 61 | <String>["1+A", "2+B", "3+x", "3-y", "5+mth", "6+x"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 62 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 63 | buildTests( |
| 64 | 'testCommentSnippets005', |
| 65 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 66 | class Date { static Date JUN, JUL;}class X { m() { return Da!1te.JU!2L; }}''', |
| 67 | <String>["1+Date", "2+JUN", "2+JUL"]); |
| 68 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 69 | buildTests( |
| 70 | 'testCommentSnippets007', |
| 71 | ''' |
danrubel@google.com | ddc3cae | 2014-12-16 16:53:24 +0000 | [diff] [blame] | 72 | class C {mth(Map x, !1) {}mtf(!2, Map x) {}m() {for (in!3t i=0; i<5; i++); A!4 x;}}class int{}class Arrays{}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 73 | <String>["1+bool", "2+bool", "3+int", "4+Arrays"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 74 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 75 | buildTests( |
| 76 | 'testCommentSnippets008', |
| 77 | ''' |
| 78 | class Date{}final num M = Dat!1''', |
| 79 | <String>["1+Date"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 80 | |
| 81 | // space, char, eol are important |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 82 | buildTests( |
| 83 | 'testCommentSnippets009', |
| 84 | ''' |
| 85 | class Maps{}class x extends!5 !2M!3 !4implements!6 !1\n{}''', |
| 86 | <String>[ |
| 87 | "1+Map", |
| 88 | "2+Maps", |
| 89 | "3+Maps", |
| 90 | "4-Maps", |
| 91 | "4+implements", |
| 92 | "5-Maps", |
| 93 | "6-Map", |
| 94 | "6+implements" |
| 95 | ], |
| 96 | failingTests: '46'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 97 | |
| 98 | // space, char, eol are important |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 99 | buildTests( |
| 100 | 'testCommentSnippets010', |
| 101 | ''' |
| 102 | class x implements !1{}''', |
| 103 | <String>["1+Map"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 104 | |
| 105 | // space, char, eol are important |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 106 | buildTests( |
| 107 | 'testCommentSnippets011', |
| 108 | ''' |
| 109 | class x implements M!1{}''', |
| 110 | <String>["1+Map"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 111 | |
| 112 | // space, char, eol are important |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 113 | buildTests( |
| 114 | 'testCommentSnippets012', |
| 115 | ''' |
| 116 | class x implements M!1\n{}''', |
| 117 | <String>["1+Map"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 118 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 119 | buildTests( |
| 120 | 'testCommentSnippets013', |
| 121 | ''' |
| 122 | class x !2{!1}!3''', |
| 123 | <String>["1+num", "2-num", "3+num"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 124 | |
| 125 | // trailing space is important |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 126 | buildTests( |
| 127 | 'testCommentSnippets014', |
| 128 | ''' |
| 129 | typedef n!1 ;''', |
| 130 | <String>["1+num"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 131 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 132 | buildTests( |
| 133 | 'testCommentSnippets015', |
| 134 | ''' |
| 135 | class D {f(){} g(){f!1(f!2);}}''', |
| 136 | <String>["1+f", "2+f"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 137 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 138 | buildTests( |
| 139 | 'testCommentSnippets016', |
| 140 | ''' |
| 141 | class F {m() { m(); !1}}''', |
| 142 | <String>["1+m"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 143 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 144 | buildTests( |
| 145 | 'testCommentSnippets017', |
| 146 | ''' |
| 147 | class F {var x = !1false;}''', |
| 148 | <String>["1+true"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 149 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 150 | buildTests( |
| 151 | 'testCommentSnippets018', |
| 152 | ''' |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 153 | class Map{}class Arrays{}class C{ m(!1){} n(!2 x, q)''', |
| 154 | <String>["1+Map", "1-void", "1-null", "2+Arrays", "2-void", "2-null"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 155 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 156 | buildTests( |
| 157 | 'testCommentSnippets019', |
| 158 | ''' |
| 159 | class A{m(){Object x;x.!1/**/clear()''', |
| 160 | <String>["1+toString"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 161 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 162 | buildTests( |
| 163 | 'testCommentSnippets020', |
| 164 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 165 | classMap{}class tst {var newt;void newf(){}test() {var newz;new!1/**/;}}''', |
danrubel@google.com | b9f3559 | 2015-01-28 20:39:36 +0000 | [diff] [blame] | 166 | <String>["1+newt", "1+newf", "1+newz", "1-Map"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 167 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 168 | buildTests( |
| 169 | 'testCommentSnippets021', |
| 170 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 171 | class Map{}class tst {var newt;void newf(){}test() {var newz;new !1/**/;}}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 172 | <String>["1+Map", "1-newt"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 173 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 174 | buildTests( |
| 175 | 'testCommentSnippets022', |
| 176 | ''' |
| 177 | class Map{}class F{m(){new !1;}}''', |
| 178 | <String>["1+Map"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 179 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 180 | buildTests( |
| 181 | 'testCommentSnippets022a', |
| 182 | ''' |
| 183 | class Map{}class F{m(){new !1''', |
| 184 | <String>["1+Map"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 185 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 186 | buildTests( |
| 187 | 'testCommentSnippets022b', |
| 188 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 189 | class Map{factory Map.qq(){return null;}}class F{m(){new Map.!1qq();}}''', |
danrubel@google.com | cd4ec28 | 2014-12-15 17:16:40 +0000 | [diff] [blame] | 190 | <String>["1+qq"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 191 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 192 | buildTests( |
| 193 | 'testCommentSnippets023', |
| 194 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 195 | class X {X c; X(this.!1c!3) : super() {c.!2}}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 196 | <String>["1+c", "2+c", "3+c"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 197 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 198 | buildTests( |
| 199 | 'testCommentSnippets024', |
| 200 | ''' |
| 201 | class q {m(Map q){var x;m(!1)}n(){var x;n(!2)}}''', |
| 202 | <String>["1+x", "2+x"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 203 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 204 | buildTests( |
| 205 | 'testCommentSnippets025', |
| 206 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 207 | class q {num m() {var q; num x=!1 q!3 + !2/**/;}}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 208 | <String>["1+q", "2+q", "3+q"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 209 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 210 | buildTests( |
| 211 | 'testCommentSnippets026', |
| 212 | ''' |
| 213 | class List{}class a implements !1{}''', |
| 214 | <String>["1+List"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 215 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 216 | buildTests( |
| 217 | 'testCommentSnippets027', |
| 218 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 219 | class String{}class List{}class test <X extends !1String!2> {}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 220 | <String>["1+List", "2+String", "2-List"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 221 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 222 | buildTests( |
| 223 | 'testCommentSnippets028', |
| 224 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 225 | class String{}class List{}class DateTime{}typedef T Y<T extends !1>(List input);''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 226 | <String>["1+DateTime", "1+String"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 227 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 228 | buildTests( |
| 229 | 'testCommentSnippets029', |
| 230 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 231 | interface A<X> default B<X extends !1List!2> {}''', |
| 232 | <String>["1+DateTime", "2+List"]); |
| 233 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 234 | buildTests( |
| 235 | 'testCommentSnippets030', |
| 236 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 237 | class Bar<T extends Foo> {const Bar(!1T!2 k);T!3 m(T!4 a, T!5 b){}final T!6 f = null;}''', |
paulberry@google.com | 2461125 | 2014-12-09 16:44:12 +0000 | [diff] [blame] | 238 | <String>["1+T", "2+T", "3+T", "4+T", "5+T", "6+T"], |
| 239 | failingTests: '123456'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 240 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 241 | buildTests( |
| 242 | 'testCommentSnippets031', |
| 243 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 244 | class Bar<T extends Foo> {m(x){if (x is !1) return;if (x is!!!2)}}''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 245 | <String>["1+Bar", "1+T", "2+T", "2+Bar"], |
| 246 | failingTests: '12'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 247 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 248 | buildTests( |
| 249 | 'testCommentSnippets032', |
| 250 | ''' |
danrubel@google.com | ddc3cae | 2014-12-16 16:53:24 +0000 | [diff] [blame] | 251 | class Fit{}class Bar<T extends Fooa> {const !2F!1ara();}''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 252 | <String>["1+Fit", "1+Fara", "1-Bar", "2+Fit"], |
| 253 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 254 | |
| 255 | // Type propagation |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 256 | buildTests( |
| 257 | 'testCommentSnippets033', |
| 258 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 259 | class List{add(){}length(){}}t1() {var x;if (x is List) {x.!1add(3);}}''', |
| 260 | <String>["1+add", "1+length"]); |
| 261 | |
| 262 | // Type propagation |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 263 | buildTests( |
| 264 | 'testCommentSnippets035', |
| 265 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 266 | class List{clear(){}length(){}}t3() {var x=new List(), y=x.!1length();x.!2clear();}''', |
| 267 | <String>["1+length", "2+clear"]); |
| 268 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 269 | buildTests( |
| 270 | 'testCommentSnippets036', |
| 271 | ''' |
| 272 | class List{}t3() {var x=new List!1}''', |
| 273 | <String>["1+List"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 274 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 275 | buildTests( |
| 276 | 'testCommentSnippets037', |
| 277 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 278 | class List{factory List.from(){}}t3() {var x=new List.!1}''', |
danrubel@google.com | cd4ec28 | 2014-12-15 17:16:40 +0000 | [diff] [blame] | 279 | <String>["1+from"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 280 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 281 | buildTests( |
| 282 | 'testCommentSnippets038', |
| 283 | ''' |
| 284 | f(){int xa; String s = '\$x!1';}''', |
| 285 | <String>["1+xa"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 286 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 287 | buildTests( |
| 288 | 'testCommentSnippets038a', |
| 289 | ''' |
| 290 | int xa; String s = '\$x!1\'''', |
| 291 | <String>["1+xa"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 292 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 293 | buildTests( |
| 294 | 'testCommentSnippets039', |
| 295 | ''' |
| 296 | f(){int xa; String s = '\$!1';}''', |
| 297 | <String>["1+xa"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 298 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 299 | buildTests( |
| 300 | 'testCommentSnippets039a', |
| 301 | ''' |
| 302 | int xa; String s = '\$!1\'''', |
| 303 | <String>["1+xa"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 304 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 305 | buildTests( |
| 306 | 'testCommentSnippets040', |
| 307 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 308 | class List{add(){}}class Map{}class X{m(){List list; list.!1 Map map;}}''', |
| 309 | <String>["1+add"]); |
| 310 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 311 | buildTests( |
| 312 | 'testCommentSnippets041', |
| 313 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 314 | class List{add(){}length(){}}class X{m(){List list; list.!1 zox();}}''', |
| 315 | <String>["1+add"]); |
| 316 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 317 | buildTests( |
| 318 | 'testCommentSnippets042', |
| 319 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 320 | class DateTime{static const int WED=3;int get day;}fd(){DateTime d=new DateTime.now();d.!1WED!2;}''', |
danrubel@google.com | 5194a2b | 2015-02-07 00:56:15 +0000 | [diff] [blame] | 321 | <String>["1+day", "2-WED"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 322 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 323 | buildTests( |
| 324 | 'testCommentSnippets043', |
| 325 | ''' |
| 326 | class L{var k;void.!1}''', |
| 327 | <String>["1-k"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 328 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 329 | buildTests( |
| 330 | 'testCommentSnippets044', |
| 331 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 332 | class List{}class XXX {XXX.fisk();}main() {main(); new !1}}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 333 | <String>["1+List", "1+XXX.fisk"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 334 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 335 | buildTests( |
| 336 | 'testCommentSnippets047', |
| 337 | ''' |
| 338 | f(){int x;int y=!1;}''', |
| 339 | <String>["1+x"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 340 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 341 | buildTests( |
| 342 | 'testCommentSnippets048', |
| 343 | ''' |
| 344 | import 'dart:convert' as json;f() {var x=new js!1}''', |
| 345 | <String>["1+json"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 346 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 347 | buildTests( |
| 348 | 'testCommentSnippets049', |
| 349 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 350 | import 'dart:convert' as json; |
| 351 | import 'dart:convert' as jxx; |
paulberry@google.com | dfb35c0 | 2014-12-19 17:02:18 +0000 | [diff] [blame] | 352 | class JsonDecoderX{} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 353 | f1() {var x=new !2j!1s!3}''', |
| 354 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 355 | "1+json", |
| 356 | "1+jxx", |
| 357 | "2+json", |
| 358 | "2+jxx", |
| 359 | "2-JsonDecoder", |
| 360 | "3+json", |
| 361 | "3-jxx" |
| 362 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 363 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 364 | buildTests( |
| 365 | 'testCommentSnippets050', |
| 366 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 367 | class xdr { |
| 368 | xdr(); |
| 369 | const xdr.a(a,b,c); |
| 370 | xdr.b(); |
| 371 | f() => 3; |
| 372 | } |
| 373 | class xa{} |
| 374 | k() { |
| 375 | new x!1dr().f(); |
| 376 | const x!2dr.!3a(1, 2, 3); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 377 | }''', |
| 378 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 379 | "1+xdr", |
| 380 | "1+xa", |
| 381 | "1+xdr.a", |
| 382 | "1+xdr.b", |
| 383 | "2+xa", // suggest default constructor |
| 384 | "2+xdr", // suggest normal constructor |
| 385 | "2+xdr.a", |
| 386 | "2+xdr.b", // suggest named constructor |
| 387 | "3+b", // suggest named constructor |
| 388 | "3+a" |
| 389 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 390 | |
| 391 | // Type propagation. |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 392 | buildTests( |
| 393 | 'testCommentSnippets051', |
| 394 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 395 | class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{getKeys(){}} |
| 396 | void r() { |
| 397 | var v; |
| 398 | if (v is String) { |
| 399 | v.!1length; |
| 400 | v.!2getKeys; |
| 401 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 402 | }''', |
| 403 | <String>["1+length", "2-getKeys"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 404 | |
| 405 | // Type propagation. |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 406 | buildTests( |
| 407 | 'testCommentSnippets052', |
| 408 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 409 | class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{getKeys(){}} |
| 410 | void r() { |
| 411 | List<String> values = ['a','b','c']; |
| 412 | for (var v in values) { |
| 413 | v.!1toUpperCase; |
| 414 | v.!2getKeys; |
| 415 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 416 | }''', |
| 417 | <String>["1+toUpperCase", "2-getKeys"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 418 | |
| 419 | // Type propagation. |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 420 | buildTests( |
| 421 | 'testCommentSnippets053', |
| 422 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 423 | class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{getKeys(){}} |
| 424 | void r() { |
| 425 | var v; |
| 426 | while (v is String) { |
| 427 | v.!1toUpperCase; |
| 428 | v.!2getKeys; |
| 429 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 430 | }''', |
| 431 | <String>["1+toUpperCase", "2-getKeys"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 432 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 433 | buildTests( |
| 434 | 'testCommentSnippets054', |
| 435 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 436 | class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{getKeys(){}} |
| 437 | void r() { |
| 438 | var v; |
| 439 | for (; v is String; v.!1isEmpty) { |
| 440 | v.!2toUpperCase; |
| 441 | v.!3getKeys; |
| 442 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 443 | }''', |
| 444 | <String>["1+isEmpty", "2+toUpperCase", "3-getKeys"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 445 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 446 | buildTests( |
| 447 | 'testCommentSnippets055', |
| 448 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 449 | class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{getKeys(){}} |
| 450 | void r() { |
| 451 | String v; |
| 452 | if (v is Object) { |
| 453 | v.!1toUpperCase; |
| 454 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 455 | }''', |
| 456 | <String>["1+toUpperCase"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 457 | |
| 458 | // Type propagation. |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 459 | buildTests( |
| 460 | 'testCommentSnippets056', |
| 461 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 462 | class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{getKeys(){}} |
| 463 | void f(var v) { |
| 464 | if (v is!! String) { |
| 465 | return; |
| 466 | } |
| 467 | v.!1toUpperCase; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 468 | }''', |
| 469 | <String>["1+toUpperCase"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 470 | |
| 471 | // Type propagation. |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 472 | buildTests( |
| 473 | 'testCommentSnippets057', |
| 474 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 475 | class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{getKeys(){}} |
| 476 | void f(var v) { |
danrubel@google.com | dc95fd3 | 2015-02-06 04:43:15 +0000 | [diff] [blame] | 477 | if ((v as String).!2length == 0) { |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 478 | v.!1toUpperCase; |
| 479 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 480 | }''', |
| 481 | <String>["1+toUpperCase", "2+length"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 482 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 483 | buildTests( |
| 484 | 'testCommentSnippets058', |
| 485 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 486 | typedef vo!2id callback(int k); |
| 487 | void x(callback q){} |
| 488 | void r() { |
| 489 | callback v; |
| 490 | x(!1); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 491 | }''', |
| 492 | <String>["1+v", "2+void"], |
| 493 | failingTests: '2'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 494 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 495 | buildTests( |
| 496 | 'testCommentSnippets059', |
| 497 | ''' |
| 498 | f(){((int x) => x+4).!1call(1);}''', |
| 499 | <String>["1-call"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 500 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 501 | buildTests( |
| 502 | 'testCommentSnippets060', |
| 503 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 504 | class Map{} |
| 505 | abstract class MM extends Map{factory MM() => new Map();} |
| 506 | class Z { |
| 507 | MM x; |
| 508 | f() { |
| 509 | x!1 |
| 510 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 511 | }''', |
| 512 | <String>["1+x", "1-x[]"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 513 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 514 | buildTests( |
| 515 | 'testCommentSnippets061', |
| 516 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 517 | class A{m(){!1f(3);!2}}n(){!3f(3);!4}f(x)=>x*3;''', |
| 518 | <String>["1+f", "1+n", "2+f", "2+n", "3+f", "3+n", "4+f", "4+n"]); |
| 519 | |
| 520 | // Type propagation. |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 521 | buildTests( |
| 522 | 'testCommentSnippets063', |
| 523 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 524 | class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{getKeys(){}} |
| 525 | void r(var v) { |
| 526 | v.!1toUpperCase; |
| 527 | assert(v is String); |
| 528 | v.!2toUpperCase; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 529 | }''', |
| 530 | <String>["1-toUpperCase", "2+toUpperCase"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 531 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 532 | buildTests( |
| 533 | 'testCommentSnippets064', |
| 534 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 535 | class Spline { |
| 536 | Line c; |
| 537 | Spline a() { |
| 538 | return this; |
| 539 | } |
| 540 | Line b() { |
| 541 | return null; |
| 542 | } |
| 543 | Spline f() { |
| 544 | Line x = new Line(); |
| 545 | x.!9h()..!1a()..!2b().!7g(); |
| 546 | x.!8j..!3b()..!4c..!6c..!5a(); |
| 547 | } |
| 548 | } |
| 549 | class Line { |
| 550 | Spline j; |
| 551 | Line g() { |
| 552 | return this; |
| 553 | } |
| 554 | Spline h() { |
| 555 | return null; |
| 556 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 557 | }''', |
| 558 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 559 | "1+a", |
| 560 | "2+b", |
| 561 | "1-g", |
| 562 | "2-h", |
| 563 | "3+b", |
| 564 | "4+c", |
| 565 | "5+a", |
| 566 | "6+c", |
| 567 | "7+g", |
| 568 | "8+j", |
| 569 | "9+h" |
| 570 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 571 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 572 | buildTests( |
| 573 | 'testCommentSnippets065', |
| 574 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 575 | class Spline { |
| 576 | Line c; |
| 577 | Spline a() { |
| 578 | return this; |
| 579 | } |
| 580 | Line b() { |
| 581 | return null; |
| 582 | } |
| 583 | Spline f() { |
| 584 | Line x = new Line(); |
| 585 | x.h()..!1; |
| 586 | } |
| 587 | } |
| 588 | class Line { |
| 589 | Spline j; |
| 590 | Line g() { |
| 591 | return this; |
| 592 | } |
| 593 | Spline h() { |
| 594 | return null; |
| 595 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 596 | }''', |
| 597 | <String>["1+a"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 598 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 599 | buildTests( |
| 600 | 'testCommentSnippets066', |
| 601 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 602 | class Spline { |
| 603 | Line c; |
| 604 | Spline a() { |
| 605 | return this; |
| 606 | } |
| 607 | Line b() { |
| 608 | return null; |
| 609 | } |
| 610 | Spline f() { |
| 611 | Line x = new Line(); |
| 612 | x.h()..a()..!1; |
| 613 | } |
| 614 | } |
| 615 | class Line { |
| 616 | Spline j; |
| 617 | Line g() { |
| 618 | return this; |
| 619 | } |
| 620 | Spline h() { |
| 621 | return null; |
| 622 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 623 | }''', |
| 624 | <String>["1+b"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 625 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 626 | buildTests( |
| 627 | 'testCommentSnippets067', |
| 628 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 629 | class Spline { |
| 630 | Line c; |
| 631 | Spline a() { |
| 632 | return this; |
| 633 | } |
| 634 | Line b() { |
| 635 | return null; |
| 636 | } |
| 637 | Spline f() { |
| 638 | Line x = new Line(); |
| 639 | x.h()..a()..c..!1; |
| 640 | } |
| 641 | } |
| 642 | class Line { |
| 643 | Spline j; |
| 644 | Line g() { |
| 645 | return this; |
| 646 | } |
| 647 | Spline h() { |
| 648 | return null; |
| 649 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 650 | }''', |
| 651 | <String>["1+b"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 652 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 653 | buildTests( |
| 654 | 'testCommentSnippets068', |
| 655 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 656 | class Spline { |
| 657 | Line c; |
| 658 | Spline a() { |
| 659 | return this; |
| 660 | } |
| 661 | Line b() { |
| 662 | return null; |
| 663 | } |
| 664 | Spline f() { |
| 665 | Line x = new Line(); |
| 666 | x.j..b()..c..!1; |
| 667 | } |
| 668 | } |
| 669 | class Line { |
| 670 | Spline j; |
| 671 | Line g() { |
| 672 | return this; |
| 673 | } |
| 674 | Spline h() { |
| 675 | return null; |
| 676 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 677 | }''', |
| 678 | <String>["1+c"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 679 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 680 | buildTests( |
| 681 | 'testCommentSnippets069', |
| 682 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 683 | class Spline { |
| 684 | Line c; |
| 685 | Spline a() { |
| 686 | return this; |
| 687 | } |
| 688 | Line b() { |
| 689 | return null; |
| 690 | } |
| 691 | Spline f() { |
| 692 | Line x = new Line(); |
| 693 | x.j..b()..!1; |
| 694 | } |
| 695 | } |
| 696 | class Line { |
| 697 | Spline j; |
| 698 | Line g() { |
| 699 | return this; |
| 700 | } |
| 701 | Spline h() { |
| 702 | return null; |
| 703 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 704 | }''', |
| 705 | <String>["1+c"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 706 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 707 | buildTests( |
| 708 | 'testCommentSnippets070', |
| 709 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 710 | class Spline { |
| 711 | Line c; |
| 712 | Spline a() { |
| 713 | return this; |
| 714 | } |
| 715 | Line b() { |
| 716 | return null; |
| 717 | } |
| 718 | Spline f() { |
| 719 | Line x = new Line(); |
| 720 | x.j..!1; |
| 721 | } |
| 722 | } |
| 723 | class Line { |
| 724 | Spline j; |
| 725 | Line g() { |
| 726 | return this; |
| 727 | } |
| 728 | Spline h() { |
| 729 | return null; |
| 730 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 731 | }''', |
| 732 | <String>["1+b"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 733 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 734 | buildTests( |
| 735 | 'testCommentSnippets072', |
| 736 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 737 | class X { |
| 738 | int _p; |
| 739 | set p(int x) => _p = x; |
| 740 | } |
| 741 | f() { |
| 742 | X x = new X(); |
| 743 | x.!1p = 3; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 744 | }''', |
| 745 | <String>["1+p"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 746 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 747 | buildTests( |
| 748 | 'testCommentSnippets073', |
| 749 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 750 | class X { |
| 751 | m() { |
| 752 | JSON.stri!1; |
| 753 | X f = null; |
| 754 | } |
| 755 | } |
| 756 | class JSON { |
| 757 | static stringify() {} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 758 | }''', |
| 759 | <String>["1+stringify"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 760 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 761 | buildTests( |
| 762 | 'testCommentSnippets074', |
| 763 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 764 | class X { |
| 765 | m() { |
| 766 | _x!1 |
| 767 | } |
| 768 | _x1(){} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 769 | }''', |
| 770 | <String>["1+_x1"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 771 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 772 | buildTests( |
| 773 | 'testCommentSnippets075', |
| 774 | ''' |
| 775 | p(x)=>0;var E;f(q)=>!1p(!2E);''', |
| 776 | <String>["1+p", "2+E"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 777 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 778 | buildTests( |
| 779 | 'testCommentSnippets076', |
| 780 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 781 | class Map<K,V>{}class List<E>{}class int{}main() {var m=new Map<Lis!1t<Map<int,in!2t>>,List<!3int>>();}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 782 | <String>["1+List", "2+int", "3+int"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 783 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 784 | buildTests( |
| 785 | 'testCommentSnippets076a', |
| 786 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 787 | class Map<K,V>{}class List<E>{}class int{}main() {var m=new Map<Lis!1t<Map<int,in!2t>>,List<!3>>();}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 788 | <String>["1+List", "2+int", "3+int"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 789 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 790 | buildTests( |
| 791 | 'testCommentSnippets077', |
| 792 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 793 | class FileMode { |
| 794 | static const READ = const FileMode._internal(0); |
| 795 | static const WRITE = const FileMode._internal(1); |
| 796 | static const APPEND = const FileMode._internal(2); |
| 797 | const FileMode._internal(int this._mode); |
| 798 | factory FileMode._internal1(int this._mode); |
| 799 | factory FileMode(_mode); |
| 800 | final int _mode; |
| 801 | } |
| 802 | class File { |
| 803 | factory File(String path) => null; |
| 804 | factory File.fromPath(Path path) => null; |
| 805 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 806 | f() => new Fil!1''', |
| 807 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 808 | "1+File", |
| 809 | "1+File.fromPath", |
| 810 | "1+FileMode", |
| 811 | "1+FileMode._internal1", |
| 812 | "1+FileMode._internal" |
| 813 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 814 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 815 | buildTests( |
| 816 | 'testCommentSnippets078', |
| 817 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 818 | class Map{static from()=>null;clear(){}}void main() { Map.!1 }''', |
| 819 | <String>["1+from", "1-clear"]); // static method, instance method |
| 820 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 821 | buildTests( |
| 822 | 'testCommentSnippets079', |
| 823 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 824 | class Map{static from()=>null;clear(){}}void main() { Map s; s.!1 }''', |
danrubel@google.com | 5194a2b | 2015-02-07 00:56:15 +0000 | [diff] [blame] | 825 | <String>["1-from", "1+clear"]); // static method, instance method |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 826 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 827 | buildTests( |
| 828 | 'testCommentSnippets080', |
| 829 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 830 | class RuntimeError{var message;}void main() { RuntimeError.!1 }''', |
| 831 | <String>["1-message"]); // field |
| 832 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 833 | buildTests( |
| 834 | 'testCommentSnippets081', |
| 835 | ''' |
| 836 | class Foo {this.!1}''', |
| 837 | <String>["1-Object"], |
| 838 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 839 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 840 | buildTests( |
| 841 | 'testCommentSnippets082', |
| 842 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 843 | class HttpRequest {} |
| 844 | class HttpResponse {} |
| 845 | main() { |
| 846 | var v = (HttpRequest req, HttpResp!1) |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 847 | }''', |
| 848 | <String>["1+HttpResponse"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 849 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 850 | buildTests( |
| 851 | 'testCommentSnippets083', |
| 852 | ''' |
| 853 | main() {(.!1)}''', |
| 854 | <String>["1-toString"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 855 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 856 | buildTests( |
| 857 | 'testCommentSnippets083a', |
| 858 | ''' |
| 859 | main() { .!1 }''', |
| 860 | <String>["1-toString"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 861 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 862 | buildTests( |
| 863 | 'testCommentSnippets083b', |
| 864 | ''' |
| 865 | main() { null.!1 }''', |
| 866 | <String>["1+toString"], |
| 867 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 868 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 869 | buildTests( |
| 870 | 'testCommentSnippets084', |
| 871 | ''' |
| 872 | class List{}class Map{}typedef X = !1Lis!2t with !3Ma!4p;''', |
| 873 | <String>["1+Map", "2+List", "2-Map", "3+List", "4+Map", "4-List"], |
| 874 | failingTests: '1234'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 875 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 876 | buildTests( |
| 877 | 'testCommentSnippets085', |
| 878 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 879 | class List{}class Map{}class Z extends List with !1Ma!2p {}''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 880 | <String>["1+List", "1+Map", "2+Map", "2-List"], |
| 881 | failingTests: '12'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 882 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 883 | buildTests( |
| 884 | 'testCommentSnippets086', |
| 885 | ''' |
| 886 | class Q{f(){xy() {!2};x!1y();}}''', |
| 887 | <String>["1+xy", "2+f", "2-xy"], |
paulberry@google.com | 8799848 | 2014-12-17 14:42:29 +0000 | [diff] [blame] | 888 | failingTests: '2'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 889 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 890 | buildTests( |
| 891 | 'testCommentSnippets087', |
| 892 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 893 | class Map{}class Q extends Object with !1Map {}''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 894 | <String>["1+Map", "1-HashMap"], |
| 895 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 896 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 897 | buildTests( |
| 898 | 'testCommentSnippets088', |
| 899 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 900 | class A { |
| 901 | int f; |
| 902 | B m(){} |
| 903 | } |
| 904 | class B extends A { |
| 905 | num f; |
| 906 | A m(){} |
| 907 | } |
| 908 | class Z { |
| 909 | B q; |
| 910 | f() {q.!1} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 911 | }''', |
| 912 | <String>["1+f", "1+m"]); // f->num, m()->A |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 913 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 914 | buildTests( |
| 915 | 'testCommentSnippets089', |
| 916 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 917 | class Q { |
| 918 | fqe() { |
| 919 | xya() { |
| 920 | xyb() { |
| 921 | !1 |
| 922 | } |
| 923 | !3 xyb(); |
| 924 | }; |
| 925 | xza() { |
| 926 | !2 |
| 927 | } |
| 928 | xya(); |
| 929 | !4 xza(); |
| 930 | } |
| 931 | fqi() { |
| 932 | !5 |
| 933 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 934 | }''', |
| 935 | <String>[ |
| 936 | "1+fqe", |
| 937 | "1+fqi", |
| 938 | "1+Q", |
| 939 | "1-xya", |
| 940 | "1-xyb", |
| 941 | "1-xza", |
| 942 | "2+fqe", |
| 943 | "2+fqi", |
| 944 | "2+Q", |
| 945 | "2-xya", |
| 946 | "2-xyb", |
| 947 | "2-xza", |
| 948 | "3+fqe", |
| 949 | "3+fqi", |
| 950 | "3+Q", |
| 951 | "3-xya", |
| 952 | "3+xyb", |
| 953 | "3-xza", |
| 954 | "4+fqe", |
| 955 | "4+fqi", |
| 956 | "4+Q", |
| 957 | "4+xya", |
| 958 | "4-xyb", |
| 959 | "4+xza", |
| 960 | "5+fqe", |
| 961 | "5+fqi", |
| 962 | "5+Q", |
| 963 | "5-xya", |
| 964 | "5-xyb", |
| 965 | "5-xza" |
| 966 | ], |
| 967 | failingTests: '123'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 968 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 969 | buildTests( |
| 970 | 'testCommentSnippets090', |
| 971 | ''' |
| 972 | class X { f() { var a = 'x'; a.!1 }}''', |
| 973 | <String>["1+length"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | void buildCompletionTests() { |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 977 | buildTests( |
| 978 | 'testCompletion_alias_field', |
| 979 | ''' |
| 980 | typedef int fnint(int k); fn!1int x;''', |
| 981 | <String>["1+fnint"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 982 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 983 | buildTests( |
| 984 | 'testCompletion_annotation_argumentList', |
| 985 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 986 | class AAA {", |
| 987 | const AAA({int aaa, int bbb});", |
| 988 | }", |
| 989 | ", |
| 990 | @AAA(!1) |
| 991 | main() { |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 992 | }''', |
| 993 | <String>[ |
| 994 | "1+AAA" /*":" + ProposalKind.ARGUMENT_LIST*/, |
| 995 | "1+aaa", |
| 996 | "1+bbb" |
| 997 | ], |
paulberry@google.com | 2461125 | 2014-12-09 16:44:12 +0000 | [diff] [blame] | 998 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 999 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1000 | buildTests( |
| 1001 | 'testCompletion_annotation_topLevelVar', |
| 1002 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1003 | const fooConst = null; |
| 1004 | final fooNotConst = null; |
| 1005 | const bar = null; |
| 1006 | |
| 1007 | @foo!1 |
| 1008 | main() { |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1009 | }''', |
| 1010 | <String>["1+fooConst", "1-fooNotConst", "1-bar"], |
| 1011 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1012 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1013 | buildTests( |
| 1014 | 'testCompletion_annotation_type', |
| 1015 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1016 | class AAA { |
| 1017 | const AAA({int a, int b}); |
| 1018 | const AAA.nnn(int c, int d); |
| 1019 | } |
| 1020 | @AAA!1 |
| 1021 | main() { |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1022 | }''', |
| 1023 | <String>[ |
| 1024 | "1+AAA" /*":" + ProposalKind.CONSTRUCTOR*/, |
| 1025 | "1+AAA.nnn" /*":" + ProposalKind.CONSTRUCTOR*/ |
| 1026 | ], |
| 1027 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1028 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1029 | buildTests( |
| 1030 | 'testCompletion_annotation_type_inClass_withoutMember', |
| 1031 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1032 | class AAA { |
| 1033 | const AAA(); |
| 1034 | } |
| 1035 | |
| 1036 | class C { |
| 1037 | @A!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1038 | }''', |
| 1039 | <String>["1+AAA" /*":" + ProposalKind.CONSTRUCTOR*/]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1040 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1041 | buildTests( |
| 1042 | 'testCompletion_argument_typeName', |
| 1043 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1044 | class Enum { |
| 1045 | static Enum FOO = new Enum(); |
| 1046 | } |
| 1047 | f(Enum e) {} |
| 1048 | main() { |
| 1049 | f(En!1); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1050 | }''', |
| 1051 | <String>["1+Enum"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1052 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1053 | buildTests( |
| 1054 | 'testCompletion_arguments_ignoreEmpty', |
| 1055 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1056 | class A { |
| 1057 | test() {} |
| 1058 | } |
| 1059 | main(A a) { |
| 1060 | a.test(!1); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1061 | }''', |
| 1062 | <String>["1-test"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1063 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1064 | buildTests( |
| 1065 | 'testCompletion_as_asIdentifierPrefix', |
| 1066 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1067 | main(p) { |
| 1068 | var asVisible; |
| 1069 | var v = as!1; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1070 | }''', |
| 1071 | <String>["1+asVisible"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1072 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1073 | buildTests( |
| 1074 | 'testCompletion_as_asPrefixedIdentifierStart', |
| 1075 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1076 | class A { |
| 1077 | var asVisible; |
| 1078 | } |
| 1079 | |
| 1080 | main(A p) { |
| 1081 | var v = p.as!1; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1082 | }''', |
| 1083 | <String>["1+asVisible"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1084 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1085 | buildTests( |
| 1086 | 'testCompletion_as_incompleteStatement', |
| 1087 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1088 | class MyClass {} |
| 1089 | main(p) { |
| 1090 | var justSomeVar; |
| 1091 | var v = p as !1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1092 | }''', |
| 1093 | <String>["1+MyClass", "1-justSomeVar"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1094 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1095 | buildTests( |
| 1096 | 'testCompletion_cascade', |
| 1097 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1098 | class A { |
| 1099 | aaa() {} |
| 1100 | } |
| 1101 | |
| 1102 | |
| 1103 | main(A a) { |
| 1104 | a..!1 aaa(); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1105 | }''', |
| 1106 | <String>["1+aaa", "1-main"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1107 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1108 | buildTests( |
| 1109 | 'testCompletion_combinator_afterComma', |
| 1110 | ''' |
danrubel | 372cb6b | 2015-12-06 15:34:19 -0500 | [diff] [blame] | 1111 | import 'dart:math' show cos, !1;''', |
| 1112 | <String>["1+PI", "1+sin", "1+Random", "1-String"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1113 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1114 | buildTests( |
| 1115 | 'testCompletion_combinator_ended', |
| 1116 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1117 | import 'dart:math' show !1;"''', |
danrubel | 372cb6b | 2015-12-06 15:34:19 -0500 | [diff] [blame] | 1118 | <String>["1+PI", "1+sin", "1+Random", "1-String"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1119 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1120 | buildTests( |
| 1121 | 'testCompletion_combinator_export', |
| 1122 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1123 | export 'dart:math' show !1;"''', |
danrubel | 372cb6b | 2015-12-06 15:34:19 -0500 | [diff] [blame] | 1124 | <String>["1+PI", "1+sin", "1+Random", "1-String"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1125 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1126 | buildTests( |
| 1127 | 'testCompletion_combinator_hide', |
| 1128 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1129 | import 'dart:math' hide !1;"''', |
danrubel | 372cb6b | 2015-12-06 15:34:19 -0500 | [diff] [blame] | 1130 | <String>["1+PI", "1+sin", "1+Random", "1-String"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1131 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1132 | buildTests( |
| 1133 | 'testCompletion_combinator_notEnded', |
| 1134 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1135 | import 'dart:math' show !1"''', |
danrubel | 372cb6b | 2015-12-06 15:34:19 -0500 | [diff] [blame] | 1136 | <String>["1+PI", "1+sin", "1+Random", "1-String"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1137 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1138 | buildTests( |
| 1139 | 'testCompletion_combinator_usePrefix', |
| 1140 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1141 | import 'dart:math' show s!1"''', |
danrubel | 372cb6b | 2015-12-06 15:34:19 -0500 | [diff] [blame] | 1142 | <String>["1+sin", "1+sqrt", "1-cos", "1-String"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1143 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1144 | buildTests( |
| 1145 | 'testCompletion_constructor_field', |
| 1146 | ''' |
| 1147 | class X { X(this.field); int f!1ield;}''', |
| 1148 | <String>["1+field"], |
danrubel@google.com | ddc3cae | 2014-12-16 16:53:24 +0000 | [diff] [blame] | 1149 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1150 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1151 | buildTests( |
| 1152 | 'testCompletion_constructorArguments_showOnlyCurrent', |
| 1153 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1154 | class A { |
| 1155 | A.first(int p); |
| 1156 | A.second(double p); |
| 1157 | } |
| 1158 | main() { |
| 1159 | new A.first(!1); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1160 | }''', |
| 1161 | <String>["1+A.first", "1-A.second"], |
| 1162 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1163 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1164 | buildTests( |
| 1165 | 'testCompletion_constructorArguments_whenPrefixedType', |
| 1166 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1167 | import 'dart:math' as m; |
| 1168 | main() { |
| 1169 | new m.Random(!1); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1170 | }''', |
| 1171 | <String>["1+Random:ARGUMENT_LIST"], |
| 1172 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1173 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1174 | buildTests( |
| 1175 | 'testCompletion_dartDoc_reference_forClass', |
| 1176 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1177 | /** |
| 1178 | * [int!1] |
| 1179 | * [method!2] |
| 1180 | */ |
| 1181 | class AAA { |
| 1182 | methodA() {} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1183 | }''', |
| 1184 | <String>["1+int", "1-method", "2+methodA", "2-int"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1185 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1186 | buildTests( |
| 1187 | 'testCompletion_dartDoc_reference_forConstructor', |
| 1188 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1189 | class A { |
| 1190 | /** |
| 1191 | * [aa!1] |
| 1192 | * [int!2] |
| 1193 | * [method!3] |
| 1194 | */ |
| 1195 | A.named(aaa, bbb) {} |
| 1196 | methodA() {} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1197 | }''', |
| 1198 | <String>["1+aaa", "1-bbb", "2+int", "2-double", "3+methodA"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1199 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1200 | buildTests( |
| 1201 | 'testCompletion_dartDoc_reference_forFunction', |
| 1202 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1203 | /** |
| 1204 | * [aa!1] |
| 1205 | * [int!2] |
| 1206 | * [function!3] |
| 1207 | */ |
| 1208 | functionA(aaa, bbb) {} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1209 | functionB() {}''', |
| 1210 | <String>[ |
| 1211 | "1+aaa", |
| 1212 | "1-bbb", |
| 1213 | "2+int", |
| 1214 | "2-double", |
| 1215 | "3+functionA", |
| 1216 | "3+functionB", |
| 1217 | "3-int" |
| 1218 | ], |
| 1219 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1220 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1221 | buildTests( |
| 1222 | 'testCompletion_dartDoc_reference_forFunctionTypeAlias', |
| 1223 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1224 | /** |
| 1225 | * [aa!1] |
| 1226 | * [int!2] |
| 1227 | * [Function!3] |
| 1228 | */ |
| 1229 | typedef FunctionA(aaa, bbb) {} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1230 | typedef FunctionB() {}''', |
| 1231 | <String>[ |
| 1232 | "1+aaa", |
| 1233 | "1-bbb", |
| 1234 | "2+int", |
| 1235 | "2-double", |
| 1236 | "3+FunctionA", |
| 1237 | "3+FunctionB", |
| 1238 | "3-int" |
| 1239 | ], |
| 1240 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1241 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1242 | buildTests( |
| 1243 | 'testCompletion_dartDoc_reference_forMethod', |
| 1244 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1245 | class A { |
| 1246 | /** |
| 1247 | * [aa!1] |
| 1248 | * [int!2] |
| 1249 | * [method!3] |
| 1250 | */ |
| 1251 | methodA(aaa, bbb) {} |
| 1252 | methodB() {} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1253 | }''', |
| 1254 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 1255 | "1+aaa", |
| 1256 | "1-bbb", |
| 1257 | "2+int", |
| 1258 | "2-double", |
| 1259 | "3+methodA", |
| 1260 | "3+methodB", |
| 1261 | "3-int" |
| 1262 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1263 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1264 | buildTests( |
| 1265 | 'testCompletion_dartDoc_reference_incomplete', |
| 1266 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1267 | /** |
| 1268 | * [doubl!1 some text |
| 1269 | * other text |
| 1270 | */ |
| 1271 | class A {} |
| 1272 | /** |
| 1273 | * [!2 some text |
| 1274 | * other text |
| 1275 | */ |
| 1276 | class B {} |
| 1277 | /** |
| 1278 | * [!3] some text |
| 1279 | */ |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1280 | class C {}''', |
| 1281 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 1282 | "1+double", |
| 1283 | "1-int", |
| 1284 | "2+int", |
| 1285 | "2+String", |
| 1286 | "3+int", |
| 1287 | "3+String" |
| 1288 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1289 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1290 | buildTests( |
| 1291 | 'testCompletion_double_inFractionPart', |
| 1292 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1293 | main() { |
| 1294 | 1.0!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1295 | }''', |
| 1296 | <String>["1-abs", "1-main"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1297 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1298 | buildTests( |
| 1299 | 'testCompletion_enum', |
| 1300 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1301 | enum MyEnum {A, B, C} |
| 1302 | main() { |
| 1303 | MyEnum.!1; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1304 | }''', |
| 1305 | <String>["1+values", "1+A", "1+B", "1+C"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1306 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1307 | buildTests( |
| 1308 | 'testCompletion_exactPrefix_hasHigherRelevance', |
| 1309 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1310 | var STR; |
| 1311 | main(p) { |
| 1312 | var str; |
| 1313 | str!1; |
| 1314 | STR!2; |
| 1315 | Str!3; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1316 | }''', |
| 1317 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 1318 | "1+str" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 1)*/, |
| 1319 | "1+STR" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/, |
| 1320 | "2+STR" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 1)*/, |
| 1321 | "2+str" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/, |
| 1322 | "3+String" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 1)*/, |
| 1323 | "3+STR" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/, |
| 1324 | "3+str" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/ |
| 1325 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1326 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1327 | buildTests( |
| 1328 | 'testCompletion_export_dart', |
| 1329 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1330 | import 'dart:math |
| 1331 | import 'dart:_chrome |
| 1332 | import 'dart:_collection.dev |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1333 | export 'dart:!1''', |
| 1334 | <String>[ |
| 1335 | "1+dart:core", |
| 1336 | "1+dart:math", |
| 1337 | "1-dart:_chrome", |
| 1338 | "1-dart:_collection.dev" |
Dan Rubel | 0232959 | 2016-09-14 11:22:25 -0400 | [diff] [blame] | 1339 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1340 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1341 | buildTests( |
| 1342 | 'testCompletion_export_noStringLiteral_noSemicolon', |
| 1343 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1344 | import !1 |
| 1345 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1346 | class A {}''', |
| 1347 | <String>["1+'dart:!';", "1+'package:!';"], |
| 1348 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1349 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1350 | buildTests( |
| 1351 | 'testCompletion_forStmt_vars', |
| 1352 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1353 | class int{}class Foo { mth() { for (in!1t i = 0; i!2 < 5; i!3++); }}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 1354 | <String>["1+int", "2+i", "3+i"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1355 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1356 | buildTests( |
| 1357 | 'testCompletion_function', |
| 1358 | ''' |
danrubel@google.com | ddc3cae | 2014-12-16 16:53:24 +0000 | [diff] [blame] | 1359 | class Foo { int boo = 7; mth() { PNGS.sort((String a, Str!1) => a.compareTo(b)); }}''', |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1360 | <String>["1+String"]); |
| 1361 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1362 | buildTests( |
| 1363 | 'testCompletion_function_partial', |
| 1364 | ''' |
danrubel@google.com | ddc3cae | 2014-12-16 16:53:24 +0000 | [diff] [blame] | 1365 | class Foo { int boo = 7; mth() { PNGS.sort((String a, Str!1)); }}''', |
| 1366 | <String>["1+String"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1367 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1368 | buildTests( |
| 1369 | 'testCompletion_functionTypeParameter_namedArgument', |
| 1370 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1371 | typedef FFF(a, b, {x1, x2, y}); |
| 1372 | main(FFF fff) { |
| 1373 | fff(1, 2, !1)!2; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1374 | }''', |
| 1375 | <String>["1+x1", "2-x2"], |
| 1376 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1377 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1378 | buildTests( |
| 1379 | 'testCompletion_ifStmt_field1', |
| 1380 | ''' |
| 1381 | class Foo { int myField = 7; mth() { if (!1) {}}}''', |
| 1382 | <String>["1+myField"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1383 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1384 | buildTests( |
| 1385 | 'testCompletion_ifStmt_field1a', |
| 1386 | ''' |
| 1387 | class Foo { int myField = 7; mth() { if (!1) }}''', |
| 1388 | <String>["1+myField"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1389 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1390 | buildTests( |
| 1391 | 'testCompletion_ifStmt_field2', |
| 1392 | ''' |
| 1393 | class Foo { int myField = 7; mth() { if (m!1) {}}}''', |
| 1394 | <String>["1+myField"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1395 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1396 | buildTests( |
| 1397 | 'testCompletion_ifStmt_field2a', |
| 1398 | ''' |
| 1399 | class Foo { int myField = 7; mth() { if (m!1) }}''', |
| 1400 | <String>["1+myField"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1401 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1402 | buildTests( |
| 1403 | 'testCompletion_ifStmt_field2b', |
| 1404 | ''' |
| 1405 | class Foo { myField = 7; mth() { if (m!1) {}}}''', |
| 1406 | <String>["1+myField"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1407 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1408 | buildTests( |
| 1409 | 'testCompletion_ifStmt_localVar', |
| 1410 | ''' |
| 1411 | class Foo { mth() { int value = 7; if (v!1) {}}}''', |
| 1412 | <String>["1+value"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1413 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1414 | buildTests( |
| 1415 | 'testCompletion_ifStmt_localVara', |
| 1416 | ''' |
| 1417 | class Foo { mth() { value = 7; if (v!1) {}}}''', |
| 1418 | <String>["1-value"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1419 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1420 | buildTests( |
| 1421 | 'testCompletion_ifStmt_topLevelVar', |
| 1422 | ''' |
| 1423 | int topValue = 7; class Foo { mth() { if (t!1) {}}}''', |
| 1424 | <String>["1+topValue"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1425 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1426 | buildTests( |
| 1427 | 'testCompletion_ifStmt_topLevelVara', |
| 1428 | ''' |
| 1429 | topValue = 7; class Foo { mth() { if (t!1) {}}}''', |
| 1430 | <String>["1+topValue"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1431 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1432 | buildTests( |
| 1433 | 'testCompletion_ifStmt_unionType_nonStrict', |
| 1434 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1435 | class A { a() => null; x() => null} |
| 1436 | class B { a() => null; y() => null} |
| 1437 | void main() { |
| 1438 | var x; |
| 1439 | var c; |
| 1440 | if(c) { |
| 1441 | x = new A(); |
| 1442 | } else { |
| 1443 | x = new B(); |
| 1444 | } |
| 1445 | x.!1; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1446 | }''', |
| 1447 | <String>["1+a", "1+x", "1+y"], |
| 1448 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1449 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1450 | buildTests( |
| 1451 | 'testCompletion_ifStmt_unionType_strict', |
| 1452 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1453 | class A { a() => null; x() => null} |
| 1454 | class B { a() => null; y() => null} |
| 1455 | void main() { |
| 1456 | var x; |
| 1457 | var c; |
| 1458 | if(c) { |
| 1459 | x = new A(); |
| 1460 | } else { |
| 1461 | x = new B(); |
| 1462 | } |
| 1463 | x.!1; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1464 | }''', |
| 1465 | <String>["1+a", "1-x", "1-y"], |
| 1466 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1467 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1468 | buildTests( |
| 1469 | 'testCompletion_import', |
| 1470 | ''' |
| 1471 | import '!1';''', |
| 1472 | <String>["1+dart:!", "1+package:!"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1473 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1474 | buildTests( |
| 1475 | 'testCompletion_import_dart', |
| 1476 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1477 | import 'dart:math |
| 1478 | import 'dart:_chrome |
| 1479 | import 'dart:_collection.dev |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1480 | import 'dart:!1''', |
| 1481 | <String>[ |
| 1482 | "1+dart:core", |
| 1483 | "1+dart:math", |
| 1484 | "1-dart:_chrome", |
| 1485 | "1-dart:_collection.dev" |
Dan Rubel | 0232959 | 2016-09-14 11:22:25 -0400 | [diff] [blame] | 1486 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1487 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1488 | buildTests( |
| 1489 | 'testCompletion_import_hasStringLiteral_noSemicolon', |
| 1490 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1491 | import '!1' |
| 1492 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1493 | class A {}''', |
| 1494 | <String>["1+dart:!", "1+package:!"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1495 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1496 | buildTests( |
| 1497 | 'testCompletion_import_noSpace', |
| 1498 | ''' |
| 1499 | import!1''', |
| 1500 | <String>["1+ 'dart:!';", "1+ 'package:!';"], |
| 1501 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1502 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1503 | buildTests( |
| 1504 | 'testCompletion_import_noStringLiteral', |
| 1505 | ''' |
| 1506 | import !1;''', |
| 1507 | <String>["1+'dart:!'", "1+'package:!'"], |
| 1508 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1509 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1510 | buildTests( |
| 1511 | 'testCompletion_import_noStringLiteral_noSemicolon', |
| 1512 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1513 | import !1 |
| 1514 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1515 | class A {}''', |
| 1516 | <String>["1+'dart:!';", "1+'package:!';"], |
| 1517 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1518 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1519 | buildTests( |
| 1520 | 'testCompletion_incompleteClassMember', |
| 1521 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1522 | class A { |
| 1523 | Str!1 |
| 1524 | final f = null; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1525 | }''', |
| 1526 | <String>["1+String", "1-bool"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1527 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1528 | buildTests( |
| 1529 | 'testCompletion_incompleteClosure_parameterType', |
| 1530 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1531 | f1(cb(String s)) {} |
| 1532 | f2(String s) {} |
| 1533 | main() { |
| 1534 | f1((Str!1)); |
| 1535 | f2((Str!2)); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1536 | }''', |
| 1537 | <String>["1+String", "1-bool", "2+String", "2-bool"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1538 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1539 | buildTests( |
| 1540 | 'testCompletion_inPeriodPeriod', |
| 1541 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1542 | main(String str) { |
| 1543 | 1 < str.!1.length; |
| 1544 | 1 + str.!2.length; |
| 1545 | 1 + 2 * str.!3.length; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1546 | }''', |
| 1547 | <String>["1+codeUnits", "2+codeUnits", "3+codeUnits"], |
paulberry@google.com | 2461125 | 2014-12-09 16:44:12 +0000 | [diff] [blame] | 1548 | failingTests: '123'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1549 | |
| 1550 | // no checks, but no exceptions |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1551 | buildTests( |
| 1552 | 'testCompletion_instanceCreation_unresolved', |
| 1553 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1554 | class A { |
| 1555 | } |
| 1556 | main() { |
| 1557 | new NoSuchClass(!1); |
| 1558 | new A.noSuchConstructor(!2); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1559 | }''', |
| 1560 | <String>["1+int", "2+int"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1561 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1562 | buildTests( |
| 1563 | 'testCompletion_import_lib', |
| 1564 | ''' |
| 1565 | import '!1''', |
| 1566 | <String>["1+my_lib.dart"], |
| 1567 | extraFiles: <String, String>{"/my_lib.dart": ""}, |
| 1568 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1569 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1570 | buildTests( |
| 1571 | 'testCompletion_is', |
| 1572 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1573 | class MyClass {} |
| 1574 | main(p) { |
| 1575 | var isVariable; |
| 1576 | if (p is MyCla!1) {} |
| 1577 | var v1 = p is MyCla!2; |
| 1578 | var v2 = p is !3; |
| 1579 | var v2 = p is!4; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1580 | }''', |
| 1581 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 1582 | "1+MyClass", |
| 1583 | "2+MyClass", |
| 1584 | "3+MyClass", |
| 1585 | "3-v1", |
| 1586 | "4+is", |
| 1587 | "4-isVariable" |
| 1588 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1589 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1590 | buildTests( |
| 1591 | 'testCompletion_is_asIdentifierStart', |
| 1592 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1593 | main(p) { |
| 1594 | var isVisible; |
| 1595 | var v1 = is!1; |
| 1596 | var v2 = is!2 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1597 | }''', |
| 1598 | <String>["1+isVisible", "2+isVisible"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1599 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1600 | buildTests( |
| 1601 | 'testCompletion_is_asPrefixedIdentifierStart', |
| 1602 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1603 | class A { |
| 1604 | var isVisible; |
| 1605 | } |
| 1606 | |
| 1607 | main(A p) { |
| 1608 | var v1 = p.is!1; |
| 1609 | var v2 = p.is!2 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1610 | }''', |
| 1611 | <String>["1+isVisible", "2+isVisible"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1612 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1613 | buildTests( |
| 1614 | 'testCompletion_is_incompleteStatement1', |
| 1615 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1616 | class MyClass {} |
| 1617 | main(p) { |
| 1618 | var justSomeVar; |
| 1619 | var v = p is !1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1620 | }''', |
| 1621 | <String>["1+MyClass", "1-justSomeVar"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1622 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1623 | buildTests( |
| 1624 | 'testCompletion_is_incompleteStatement2', |
| 1625 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1626 | class MyClass {} |
| 1627 | main(p) { |
| 1628 | var isVariable; |
| 1629 | var v = p is!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1630 | }''', |
Dan Rubel | bd95b13 | 2015-08-26 17:34:57 -0400 | [diff] [blame] | 1631 | <String>["1+is", "1-isVariable"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1632 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1633 | buildTests( |
| 1634 | 'testCompletion_keyword_in', |
| 1635 | ''' |
| 1636 | class Foo { int input = 7; mth() { if (in!1) {}}}''', |
| 1637 | <String>["1+input"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1638 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1639 | buildTests( |
| 1640 | 'testCompletion_keyword_syntheticIdentifier', |
| 1641 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1642 | main() { |
| 1643 | var caseVar; |
| 1644 | var otherVar; |
| 1645 | var v = case!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1646 | }''', |
| 1647 | <String>["1+caseVar", "1-otherVar"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1648 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1649 | buildTests( |
| 1650 | 'testCompletion_libraryIdentifier_atEOF', |
| 1651 | ''' |
| 1652 | library int.!1''', |
| 1653 | <String>["1-parse", "1-bool"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1654 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1655 | buildTests( |
| 1656 | 'testCompletion_libraryIdentifier_notEOF', |
| 1657 | ''' |
| 1658 | library int.!1''', |
| 1659 | <String>["1-parse", "1-bool"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1660 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1661 | buildTests( |
| 1662 | 'testCompletion_methodRef_asArg_incompatibleFunctionType', |
| 1663 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1664 | foo( f(int p) ) {} |
| 1665 | class Functions { |
| 1666 | static myFuncInt(int p) {} |
| 1667 | static myFuncDouble(double p) {} |
| 1668 | } |
| 1669 | bar(p) {} |
| 1670 | main(p) { |
| 1671 | foo( Functions.!1; ); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1672 | }''', |
| 1673 | <String>[ |
| 1674 | "1+myFuncInt" /*":" + ProposalKind.METHOD_NAME*/, |
| 1675 | "1-myFuncDouble" /*":" + ProposalKind.METHOD_NAME*/ |
| 1676 | ], |
| 1677 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1678 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1679 | buildTests( |
| 1680 | 'testCompletion_methodRef_asArg_notFunctionType', |
| 1681 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1682 | foo( f(int p) ) {} |
| 1683 | class Functions { |
| 1684 | static myFunc(int p) {} |
| 1685 | } |
| 1686 | bar(p) {} |
| 1687 | main(p) { |
| 1688 | foo( (int p) => Functions.!1; ); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1689 | }''', |
| 1690 | <String>[ |
| 1691 | "1+myFunc" /*":" + ProposalKind.METHOD*/, |
| 1692 | "1-myFunc" /*":" + ProposalKind.METHOD_NAME*/ |
| 1693 | ], |
| 1694 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1695 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1696 | buildTests( |
| 1697 | 'testCompletion_methodRef_asArg_ofFunctionType', |
| 1698 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1699 | foo( f(int p) ) {} |
| 1700 | class Functions { |
| 1701 | static int myFunc(int p) {} |
| 1702 | } |
| 1703 | main(p) { |
| 1704 | foo(Functions.!1); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1705 | }''', |
| 1706 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 1707 | "1+myFunc" /*":" + ProposalKind.METHOD*/, |
| 1708 | "1+myFunc" /*":" + ProposalKind.METHOD_NAME*/ |
| 1709 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1710 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1711 | buildTests( |
| 1712 | 'testCompletion_namedArgument_alreadyUsed', |
| 1713 | ''' |
| 1714 | func({foo}) {} main() { func(foo: 0, fo!1); }''', |
| 1715 | <String>["1-foo"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1716 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1717 | buildTests( |
| 1718 | 'testCompletion_namedArgument_constructor', |
| 1719 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1720 | class A {A({foo, bar}) {}} main() { new A(fo!1); }''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1721 | <String>["1+foo", "1-bar"], |
| 1722 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1723 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1724 | buildTests( |
| 1725 | 'testCompletion_namedArgument_empty', |
| 1726 | ''' |
| 1727 | func({foo, bar}) {} main() { func(!1); }''', |
| 1728 | <String>[ |
| 1729 | "1+foo" /*":" + ProposalKind.NAMED_ARGUMENT*/, |
| 1730 | "1-foo" /*":" + ProposalKind.OPTIONAL_ARGUMENT*/ |
| 1731 | ], |
| 1732 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1733 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1734 | buildTests( |
| 1735 | 'testCompletion_namedArgument_function', |
| 1736 | ''' |
danrubel@google.com | 7c9de02 | 2015-03-03 16:51:18 +0000 | [diff] [blame] | 1737 | func({foo, bar}) {} main() { func(fo!1); }''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1738 | <String>["1+foo", "1-bar"], |
| 1739 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1740 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1741 | buildTests( |
| 1742 | 'testCompletion_namedArgument_notNamed', |
| 1743 | ''' |
| 1744 | func([foo]) {} main() { func(fo!1); }''', |
| 1745 | <String>["1-foo"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1746 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1747 | buildTests( |
| 1748 | 'testCompletion_namedArgument_unresolvedFunction', |
| 1749 | ''' |
| 1750 | main() { func(fo!1); }''', |
| 1751 | <String>["1-foo"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1752 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1753 | buildTests( |
| 1754 | 'testCompletion_newMemberType1', |
| 1755 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1756 | class Collection{}class List extends Collection{}class Foo { !1 }''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 1757 | <String>["1+Collection", "1+List"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1758 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1759 | buildTests( |
| 1760 | 'testCompletion_newMemberType2', |
| 1761 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1762 | class Collection{}class List extends Collection{}class Foo {!1}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 1763 | <String>["1+Collection", "1+List"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1764 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1765 | buildTests( |
| 1766 | 'testCompletion_newMemberType3', |
| 1767 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1768 | class Collection{}class List extends Collection{}class Foo {L!1}''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 1769 | <String>["1-Collection", "1+List"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1770 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1771 | buildTests( |
| 1772 | 'testCompletion_newMemberType4', |
| 1773 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1774 | class Collection{}class List extends Collection{}class Foo {C!1}''', |
| 1775 | <String>["1+Collection", "1-List"]); |
| 1776 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1777 | buildTests( |
| 1778 | 'testCompletion_positionalArgument_constructor', |
| 1779 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1780 | class A { |
| 1781 | A([foo, bar]); |
| 1782 | } |
| 1783 | main() { |
| 1784 | new A(!1); |
| 1785 | new A(0, !2); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1786 | }''', |
| 1787 | <String>[ |
| 1788 | "1+foo" /*":" + ProposalKind.OPTIONAL_ARGUMENT*/, |
| 1789 | "1-bar", |
| 1790 | "2-foo", |
| 1791 | "2+bar" /*":" |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 1792 | + ProposalKind.OPTIONAL_ARGUMENT*/ |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1793 | ], |
| 1794 | failingTests: '12'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1795 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1796 | buildTests( |
| 1797 | 'testCompletion_positionalArgument_function', |
| 1798 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1799 | func([foo, bar]) {} |
| 1800 | main() { |
| 1801 | func(!1); |
| 1802 | func(0, !2); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1803 | }''', |
| 1804 | <String>[ |
| 1805 | "1+foo" /*":" + ProposalKind.OPTIONAL_ARGUMENT*/, |
| 1806 | "1-bar", |
| 1807 | "2-foo", |
| 1808 | "2+bar" /*":" |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 1809 | + ProposalKind.OPTIONAL_ARGUMENT*/ |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1810 | ], |
| 1811 | failingTests: '12'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1812 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1813 | buildTests( |
| 1814 | 'testCompletion_preferStaticType', |
| 1815 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1816 | class A { |
| 1817 | foo() {} |
| 1818 | } |
| 1819 | class B extends A { |
| 1820 | bar() {} |
| 1821 | } |
| 1822 | main() { |
| 1823 | A v = new B(); |
| 1824 | v.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1825 | }''', |
| 1826 | <String>[ |
| 1827 | "1+foo", |
| 1828 | "1-bar,potential=false,declaringType=B", |
| 1829 | "1+bar,potential=true,declaringType=B" |
| 1830 | ], |
| 1831 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1832 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1833 | buildTests( |
| 1834 | 'testCompletion_privateElement_sameLibrary_constructor', |
| 1835 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1836 | class A { |
| 1837 | A._c(); |
| 1838 | A.c(); |
| 1839 | } |
| 1840 | main() { |
| 1841 | new A.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1842 | }''', |
| 1843 | <String>["1+_c", "1+c"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1844 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1845 | buildTests( |
| 1846 | 'testCompletion_privateElement_sameLibrary_member', |
| 1847 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1848 | class A { |
| 1849 | _m() {} |
| 1850 | m() {} |
| 1851 | } |
| 1852 | main(A a) { |
| 1853 | a.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1854 | }''', |
| 1855 | <String>["1+_m", "1+m"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1856 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1857 | buildTests( |
| 1858 | 'testCompletion_propertyAccess_whenClassTarget', |
| 1859 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1860 | class A { |
| 1861 | static int FIELD; |
| 1862 | int field; |
| 1863 | } |
| 1864 | main() { |
| 1865 | A.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1866 | }''', |
| 1867 | <String>["1+FIELD", "1-field"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1868 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1869 | buildTests( |
| 1870 | 'testCompletion_propertyAccess_whenClassTarget_excludeSuper', |
| 1871 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1872 | class A { |
| 1873 | static int FIELD_A; |
| 1874 | static int methodA() {} |
| 1875 | } |
| 1876 | class B extends A { |
| 1877 | static int FIELD_B; |
| 1878 | static int methodB() {} |
| 1879 | } |
| 1880 | main() { |
| 1881 | B.!1; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1882 | }''', |
Dan Rubel | 824a012 | 2015-12-09 14:37:03 -0500 | [diff] [blame] | 1883 | <String>["1+FIELD_B", "1-FIELD_A", "1+methodB", "1-methodA"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1884 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1885 | buildTests( |
| 1886 | 'testCompletion_propertyAccess_whenInstanceTarget', |
| 1887 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1888 | class A { |
| 1889 | static int FIELD; |
| 1890 | int fieldA; |
| 1891 | } |
| 1892 | class B { |
| 1893 | A a; |
| 1894 | } |
| 1895 | class C extends A { |
| 1896 | int fieldC; |
| 1897 | } |
| 1898 | main(B b, C c) { |
| 1899 | b.a.!1; |
| 1900 | c.!2; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1901 | }''', |
| 1902 | <String>["1-FIELD", "1+fieldA", "2+fieldC", "2+fieldA"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1903 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1904 | buildTests( |
| 1905 | 'testCompletion_return_withIdentifierPrefix', |
| 1906 | ''' |
| 1907 | f() { var vvv = 42; return v!1 }''', |
| 1908 | <String>["1+vvv"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1909 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1910 | buildTests( |
| 1911 | 'testCompletion_return_withoutExpression', |
| 1912 | ''' |
| 1913 | f() { var vvv = 42; return !1 }''', |
| 1914 | <String>["1+vvv"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1915 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1916 | buildTests( |
| 1917 | 'testCompletion_staticField1', |
| 1918 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1919 | class num{}class Sunflower {static final n!2um MAX_D = 300;nu!3m xc, yc;Sun!4flower() {x!Xc = y!Yc = MA!1 }}''', |
danrubel@google.com | 25c6bba | 2015-04-20 15:29:28 +0000 | [diff] [blame] | 1920 | <String>["1+MAX_D", "X+xc", "Y+yc", "2+num", "3+num", "4+Sunflower"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1921 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1922 | buildTests( |
| 1923 | 'testCompletion_super_superType', |
| 1924 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1925 | class A { |
| 1926 | var fa; |
| 1927 | ma() {} |
| 1928 | } |
| 1929 | class B extends A { |
| 1930 | var fb; |
| 1931 | mb() {} |
| 1932 | main() { |
| 1933 | super.!1 |
| 1934 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1935 | }''', |
| 1936 | <String>["1+fa", "1-fb", "1+ma", "1-mb"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1937 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1938 | buildTests( |
| 1939 | 'testCompletion_superConstructorInvocation_noNamePrefix', |
| 1940 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1941 | class A { |
| 1942 | A.fooA(); |
| 1943 | A.fooB(); |
| 1944 | A.bar(); |
| 1945 | } |
| 1946 | class B extends A { |
| 1947 | B() : super.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1948 | }''', |
| 1949 | <String>["1+fooA", "1+fooB", "1+bar"], |
| 1950 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1951 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1952 | buildTests( |
| 1953 | 'testCompletion_superConstructorInvocation_withNamePrefix', |
| 1954 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1955 | class A { |
| 1956 | A.fooA(); |
| 1957 | A.fooB(); |
| 1958 | A.bar(); |
| 1959 | } |
| 1960 | class B extends A { |
| 1961 | B() : super.f!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1962 | }''', |
| 1963 | <String>["1+fooA", "1+fooB", "1-bar"], |
| 1964 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1965 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1966 | buildTests( |
| 1967 | 'testCompletion_this_bad_inConstructorInitializer', |
| 1968 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1969 | class A { |
| 1970 | var f; |
| 1971 | A() : f = this.!1; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1972 | }''', |
| 1973 | <String>["1-toString"], |
| 1974 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1975 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1976 | buildTests( |
| 1977 | 'testCompletion_this_bad_inFieldDeclaration', |
| 1978 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1979 | class A { |
| 1980 | var f = this.!1; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1981 | }''', |
| 1982 | <String>["1-toString"], |
| 1983 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1984 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1985 | buildTests( |
| 1986 | 'testCompletion_this_bad_inStaticMethod', |
| 1987 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1988 | class A { |
| 1989 | static m() { |
| 1990 | this.!1; |
| 1991 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1992 | }''', |
| 1993 | <String>["1-toString"], |
| 1994 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1995 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 1996 | buildTests( |
| 1997 | 'testCompletion_this_bad_inTopLevelFunction', |
| 1998 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 1999 | main() { |
| 2000 | this.!1; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2001 | }''', |
| 2002 | <String>["1-toString"], |
| 2003 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2004 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2005 | buildTests( |
| 2006 | 'testCompletion_this_bad_inTopLevelVariableDeclaration', |
| 2007 | ''' |
| 2008 | var v = this.!1;''', |
| 2009 | <String>["1-toString"], |
| 2010 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2011 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2012 | buildTests( |
| 2013 | 'testCompletion_this_OK_inConstructorBody', |
| 2014 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2015 | class A { |
| 2016 | var f; |
| 2017 | m() {} |
| 2018 | A() { |
| 2019 | this.!1; |
| 2020 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2021 | }''', |
| 2022 | <String>["1+f", "1+m"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2023 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2024 | buildTests( |
| 2025 | 'testCompletion_this_OK_localAndSuper', |
| 2026 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2027 | class A { |
| 2028 | var fa; |
| 2029 | ma() {} |
| 2030 | } |
| 2031 | class B extends A { |
| 2032 | var fb; |
| 2033 | mb() {} |
| 2034 | main() { |
| 2035 | this.!1 |
| 2036 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2037 | }''', |
| 2038 | <String>["1+fa", "1+fb", "1+ma", "1+mb"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2039 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2040 | buildTests( |
| 2041 | 'testCompletion_topLevelField_init2', |
| 2042 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2043 | class DateTime{static var JUN;}final num M = Dat!1eTime.JUN;''', |
danrubel@google.com | 676e027 | 2015-03-12 21:40:55 +0000 | [diff] [blame] | 2044 | <String>["1+DateTime", "1-void"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2045 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2046 | buildTests( |
| 2047 | 'testCompletion_while', |
| 2048 | ''' |
| 2049 | class Foo { int boo = 7; mth() { while (b!1) {} }}''', |
| 2050 | <String>["1+boo"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2051 | } |
| 2052 | |
| 2053 | void buildLibraryTests() { |
| 2054 | Map<String, String> sources = new HashMap<String, String>(); |
| 2055 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2056 | buildTests( |
| 2057 | 'test_export_ignoreIfThisLibraryExports', |
| 2058 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2059 | export 'dart:math'; |
| 2060 | libFunction() {}; |
| 2061 | main() { |
| 2062 | !1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2063 | }''', |
| 2064 | <String>["1-cos", "1+libFunction"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2065 | |
| 2066 | sources.clear(); |
| 2067 | sources["/lib.dart"] = ''' |
| 2068 | library lib; |
| 2069 | export 'dart:math' hide sin; |
| 2070 | libFunction() {};'''; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2071 | buildTests( |
| 2072 | 'test_export_showIfImportLibraryWithExport', |
| 2073 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2074 | import 'lib.dart' as p; |
| 2075 | main() { |
| 2076 | p.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2077 | }''', |
| 2078 | <String>["1+cos", "1-sin", "1+libFunction"], |
| 2079 | extraFiles: sources, |
| 2080 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2081 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2082 | buildTests( |
| 2083 | 'test_importPrefix_hideCombinator', |
| 2084 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2085 | import 'dart:math' as math hide PI; |
| 2086 | main() { |
| 2087 | math.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2088 | }''', |
| 2089 | <String>["1-PI", "1+LN10"], |
| 2090 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2091 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2092 | buildTests( |
| 2093 | 'test_importPrefix_showCombinator', |
| 2094 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2095 | import 'dart:math' as math show PI; |
| 2096 | main() { |
| 2097 | math.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2098 | }''', |
| 2099 | <String>["1+PI", "1-LN10"], |
| 2100 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2101 | |
| 2102 | sources.clear(); |
| 2103 | sources["/lib.dart"] = ''' |
| 2104 | library lib |
danrubel | 85334be | 2015-11-23 11:15:22 -0500 | [diff] [blame] | 2105 | class _A |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2106 | foo() {} |
| 2107 | |
| 2108 | class A extends _A { |
| 2109 | }'''; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2110 | buildTests( |
| 2111 | 'test_memberOfPrivateClass_otherLibrary', |
| 2112 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2113 | import 'lib.dart'; |
| 2114 | main(A a) { |
| 2115 | a.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2116 | }''', |
| 2117 | <String>["1+foo"], |
| 2118 | extraFiles: sources, |
| 2119 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2120 | |
| 2121 | sources.clear(); |
| 2122 | sources["/lib.dart"] = ''' |
| 2123 | library lib; |
| 2124 | class A { |
| 2125 | A.c(); |
| 2126 | A._c(); |
| 2127 | }'''; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2128 | buildTests( |
| 2129 | 'test_noPrivateElement_otherLibrary_constructor', |
| 2130 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2131 | import 'lib.dart'; |
| 2132 | main() { |
| 2133 | new A.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2134 | }''', |
| 2135 | <String>["1-_c", "1+c"], |
| 2136 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2137 | |
| 2138 | sources.clear(); |
| 2139 | sources["/lib.dart"] = ''' |
| 2140 | library lib; |
| 2141 | class A { |
| 2142 | var f; |
| 2143 | var _f; |
| 2144 | }'''; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2145 | buildTests( |
| 2146 | 'test_noPrivateElement_otherLibrary_member', |
| 2147 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2148 | import 'lib.dart'; |
| 2149 | main(A a) { |
| 2150 | a.!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2151 | }''', |
| 2152 | <String>["1-_f", "1+f"], |
| 2153 | extraFiles: sources, |
| 2154 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2155 | |
| 2156 | sources.clear(); |
| 2157 | sources["/firth.dart"] = ''' |
| 2158 | library firth; |
| 2159 | class SerializationException { |
| 2160 | const SerializationException(); |
| 2161 | }'''; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2162 | buildTests( |
| 2163 | 'testLibrary001', |
| 2164 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2165 | import 'firth.dart'; |
| 2166 | main() { |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2167 | throw new Seria!1lizationException();}''', |
| 2168 | <String>["1+SerializationException"], |
| 2169 | extraFiles: sources, |
| 2170 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2171 | |
| 2172 | // Type propagation. |
| 2173 | // TODO Include corelib analysis (this works in the editor) |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2174 | buildTests( |
| 2175 | 'testLibrary002', |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2176 | '''t2() {var q=[0],z=q.!1length;q.!2clear();}''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2177 | <String>["1+length", "1+isEmpty", "2+clear"], |
| 2178 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2179 | |
| 2180 | // TODO Include corelib analysis |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2181 | buildTests('testLibrary003', '''class X{var q; f() {q.!1a!2}}''', |
| 2182 | <String>["1+end", "2+abs", "2-end"], |
| 2183 | failingTests: '12'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2184 | |
| 2185 | // TODO Include corelib analysis |
| 2186 | // Resolving dart:html takes between 2.5s and 30s; json, about 0.12s |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2187 | buildTests( |
| 2188 | 'testLibrary004', |
| 2189 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2190 | library foo; |
| 2191 | import 'dart:convert' as json; |
paulberry@google.com | dfb35c0 | 2014-12-19 17:02:18 +0000 | [diff] [blame] | 2192 | class JsonDecoderX{} |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2193 | f1() {var x=new json.!1} |
paulberry@google.com | dfb35c0 | 2014-12-19 17:02:18 +0000 | [diff] [blame] | 2194 | f2() {var x=new json.JsonDe!2} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2195 | f3() {var x=new json.JsonDecoder!3}''', |
| 2196 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 2197 | "1+JsonDecoder", |
| 2198 | "1-JsonDecoderX", |
| 2199 | "2+JsonDecoder", |
| 2200 | "2-JsonDecoderX", |
| 2201 | "3+JsonDecoder", |
| 2202 | "3-JsonDecoderX" |
| 2203 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2204 | |
| 2205 | // TODO Enable after type propagation is implemented. Not yet. |
| 2206 | // TODO Include corelib analysis |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2207 | buildTests('testLibrary005', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2208 | '''var PHI;main(){PHI=5.3;PHI.abs().!1 Object x;}''', <String>["1+abs"], |
| 2209 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2210 | |
| 2211 | // Exercise import and export handling. |
| 2212 | // Libraries are defined in partial order of increasing dependency. |
| 2213 | sources.clear(); |
| 2214 | sources["/exp2a.dart"] = ''' |
| 2215 | library exp2a; |
| 2216 | e2a() {}'''; |
| 2217 | sources["/exp1b.dart"] = ''' |
| 2218 | library exp1b;", |
| 2219 | e1b() {}'''; |
| 2220 | sources["/exp1a.dart"] = ''' |
| 2221 | library exp1a;", |
| 2222 | export 'exp1b.dart';", |
| 2223 | e1a() {}'''; |
| 2224 | sources["/imp1.dart"] = ''' |
| 2225 | library imp1; |
| 2226 | export 'exp1a.dart'; |
| 2227 | i1() {}'''; |
| 2228 | sources["/imp2.dart"] = ''' |
| 2229 | library imp2; |
| 2230 | export 'exp2a.dart'; |
| 2231 | i2() {}'''; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2232 | buildTests( |
| 2233 | 'testLibrary006', |
| 2234 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2235 | import 'imp1.dart'; |
| 2236 | import 'imp2.dart'; |
| 2237 | main() {!1 |
| 2238 | i1(); |
| 2239 | i2(); |
| 2240 | e1a(); |
| 2241 | e1b(); |
| 2242 | e2a(); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2243 | }''', |
| 2244 | <String>["1+i1", "1+i2", "1+e1a", "1+e2a", "1+e1b"], |
| 2245 | extraFiles: sources, |
| 2246 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2247 | |
| 2248 | // Exercise import and export handling. |
| 2249 | // Libraries are defined in partial order of increasing dependency. |
| 2250 | sources.clear(); |
| 2251 | sources["/l1.dart"] = ''' |
| 2252 | library l1; |
| 2253 | var _l1t; var l1t;'''; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2254 | buildTests( |
| 2255 | 'testLibrary007', |
| 2256 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2257 | import 'l1.dart'; |
| 2258 | main() { |
| 2259 | var x = l!1 |
| 2260 | var y = _!2 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2261 | }''', |
| 2262 | <String>["1+l1t", "1-_l1t", "2-_l1t"], |
| 2263 | extraFiles: sources, |
| 2264 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2265 | |
| 2266 | // Check private library exclusion |
| 2267 | sources.clear(); |
| 2268 | sources["/public.dart"] = ''' |
| 2269 | library public; |
| 2270 | class NonPrivate { |
| 2271 | void publicMethod() { |
| 2272 | } |
| 2273 | }'''; |
| 2274 | sources["/private.dart"] = ''' |
| 2275 | library _private; |
| 2276 | import 'public.dart'; |
| 2277 | class Private extends NonPrivate { |
| 2278 | void privateMethod() { |
| 2279 | } |
| 2280 | }'''; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2281 | buildTests( |
| 2282 | 'testLibrary008', |
| 2283 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2284 | import 'private.dart'; |
| 2285 | import 'public.dart'; |
| 2286 | class Test { |
| 2287 | void test() { |
| 2288 | NonPrivate x = new NonPrivate(); |
| 2289 | x.!1 //publicMethod but not privateMethod should appear |
| 2290 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2291 | }''', |
| 2292 | <String>["1-privateMethod", "1+publicMethod"], |
| 2293 | extraFiles: sources, |
| 2294 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2295 | |
| 2296 | // Exercise library prefixes. |
| 2297 | sources.clear(); |
| 2298 | sources["/lib.dart"] = ''' |
| 2299 | library lib; |
| 2300 | int X = 1; |
| 2301 | void m(){} |
| 2302 | class Y {}'''; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2303 | buildTests( |
| 2304 | 'testLibrary009', |
| 2305 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2306 | import 'lib.dart' as Q; |
| 2307 | void a() { |
| 2308 | var x = Q.!1 |
| 2309 | } |
| 2310 | void b() { |
| 2311 | var x = [Q.!2] |
| 2312 | } |
| 2313 | void c() { |
| 2314 | var x = new List([Q.!3]) |
| 2315 | } |
| 2316 | void d() { |
| 2317 | new Q.!4 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2318 | }''', |
| 2319 | <String>[ |
| 2320 | "1+X", |
| 2321 | "1+m", |
| 2322 | "1+Y", |
| 2323 | "2+X", |
| 2324 | "2+m", |
| 2325 | "2+Y", |
| 2326 | "3+X", |
| 2327 | "3+m", |
| 2328 | "3+Y", |
| 2329 | "4+Y", |
| 2330 | "4-m", |
| 2331 | "4-X" |
| 2332 | ], |
| 2333 | extraFiles: sources, |
| 2334 | failingTests: '1234'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2335 | } |
| 2336 | |
| 2337 | void buildNumberedTests() { |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2338 | buildTests( |
| 2339 | 'test001', |
| 2340 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2341 | void r1(var v) { |
| 2342 | v.!1toString!2().!3hash!4Code |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2343 | }''', |
| 2344 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 2345 | "1+toString", |
| 2346 | "1-==", |
| 2347 | "2+toString", |
| 2348 | "3+hashCode", |
| 2349 | "3+toString", |
| 2350 | "4+hashCode", |
| 2351 | "4-toString" |
| 2352 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2353 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2354 | buildTests( |
| 2355 | 'test002', |
| 2356 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2357 | void r2(var vim) { |
| 2358 | v!1.toString() |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2359 | }''', |
| 2360 | <String>["1+vim"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2361 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2362 | buildTests( |
| 2363 | 'test003', |
| 2364 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2365 | class A { |
| 2366 | int a() => 3; |
| 2367 | int b() => this.!1a(); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2368 | }''', |
| 2369 | <String>["1+a"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2370 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2371 | buildTests( |
| 2372 | 'test004', |
| 2373 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2374 | class A { |
| 2375 | int x; |
| 2376 | A() : this.!1x = 1; |
| 2377 | A.b() : this(); |
| 2378 | A.c() : this.!2b(); |
| 2379 | g() => new A.!3c(); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2380 | }''', |
| 2381 | <String>["1+x", "2+b", "3+c"], |
| 2382 | failingTests: '12'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2383 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2384 | buildTests( |
| 2385 | 'test005', |
| 2386 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2387 | class A {} |
| 2388 | void rr(var vim) { |
| 2389 | var !1vq = v!2.toString(); |
| 2390 | var vf; |
| 2391 | v!3.toString(); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2392 | }''', |
| 2393 | <String>[ |
| 2394 | "1-A", |
| 2395 | "1-vim", |
| 2396 | "1+vq", |
| 2397 | "1-vf", |
| 2398 | "1-this", |
| 2399 | "1-void", |
| 2400 | "1-null", |
| 2401 | "1-false", |
| 2402 | "2-A", |
| 2403 | "2+vim", |
| 2404 | "2-vf", |
| 2405 | "2-vq", |
| 2406 | "2-this", |
| 2407 | "2-void", |
| 2408 | "2-null", |
| 2409 | "2-false", |
| 2410 | "3+vf", |
| 2411 | "3+vq", |
| 2412 | "3+vim", |
| 2413 | "3-A" |
| 2414 | ], |
| 2415 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2416 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2417 | buildTests( |
| 2418 | 'test006', |
| 2419 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2420 | void r2(var vim, {va: 2, b: 3}) { |
| 2421 | v!1.toString() |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2422 | }''', |
| 2423 | <String>["1+va", "1-b"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2424 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2425 | buildTests( |
| 2426 | 'test007', |
| 2427 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2428 | void r2(var vim, [va: 2, b: 3]) { |
| 2429 | v!1.toString() |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2430 | }''', |
| 2431 | <String>["1+va", "1-b"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2432 | |
| 2433 | // keywords |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2434 | buildTests( |
| 2435 | 'test008', |
| 2436 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2437 | !1class Aclass {} |
| 2438 | class Bclass !2extends!3 !4Aclass {} |
| 2439 | !5typedef Ctype = !6Bclass with !7Aclass; |
| 2440 | class Dclass extends !8Ctype {} |
| 2441 | !9abstract class Eclass implements Dclass,!C Ctype, Bclass {} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2442 | class Fclass extends Bclass !Awith !B Eclass {}''', |
| 2443 | <String>[ |
| 2444 | "1+class", |
| 2445 | "1-implements", |
| 2446 | "1-extends", |
| 2447 | "1-with", |
| 2448 | "2+extends", |
| 2449 | "3+extends", |
| 2450 | "4+Aclass", |
| 2451 | "4-Bclass", |
| 2452 | "5+typedef", |
| 2453 | "6+Bclass", |
| 2454 | "6-Ctype", |
| 2455 | "7+Aclass", |
| 2456 | "7-Bclass", |
| 2457 | "8+Ctype", |
| 2458 | "9+abstract", |
| 2459 | "A+with", |
| 2460 | "B+Eclass", |
| 2461 | "B-Dclass", |
| 2462 | "B-Ctype", |
| 2463 | "C+Bclass", |
| 2464 | "C-Eclass" |
| 2465 | ], |
| 2466 | failingTests: '23467ABC'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2467 | |
| 2468 | // keywords |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2469 | buildTests( |
| 2470 | 'test009', |
| 2471 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2472 | typedef !1dy!2namic TestFn1(); |
| 2473 | typedef !3vo!4id TestFn2(); |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2474 | typ!7edef !5n!6''', |
| 2475 | <String>[ |
| 2476 | "1+void", |
| 2477 | "1+TestFn2", |
| 2478 | "2+dynamic", |
| 2479 | "2-void", |
| 2480 | "3+dynamic", |
| 2481 | "4+void", |
| 2482 | "4-dynamic", |
| 2483 | "5+TestFn2", |
| 2484 | "6+num", |
| 2485 | "7+typedef" |
| 2486 | ], |
| 2487 | failingTests: '1234'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2488 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2489 | buildTests( |
| 2490 | 'test010', |
| 2491 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2492 | class test !8<!1t !2 !3extends String,!4 List,!5 !6>!7 {} |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2493 | class tezetst !9<!BString,!C !DList>!A {}''', |
| 2494 | <String>[ |
| 2495 | "1-String", |
| 2496 | "1-List", |
| 2497 | "1-test", |
| 2498 | "2-String", |
| 2499 | "2-test", |
| 2500 | "3+extends", |
| 2501 | "4-tezetst", |
| 2502 | "4-test", |
| 2503 | "5-String", |
| 2504 | "6-List", |
| 2505 | "7-List", |
| 2506 | "8-List", |
| 2507 | "9-String", |
| 2508 | "A-String", |
| 2509 | "B-String", |
| 2510 | "C-List", |
| 2511 | "C-tezetst", |
| 2512 | "D-List", |
| 2513 | "D-test" |
| 2514 | ], |
| 2515 | failingTests: '23'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2516 | |
| 2517 | // name generation with conflicts |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2518 | buildTests('test011', '''r2(var object, Object object1, Object !1);''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2519 | <String>["1+object2"], |
| 2520 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2521 | |
| 2522 | // reserved words |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2523 | buildTests( |
| 2524 | 'test012', |
| 2525 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2526 | class X { |
| 2527 | f() { |
| 2528 | g(!1var!2 z) {!3true.!4toString();}; |
| 2529 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2530 | }''', |
| 2531 | <String>[ |
| 2532 | "1+var", |
| 2533 | "1+dynamic", |
| 2534 | "1-f", |
| 2535 | "2+var", |
| 2536 | "2-dynamic", |
| 2537 | "3+false", |
| 2538 | "3+true", |
| 2539 | "4+toString" |
| 2540 | ], |
| 2541 | failingTests: '123'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2542 | |
| 2543 | // conditions & operators |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2544 | buildTests( |
| 2545 | 'test013', |
| 2546 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2547 | class Q { |
| 2548 | bool x; |
| 2549 | List zs; |
| 2550 | int k; |
| 2551 | var a; |
| 2552 | mth() { |
| 2553 | while (!1x !9); |
| 2554 | do{} while(!2x !8); |
| 2555 | for(z in !3zs) {} |
| 2556 | switch(!4k) {case 1:{!0}} |
| 2557 | try { |
| 2558 | } on !5Object catch(a){} |
| 2559 | if (!7x !6) {} else {}; |
| 2560 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2561 | }''', |
| 2562 | <String>[ |
| 2563 | "1+x", |
| 2564 | "2+x", |
| 2565 | "3+zs", |
| 2566 | "4+k", |
| 2567 | "5+Q", |
| 2568 | "5-a", |
| 2569 | "6+==", |
| 2570 | "7+x", |
| 2571 | "8+==", |
| 2572 | "9+==", |
| 2573 | "0+k" |
| 2574 | ], |
| 2575 | failingTests: '689'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2576 | |
| 2577 | // keywords |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2578 | buildTests( |
| 2579 | 'test014', |
| 2580 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2581 | class Q { |
| 2582 | bool x; |
| 2583 | List zs; |
| 2584 | int k; |
| 2585 | !Dvar a; |
| 2586 | !Evoid mth() { |
| 2587 | !1while (z) { !Gcontinue; }; |
| 2588 | !2do{ !Hbreak; } !3while(x); |
| 2589 | !4for(z !5in zs) {} |
| 2590 | !6for (int i; i < 3; i++); |
| 2591 | !7switch(k) {!8case 1:{} !9default:{}} |
| 2592 | !Atry { |
| 2593 | } !Bon Object !Ccatch(a){} |
| 2594 | !Fassert true; |
| 2595 | !Jif (x) {} !Kelse {}; |
| 2596 | !Lreturn; |
| 2597 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2598 | }''', |
| 2599 | <String>[ |
| 2600 | "1+while", |
| 2601 | "2+do", |
| 2602 | "3+while", |
danrubel | f79d02d | 2015-08-10 10:09:18 -0400 | [diff] [blame] | 2603 | "4+for", |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2604 | "5+in", |
danrubel | f79d02d | 2015-08-10 10:09:18 -0400 | [diff] [blame] | 2605 | "6+for", |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2606 | "7+switch", |
| 2607 | "8+case", |
| 2608 | "9+default", |
| 2609 | "A+try", |
| 2610 | "B+on", |
| 2611 | "C+catch", |
| 2612 | "D+var", |
| 2613 | "E+void", |
| 2614 | "F+assert", |
| 2615 | "G+continue", |
| 2616 | "H+break", |
| 2617 | "J+if", |
| 2618 | "K+else", |
| 2619 | "L+return" |
| 2620 | ], |
Dan Rubel | bd95b13 | 2015-08-26 17:34:57 -0400 | [diff] [blame] | 2621 | failingTests: '3BCK'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2622 | |
| 2623 | // operators in function |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2624 | buildTests('test015', '''f(a,b,c) => a + b * c !1;''', <String>["1+=="], |
paulberry@google.com | 2461125 | 2014-12-09 16:44:12 +0000 | [diff] [blame] | 2625 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2626 | |
| 2627 | // operators in return |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2628 | buildTests( |
| 2629 | 'test016', |
| 2630 | '''class X {dynamic f(a,b,c) {return a + b * c !1;}}''', |
| 2631 | <String>["1+=="], |
| 2632 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2633 | |
| 2634 | // keywords |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2635 | buildTests( |
| 2636 | 'test017', |
| 2637 | ''' |
danrubel@google.com | 6368514 | 2015-05-04 18:02:23 +0000 | [diff] [blame] | 2638 | !1!2import 'x' !5as r; |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2639 | !3export '!8uri' !6hide Q !7show X; |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2640 | !4part 'x';''', |
| 2641 | <String>[ |
| 2642 | "1+library", |
Jaime Wren | 04a14d0 | 2016-04-06 14:26:18 -0700 | [diff] [blame] | 2643 | "2+import \'\';", |
| 2644 | "3+export \'\';", |
| 2645 | "4+part \'\';", |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2646 | "5+as", |
| 2647 | "6+hide", |
| 2648 | "7+show", |
| 2649 | "8-null" |
| 2650 | ], |
Jaime Wren | 04a14d0 | 2016-04-06 14:26:18 -0700 | [diff] [blame] | 2651 | failingTests: '234567'); //TODO(jwren) 234 failing as correct selection |
Brian Wilkerson | 6ccbef9 | 2016-08-29 08:11:53 -0700 | [diff] [blame] | 2652 | // offset assertions can't be passed into buildTests(..) |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2653 | |
paulberry@google.com | 0b9ed18 | 2014-12-12 18:22:34 +0000 | [diff] [blame] | 2654 | // keywords |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2655 | buildTests('test018', '''!1part !2of foo;''', <String>["1+part", "2+of"], |
Jaime Wren | 04a14d0 | 2016-04-06 14:26:18 -0700 | [diff] [blame] | 2656 | failingTests: '12'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2657 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2658 | buildTests( |
| 2659 | 'test019', |
| 2660 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2661 | var truefalse = 0; |
| 2662 | var falsetrue = 1; |
| 2663 | main() { |
| 2664 | var foo = true!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2665 | }''', |
| 2666 | <String>["1+true", "1+truefalse", "1-falsetrue"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2667 | |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2668 | buildTests('test020', '''var x = null.!1''', <String>["1+toString"], |
paulberry@google.com | 2461125 | 2014-12-09 16:44:12 +0000 | [diff] [blame] | 2669 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2670 | |
danrubel@google.com | 4e903a6 | 2015-04-03 20:38:50 +0000 | [diff] [blame] | 2671 | buildTests('test021', '''var x = .!1''', <String>["1-toString"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2672 | |
danrubel@google.com | 4e903a6 | 2015-04-03 20:38:50 +0000 | [diff] [blame] | 2673 | buildTests('test022', '''var x = .!1;''', <String>["1-toString"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2674 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2675 | buildTests( |
| 2676 | 'test023', |
| 2677 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2678 | class Map{getKeys(){}} |
| 2679 | class X { |
| 2680 | static x1(Map m) { |
| 2681 | m.!1getKeys; |
| 2682 | } |
| 2683 | x2(Map m) { |
| 2684 | m.!2getKeys; |
| 2685 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2686 | }''', |
| 2687 | <String>["1+getKeys", "2+getKeys"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2688 | |
| 2689 | // Note lack of semicolon following completion location |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2690 | buildTests( |
| 2691 | 'test024', |
| 2692 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2693 | class List{factory List.from(Iterable other) {}} |
| 2694 | class F { |
| 2695 | f() { |
| 2696 | new List.!1 |
| 2697 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2698 | }''', |
| 2699 | <String>["1+from"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2700 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2701 | buildTests( |
| 2702 | 'test025', |
| 2703 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2704 | class R { |
| 2705 | static R _m; |
| 2706 | static R m; |
| 2707 | f() { |
| 2708 | var a = !1m; |
| 2709 | var b = _!2m; |
| 2710 | var c = !3g(); |
| 2711 | } |
| 2712 | static g() { |
| 2713 | var a = !4m; |
| 2714 | var b = _!5m; |
| 2715 | var c = !6g(); |
| 2716 | } |
| 2717 | } |
| 2718 | class T { |
| 2719 | f() { |
| 2720 | R x; |
| 2721 | x.!7g(); |
| 2722 | x.!8m; |
| 2723 | x._!9m; |
| 2724 | } |
| 2725 | static g() { |
| 2726 | var q = R._!Am; |
| 2727 | var g = R.!Bm; |
| 2728 | var h = R.!Cg(); |
| 2729 | } |
| 2730 | h() { |
| 2731 | var q = R._!Dm; |
| 2732 | var g = R.!Em; |
| 2733 | var h = R.!Fg(); |
| 2734 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2735 | }''', |
| 2736 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 2737 | "1+m", |
| 2738 | "2+_m", |
| 2739 | "3+g", |
| 2740 | "4+m", |
| 2741 | "5+_m", |
| 2742 | "6+g", |
| 2743 | "7-g", |
| 2744 | "8-m", |
| 2745 | "9-_m", |
| 2746 | "A+_m", |
| 2747 | "B+m", |
| 2748 | "C+g", |
| 2749 | "D+_m", |
| 2750 | "E+m", |
| 2751 | "F+g" |
| 2752 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2753 | |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2754 | buildTests('test026', '''var aBcD; var x=ab!1''', <String>["1+aBcD"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2755 | |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2756 | buildTests( |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2757 | 'test027', '''m(){try{}catch(eeee,ssss){s!1}''', <String>["1+ssss"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2758 | |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2759 | buildTests('test028', '''m(){var isX=3;if(is!1)''', <String>["1+isX"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2760 | |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2761 | buildTests('test029', '''m(){[1].forEach((x)=>!1x);}''', <String>["1+x"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2762 | |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2763 | buildTests('test030', '''n(){[1].forEach((x){!1});}''', <String>["1+x"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2764 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2765 | buildTests( |
| 2766 | 'test031', |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2767 | '''class Caster {} m() {try {} on Cas!1ter catch (CastBlock) {!2}}''', |
danrubel@google.com | caff47a | 2015-04-01 19:29:57 +0000 | [diff] [blame] | 2768 | <String>["1+Caster", "1-CastBlock", "2+Caster", "2+CastBlock"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2769 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2770 | buildTests( |
| 2771 | 'test032', |
| 2772 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2773 | const ONE = 1; |
| 2774 | const ICHI = 10; |
| 2775 | const UKSI = 100; |
| 2776 | const EIN = 1000; |
| 2777 | m() { |
| 2778 | int x; |
| 2779 | switch (x) { |
| 2780 | case !3ICHI: |
| 2781 | case UKSI: |
| 2782 | case EIN!2: |
| 2783 | case ONE!1: return; |
| 2784 | default: return; |
| 2785 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2786 | }''', |
| 2787 | <String>[ |
Brian Wilkerson | 8c22a5f | 2016-03-29 08:27:14 -0700 | [diff] [blame] | 2788 | "1+ONE", |
| 2789 | "1-UKSI", |
| 2790 | "2+EIN", |
| 2791 | "2-ICHI", |
| 2792 | "3+ICHI", |
| 2793 | "3+UKSI", |
| 2794 | "3+EIN", |
| 2795 | "3+ONE" |
| 2796 | ]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2797 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2798 | buildTests( |
| 2799 | 'test033', |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2800 | '''class A{}class B extends A{b(){}}class C implements A {c(){}}class X{x(){A f;f.!1}}''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2801 | <String>["1+b", "1-c"], |
| 2802 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2803 | |
| 2804 | // TODO(scheglov) decide what to do with Type for untyped field (not |
| 2805 | // supported by the new store) |
| 2806 | // test analysis of untyped fields and top-level vars |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2807 | buildTests( |
| 2808 | 'test034', |
| 2809 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2810 | var topvar; |
| 2811 | class Top {top(){}} |
| 2812 | class Left extends Top {left(){}} |
| 2813 | class Right extends Top {right(){}} |
| 2814 | t1() { |
| 2815 | topvar = new Left(); |
| 2816 | } |
| 2817 | t2() { |
| 2818 | topvar = new Right(); |
| 2819 | } |
| 2820 | class A { |
| 2821 | var field; |
| 2822 | a() { |
| 2823 | field = new Left(); |
| 2824 | } |
| 2825 | b() { |
| 2826 | field = new Right(); |
| 2827 | } |
| 2828 | test() { |
| 2829 | topvar.!1top(); |
| 2830 | field.!2top(); |
| 2831 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2832 | }''', |
| 2833 | <String>["1+top", "2+top"], |
| 2834 | failingTests: '12'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2835 | |
| 2836 | // test analysis of untyped fields and top-level vars |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2837 | buildTests('test035', '''class Y {final x='hi';mth() {x.!1length;}}''', |
Konstantin Shcheglov | de4d8b3 | 2016-10-06 08:47:15 -0700 | [diff] [blame] | 2838 | <String>["1+length"], |
| 2839 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2840 | |
| 2841 | // TODO(scheglov) decide what to do with Type for untyped field (not |
| 2842 | // supported by the new store) |
| 2843 | // test analysis of untyped fields and top-level vars |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2844 | buildTests( |
| 2845 | 'test036', |
| 2846 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2847 | class A1 { |
| 2848 | var field; |
| 2849 | A1() : field = 0; |
| 2850 | q() { |
| 2851 | A1 a = new A1(); |
| 2852 | a.field.!1 |
| 2853 | } |
| 2854 | } |
| 2855 | main() { |
| 2856 | A1 a = new A1(); |
| 2857 | a.field.!2 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2858 | }''', |
| 2859 | <String>["1+round", "2+round"], |
| 2860 | failingTests: '12'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2861 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2862 | buildTests( |
| 2863 | 'test037', |
| 2864 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2865 | class HttpServer{} |
| 2866 | class HttpClient{} |
| 2867 | main() { |
| 2868 | new HtS!1 |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2869 | }''', |
| 2870 | <String>["1+HttpServer", "1-HttpClient"], |
| 2871 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2872 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2873 | buildTests( |
| 2874 | 'test038', |
| 2875 | ''' |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2876 | class X { |
| 2877 | x(){} |
| 2878 | } |
| 2879 | class Y { |
| 2880 | y(){} |
| 2881 | } |
| 2882 | class A<Z extends X> { |
| 2883 | Y ay; |
| 2884 | Z az; |
| 2885 | A(this.ay, this.az) { |
| 2886 | ay.!1y; |
| 2887 | az.!2x; |
| 2888 | } |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2889 | }''', |
| 2890 | <String>["1+y", "1-x", "2+x", "2-y"], |
| 2891 | failingTests: '2'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2892 | |
| 2893 | // test analysis of untyped fields and top-level vars |
Brian Wilkerson | 6ccbef9 | 2016-08-29 08:11:53 -0700 | [diff] [blame] | 2894 | buildTests( |
| 2895 | 'test039', '''class X{}var x = null as !1X;''', <String>["1-void"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2896 | |
| 2897 | // test arg lists with named params |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2898 | buildTests('test040', '''m(){f(a, b, {x1, x2, y}) {};f(1, 2, !1)!2;}''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2899 | <String>["1+x1", "2-x2"], |
| 2900 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2901 | |
| 2902 | // test arg lists with named params |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2903 | buildTests('test041', '''m(){f(a, b, {x1, x2, y}) {};f(1, 2, !1''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2904 | <String>["1+x1", "1+x2", "1+y"], |
| 2905 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2906 | |
| 2907 | // test arg lists with named params |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2908 | buildTests('test042', '''m(){f(a, b, {x1, x2, y}) {};f(1, 2, !1;!2''', |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2909 | <String>["1+x1", "1+x2", "2-y"], |
| 2910 | failingTests: '1'); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2911 | } |
| 2912 | |
| 2913 | void buildOtherTests() { |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2914 | buildTests('test_classMembers_inGetter', |
| 2915 | '''class A { var fff; get z {ff!1}}''', <String>["1+fff"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2916 | |
Brian Wilkerson | 908708d | 2015-08-05 08:13:28 -0700 | [diff] [blame] | 2917 | buildTests( |
| 2918 | 'testSingle', |
| 2919 | '''class A {int x; !2mth() {int y = this.x;}}class B{}''', |
| 2920 | <String>["2+B"]); |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2921 | } |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2922 | |
| 2923 | /** |
| 2924 | * Generate a set of completion tests based on the given [originalSource]. |
| 2925 | * |
| 2926 | * The source string has completion points embedded in it, which are |
| 2927 | * identified by '!X' where X is a single character. Each X is matched to |
| 2928 | * positive or negative results in the array of [validationStrings]. |
| 2929 | * Validation strings contain the name of a prediction with a two character |
| 2930 | * prefix. The first character of the prefix corresponds to an X in the |
| 2931 | * [originalSource]. The second character is either a '+' or a '-' indicating |
| 2932 | * whether the string is a positive or negative result. |
| 2933 | * |
| 2934 | * The [originalSource] is the source for a completion test that contains |
| 2935 | * completion points. The [validationStrings] are the positive and negative |
| 2936 | * predictions. |
| 2937 | * |
| 2938 | * Optional argument [failingTests], if given, is a string, each character of |
| 2939 | * which corresponds to an X in the [originalSource] for which the test is |
| 2940 | * expected to fail. This sould be used to mark known completion bugs that |
| 2941 | * have not yet been fixed. |
| 2942 | */ |
| 2943 | void buildTests(String baseName, String originalSource, List<String> results, |
| 2944 | {Map<String, String> extraFiles, String failingTests: ''}) { |
| 2945 | List<LocationSpec> completionTests = |
| 2946 | LocationSpec.from(originalSource, results); |
| 2947 | completionTests.sort((LocationSpec first, LocationSpec second) { |
| 2948 | return first.id.compareTo(second.id); |
| 2949 | }); |
| 2950 | if (completionTests.isEmpty) { |
| 2951 | test(baseName, () { |
brianwilkerson@google.com | cd58e29 | 2015-03-02 22:43:12 +0000 | [diff] [blame] | 2952 | fail("Expected exclamation point ('!') within the source denoting the" |
| 2953 | "position at which code completion should occur"); |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2954 | }); |
| 2955 | } |
| 2956 | Set<String> allSpecIds = |
| 2957 | completionTests.map((LocationSpec spec) => spec.id).toSet(); |
| 2958 | for (String id in failingTests.split('')) { |
| 2959 | if (!allSpecIds.contains(id)) { |
| 2960 | test("$baseName-$id", () { |
| 2961 | fail( |
| 2962 | "Test case '$id' included in failingTests, but this id does not exist."); |
| 2963 | }); |
| 2964 | } |
| 2965 | } |
| 2966 | for (LocationSpec spec in completionTests) { |
paulberry@google.com | 6d7155d | 2014-12-20 15:47:25 +0000 | [diff] [blame] | 2967 | String testName = '$baseName-${spec.id}'; |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2968 | if (failingTests.contains(spec.id)) { |
| 2969 | ++expectedFailCount; |
Konstantin Shcheglov | de4d8b3 | 2016-10-06 08:47:15 -0700 | [diff] [blame] | 2970 | test("$testName (expected failure $expectedFailCount)", () { |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2971 | CompletionTestCase test = new CompletionTestCase(); |
| 2972 | return new Future(() => test.runTest(spec, extraFiles)).then((_) { |
| 2973 | fail('Test passed - expected to fail.'); |
| 2974 | }, onError: (_) {}); |
| 2975 | }); |
| 2976 | } else { |
| 2977 | ++expectedPassCount; |
Konstantin Shcheglov | de4d8b3 | 2016-10-06 08:47:15 -0700 | [diff] [blame] | 2978 | test(testName, () { |
paulberry@google.com | 523dac8 | 2014-12-17 16:52:25 +0000 | [diff] [blame] | 2979 | CompletionTestCase test = new CompletionTestCase(); |
| 2980 | return test.runTest(spec, extraFiles); |
| 2981 | }); |
| 2982 | } |
| 2983 | } |
| 2984 | } |
brianwilkerson@google.com | d05b815 | 2014-12-08 20:00:24 +0000 | [diff] [blame] | 2985 | } |