Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6535eed3c30996fe26b575089d8e3f03b1b84696 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*******************************************************************************
 *  Copyright (c) 2010 IBM Corporation and others.
 *
 *  This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License 2.0
 *  which accompanies this distribution, and is available at
 *  https://www.eclipse.org/legal/epl-2.0/
 *
 *  SPDX-License-Identifier: EPL-2.0
 * 
 *  Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.cdt.core.lrparser.tests;





import junit.framework.TestSuite;

public class LRCompletionHangingTest extends AbstractLRHangingTest {

	

	public static TestSuite suite() {
		return new TestSuite(LRCompletionHangingTest.class);
	}
	
	
	
	
	
	//test c
	public void testCompletionDoWhileForC() throws Exception {

		String code = 
			"int main(int argc, char **argv) {" + 
				"do{" +
					CONTENT_ASIST_CURSOR +
		        "} while (i < 3);" +
		    "}";
		
		runTestCase(code, getCLanguage());
		
	}
	
	
	
	//test cpp
	public void testCompletionDoWhileForCPP() throws Exception {

		String code = 
			"int main(int argc, char **argv) {" + 
				"do{" +
		        	CONTENT_ASIST_CURSOR +
		        "} while (i < 3);" +
		    "}";
		runTestCase(code, getCPPLanguage());
	}
	
	public void testCompletionTryCatch() throws Exception {

		String code = 
			"int main(int argc, char **argv) {" + 
				"try {" +
					CONTENT_ASIST_CURSOR + 
				"}" + 
				
				"catch(x){}" + 
			"}";
		runTestCase(code, getCPPLanguage());
		
	}
	
	

	
	public void testCompletionTemplateFunctionForCPP() throws Exception {

		String code = 
			"template " + CONTENT_ASIST_CURSOR +"<class myType>" +
			"myType GetA (myType a) {" +
				"return a;" +
			"}" +
			
			"int main(int argc, char **argv) {" + 
				"int x=0;" +
				"int y = GetA " + CONTENT_ASIST_CURSOR + " <int> (x);" +
			"}";
		runTestCase(code, getCPPLanguage());
	}
	
	
	public void testCompletionIfForCPP() throws Exception {
		String code = 
			"int main(int argc, char **argv) {" + 
				"int x=0;" +
				"if" + CONTENT_ASIST_CURSOR +"(x>0){}" +
			"}";
		runTestCase(code, getCPPLanguage());
		
	}
	
	public void testCompletionTemplateClassForCPP() throws Exception {

		String code = 
		    "template" + CONTENT_ASIST_CURSOR +" <class T> " +
			"class Test {" + 
			    "T val;" +
			    "public:Test(T arg){"+
			      	"val = arg;" +
			    "}" +
			    "~" + CONTENT_ASIST_CURSOR +"Test();"+
			"};" +
			"Test::" + CONTENT_ASIST_CURSOR +"~" + CONTENT_ASIST_CURSOR +"Test(){}" +
			"int main(int argc, char **argv) {" + 
			    CONTENT_ASIST_CURSOR +
				"Test<" + CONTENT_ASIST_CURSOR + "int> t(1);" +
				"Test<" + CONTENT_ASIST_CURSOR +"double>" + CONTENT_ASIST_CURSOR + "* dt = new dt(1.0);" +
				"S* s = dynamic_cast<S*" + CONTENT_ASIST_CURSOR +">(dt);" +   
				"S* s = dynamic_cast" + CONTENT_ASIST_CURSOR +"<S*>(dt);" +   
			"}";
		runTestCase(code, getCPPLanguage());
	}
	
	
	
	
	public void testCompletionSimpleIfForCPP() throws Exception {
		String code = 
			"#" + CONTENT_ASIST_CURSOR + "include " + CONTENT_ASIST_CURSOR + "<iostream>" +
		   "using " + CONTENT_ASIST_CURSOR + "namespace std;" +
		   "if" + CONTENT_ASIST_CURSOR + "(i>0)){}" +
		   "int " + CONTENT_ASIST_CURSOR + "*" + CONTENT_ASIST_CURSOR + " i " + CONTENT_ASIST_CURSOR + "=" + CONTENT_ASIST_CURSOR + " &" + CONTENT_ASIST_CURSOR + "j;" +
		   "*" + CONTENT_ASIST_CURSOR + "j=0;" +
		   "*" + CONTENT_ASIST_CURSOR + "j++;"+
		   "*i" + CONTENT_ASIST_CURSOR + "++ = " + CONTENT_ASIST_CURSOR + "*j++;";
		runTestCase(code, getCPPLanguage());
	
	}
	
	public void testCompletionStructForCPP() throws Exception {
		String code = 
		    "struct " + CONTENT_ASIST_CURSOR + "p " + CONTENT_ASIST_CURSOR + "{" +
		      CONTENT_ASIST_CURSOR+
			  "int w;" +
			  "float p;" +
			"} " + CONTENT_ASIST_CURSOR + "a," + CONTENT_ASIST_CURSOR + "b,c;";
			 
		runTestCase(code, getCPPLanguage());
	
	}
	
	public void testCompletionGnuCPP() throws Exception {
		String code = 
		 "if a>b ? " + CONTENT_ASIST_CURSOR + "g" + CONTENT_ASIST_CURSOR + ":l;" +
		 "case 1..." + CONTENT_ASIST_CURSOR + "3 : ok; ";
		runTestCase(code, getCPPLanguage());
	}
	

	

}

Back to the top