OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, the Dart project authors. | 2 * Copyright (c) 2013, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 package com.google.dart.engine.resolver; | 14 package com.google.dart.engine.resolver; |
15 | 15 |
16 import com.google.dart.engine.error.CompileTimeErrorCode; | 16 import com.google.dart.engine.error.CompileTimeErrorCode; |
17 import com.google.dart.engine.error.HintCode; | 17 import com.google.dart.engine.error.HintCode; |
| 18 import com.google.dart.engine.error.StaticTypeWarningCode; |
18 import com.google.dart.engine.error.StaticWarningCode; | 19 import com.google.dart.engine.error.StaticWarningCode; |
19 import com.google.dart.engine.source.Source; | 20 import com.google.dart.engine.source.Source; |
20 | 21 |
21 public class StaticWarningCodeTest extends ResolverTestCase { | 22 public class StaticWarningCodeTest extends ResolverTestCase { |
22 public void fail_undefinedGetter() throws Exception { | 23 public void fail_undefinedGetter() throws Exception { |
23 Source source = addSource(createSource(// | 24 Source source = addSource(createSource(// |
24 // TODO | 25 // TODO |
25 )); | 26 )); |
26 resolve(source); | 27 resolve(source); |
27 assertErrors(source, StaticWarningCode.UNDEFINED_GETTER); | 28 assertErrors(source, StaticWarningCode.UNDEFINED_GETTER); |
(...skipping 16 matching lines...) Expand all Loading... |
44 Source source = addSource(createSource(// | 45 Source source = addSource(createSource(// |
45 "class C {}", | 46 "class C {}", |
46 "f(var p) {", | 47 "f(var p) {", |
47 " C.m = 0;", | 48 " C.m = 0;", |
48 "}")); | 49 "}")); |
49 resolve(source); | 50 resolve(source); |
50 assertErrors(source, StaticWarningCode.UNDEFINED_SETTER); | 51 assertErrors(source, StaticWarningCode.UNDEFINED_SETTER); |
51 verify(source); | 52 verify(source); |
52 } | 53 } |
53 | 54 |
54 public void fail_undefinedStaticMethodOrGetter_getter() throws Exception { | |
55 Source source = addSource(createSource(// | |
56 "class C {}", | |
57 "f(var p) {", | |
58 " f(C.m);", | |
59 "}")); | |
60 resolve(source); | |
61 assertErrors(source, StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER); | |
62 verify(source); | |
63 } | |
64 | |
65 public void fail_undefinedStaticMethodOrGetter_method() throws Exception { | |
66 Source source = addSource(createSource(// | |
67 "class C {}", | |
68 "f(var p) {", | |
69 " f(C.m());", | |
70 "}")); | |
71 resolve(source); | |
72 assertErrors(source, StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER); | |
73 verify(source); | |
74 } | |
75 | |
76 public void test_ambiguousImport_as() throws Exception { | 55 public void test_ambiguousImport_as() throws Exception { |
77 Source source = addSource(createSource(// | 56 Source source = addSource(createSource(// |
78 "import 'lib1.dart';", | 57 "import 'lib1.dart';", |
79 "import 'lib2.dart';", | 58 "import 'lib2.dart';", |
80 "f(p) {p as N;}")); | 59 "f(p) {p as N;}")); |
81 addSource("/lib1.dart", createSource(// | 60 addSource("/lib1.dart", createSource(// |
82 "library lib1;", | 61 "library lib1;", |
83 "class N {}")); | 62 "class N {}")); |
84 addSource("/lib2.dart", createSource(// | 63 addSource("/lib2.dart", createSource(// |
85 "library lib2;", | 64 "library lib2;", |
(...skipping 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2376 Source source1 = addSource("lib.dart", ""); | 2355 Source source1 = addSource("lib.dart", ""); |
2377 Source source2 = addSource("lib2.dart", createSource(// | 2356 Source source2 = addSource("lib2.dart", createSource(// |
2378 "import 'lib.dart' as lib;", | 2357 "import 'lib.dart' as lib;", |
2379 "void f() {", | 2358 "void f() {", |
2380 " lib.gg = null;", | 2359 " lib.gg = null;", |
2381 "}")); | 2360 "}")); |
2382 resolve(source1); | 2361 resolve(source1); |
2383 resolve(source2); | 2362 resolve(source2); |
2384 assertErrors(source2, StaticWarningCode.UNDEFINED_SETTER); | 2363 assertErrors(source2, StaticWarningCode.UNDEFINED_SETTER); |
2385 } | 2364 } |
| 2365 |
| 2366 // See comment on StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER |
| 2367 public void test_undefinedStaticMethodOrGetter_getter() throws Exception { |
| 2368 Source source = addSource(createSource(// |
| 2369 "class C {}", |
| 2370 "f(var p) {", |
| 2371 " f(C.m);", |
| 2372 "}")); |
| 2373 resolve(source); |
| 2374 assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER); |
| 2375 } |
| 2376 |
| 2377 // See comment on StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER |
| 2378 public void test_undefinedStaticMethodOrGetter_getter_inSuperclass() throws Ex
ception { |
| 2379 Source source = addSource(createSource(// |
| 2380 "class S {", |
| 2381 " static int get g => 0;", |
| 2382 "}", |
| 2383 "class C extends S {}", |
| 2384 "f(var p) {", |
| 2385 " f(C.g);", |
| 2386 "}")); |
| 2387 resolve(source); |
| 2388 assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER); |
| 2389 } |
| 2390 |
| 2391 // See comment on StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER |
| 2392 public void test_undefinedStaticMethodOrGetter_method() throws Exception { |
| 2393 Source source = addSource(createSource(// |
| 2394 "class C {}", |
| 2395 "f(var p) {", |
| 2396 " f(C.m());", |
| 2397 "}")); |
| 2398 resolve(source); |
| 2399 assertErrors(source, StaticTypeWarningCode.UNDEFINED_METHOD); |
| 2400 } |
| 2401 |
| 2402 // See comment on StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER |
| 2403 public void test_undefinedStaticMethodOrGetter_method_inSuperclass() throws Ex
ception { |
| 2404 Source source = addSource(createSource(// |
| 2405 "class S {", |
| 2406 " static m() {}", |
| 2407 "}", |
| 2408 "class C extends S {}", |
| 2409 "f(var p) {", |
| 2410 " f(C.m());", |
| 2411 "}")); |
| 2412 resolve(source); |
| 2413 assertErrors(source, StaticTypeWarningCode.UNDEFINED_METHOD); |
| 2414 } |
| 2415 |
| 2416 // See comment on StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER |
| 2417 public void test_undefinedStaticMethodOrGetter_setter_inSuperclass() throws Ex
ception { |
| 2418 Source source = addSource(createSource(// |
| 2419 "class S {", |
| 2420 " static set s(int i) {}", |
| 2421 "}", |
| 2422 "class C extends S {}", |
| 2423 "f(var p) {", |
| 2424 " f(C.s = 1);", |
| 2425 "}")); |
| 2426 resolve(source); |
| 2427 assertErrors(source, StaticTypeWarningCode.UNDEFINED_SETTER); |
| 2428 } |
2386 } | 2429 } |
OLD | NEW |