OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 package com.google.dart.compiler; | 5 package com.google.dart.compiler; |
6 | 6 |
7 import com.google.dart.compiler.ast.LibraryUnit; | 7 import com.google.dart.compiler.ast.LibraryUnit; |
8 | 8 |
9 /** | 9 /** |
10 * Tests the use of the parser and analysis phases as used by the IDE for code | 10 * Tests the use of the parser and analysis phases as used by the IDE for code |
11 * completion. | 11 * completion. |
12 */ | 12 */ |
13 public class CodeCompletionParseTest extends CompilerTestCase { | 13 public class CodeCompletionParseTest extends CompilerTestCase { |
14 | 14 |
15 public void test1() throws Exception { | 15 public void test1() throws Exception { |
16 AnalyzeLibraryResult result = analyzeLibrary(makeCode( | 16 AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode( |
17 "class CellLocation {", | 17 "class CellLocation {", |
18 " int _field1;", | 18 " int _field1;", |
19 " String _field2;", | 19 " String _field2;", |
20 "", | 20 "", |
21 " CellLoc", // cursor | 21 " CellLoc", // cursor |
22 "", | 22 "", |
23 " int hashCode() {", | 23 " int hashCode() {", |
24 " return _field1 * 31 ^ _field2.hashCode();", | 24 " return _field1 * 31 ^ _field2.hashCode();", |
25 " }", | 25 " }", |
26 "}")); | 26 "}")); |
27 LibraryUnit lib = result.getLibraryUnitResult(); | 27 LibraryUnit lib = result.getLibraryUnitResult(); |
28 assertNotNull(lib); | 28 assertNotNull(lib); |
29 } | 29 } |
30 | 30 |
31 public void test2() throws Exception { | 31 public void test2() throws Exception { |
32 AnalyzeLibraryResult result = analyzeLibrary(makeCode( | 32 AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode( |
33 "doFoo() {", | 33 "doFoo() {", |
34 " new ", // cursor | 34 " new ", // cursor |
35 "}")); | 35 "}")); |
36 LibraryUnit lib = result.getLibraryUnitResult(); | 36 LibraryUnit lib = result.getLibraryUnitResult(); |
37 assertNotNull(lib); | 37 assertNotNull(lib); |
38 } | 38 } |
39 | 39 |
40 public void test3() throws Exception { | 40 public void test3() throws Exception { |
41 AnalyzeLibraryResult result = analyzeLibrary(makeCode( | 41 AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode( |
42 "class Foo {", | 42 "class Foo {", |
43 " static final Bar b = const ", // cursor | 43 " static final Bar b = const ", // cursor |
44 "}", | 44 "}", |
45 "", | 45 "", |
46 "class Bar {", | 46 "class Bar {", |
47 " factory Bar() {}", | 47 " factory Bar() {}", |
48 "}")); | 48 "}")); |
49 LibraryUnit lib = result.getLibraryUnitResult(); | 49 LibraryUnit lib = result.getLibraryUnitResult(); |
50 assertNotNull(lib); | 50 assertNotNull(lib); |
51 } | 51 } |
52 | 52 |
53 public void test4() throws Exception { | 53 public void test4() throws Exception { |
54 AnalyzeLibraryResult result = analyzeLibrary(makeCode( | 54 AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode( |
55 "foo() {", | 55 "foo() {", |
56 " int SEED;", | 56 " int SEED;", |
57 " for (int i = 0; i < S)", // cursor before ) | 57 " for (int i = 0; i < S)", // cursor before ) |
58 "}")); | 58 "}")); |
59 LibraryUnit lib = result.getLibraryUnitResult(); | 59 LibraryUnit lib = result.getLibraryUnitResult(); |
60 assertNotNull(lib); | 60 assertNotNull(lib); |
61 } | 61 } |
62 | 62 |
63 public void test5() throws Exception { | 63 public void test5() throws Exception { |
64 AnalyzeLibraryResult result = analyzeLibrary(makeCode( | 64 AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode( |
65 "ckass Sunflower {", | 65 "ckass Sunflower {", |
66 " static final int SEED_RADIUS = 2;", | 66 " static final int SEED_RADIUS = 2;", |
67 " static final int SCALE_FACTOR = 4;", | 67 " static final int SCALE_FACTOR = 4;", |
68 " static final num PI2 = Math.PI * 2;", | 68 " static final num PI2 = Math.PI * 2;", |
69 " static final num PI4 = M", // cursor | 69 " static final num PI4 = M", // cursor |
70 "}")); | 70 "}")); |
71 LibraryUnit lib = result.getLibraryUnitResult(); | 71 LibraryUnit lib = result.getLibraryUnitResult(); |
72 assertNotNull(lib); | 72 assertNotNull(lib); |
73 } | 73 } |
74 | 74 |
75 public void test6() throws Exception { | 75 public void test6() throws Exception { |
76 AnalyzeLibraryResult result = analyzeLibrary(makeCode( | 76 AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode( |
77 "class Sunflower {", | 77 "class Sunflower {", |
78 " static final int SEED_RADIUS = 2;", | 78 " static final int SEED_RADIUS = 2;", |
79 " static final int SCALE_FACTOR = 4;", | 79 " static final int SCALE_FACTOR = 4;", |
80 " static final num PI2 = Math.PI * 2;", | 80 " static final num PI2 = Math.PI * 2;", |
81 " static final num PI4 = M", // cursor | 81 " static final num PI4 = M", // cursor |
82 "}")); | 82 "}")); |
83 LibraryUnit lib = result.getLibraryUnitResult(); | 83 LibraryUnit lib = result.getLibraryUnitResult(); |
84 assertNotNull(lib); | 84 assertNotNull(lib); |
85 } | 85 } |
86 } | 86 } |
OLD | NEW |