View | Details | Raw Unified | Return to bug 186114 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-3 / +129 lines)
Lines 46-53 Link Here
46
	}
46
	}
47
47
48
	static {
48
	static {
49
//		TESTS_NUMBERS = new int[] { 276 };
49
//		TESTS_NUMBERS = new int[] { 277 };
50
//		TESTS_RANGE = new int[] { 253, -1 };
50
//		TESTS_RANGE = new int[] { 277, -1 };
51
//		TESTS_NAMES = new String[] {"test0204"};
51
//		TESTS_NAMES = new String[] {"test0204"};
52
	}
52
	}
53
	public static Test suite() {
53
	public static Test suite() {
Lines 9195-9199 Link Here
9195
		parser.setProject(this.getJavaProject("Converter15"));
9195
		parser.setProject(this.getJavaProject("Converter15"));
9196
		parser.setKind(ASTParser.K_COMPILATION_UNIT);
9196
		parser.setKind(ASTParser.K_COMPILATION_UNIT);
9197
		parser.createASTs(new ICompilationUnit[]{this.workingCopy}, new String[0], requestor, null);
9197
		parser.createASTs(new ICompilationUnit[]{this.workingCopy}, new String[0], requestor, null);
9198
	}	
9198
	}
9199
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908
9200
	public void test0277() throws JavaModelException {
9201
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
9202
		String contents =
9203
			"public class X {\n" + 
9204
			"	public static void method() {\n" + 
9205
			"	}\n" + 
9206
			"}\n" + 
9207
			"class Y extends X {\n" + 
9208
			"	public static void method() {\n" + 
9209
			"	}\n" + 
9210
			"}";
9211
		ASTNode node = buildAST(
9212
				contents,
9213
				this.workingCopy,
9214
				true);
9215
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9216
		CompilationUnit unit = (CompilationUnit) node;
9217
		assertProblemsSize(unit, 0);
9218
		node = getASTNode(unit, 0, 0);
9219
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
9220
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;
9221
		IMethodBinding methodBinding1 = methodDeclaration.resolveBinding();
9222
		
9223
		node = getASTNode(unit, 1, 0);
9224
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
9225
		methodDeclaration = (MethodDeclaration) node;
9226
		IMethodBinding methodBinding2 = methodDeclaration.resolveBinding();
9227
		
9228
		assertFalse("Overrides", methodBinding2.overrides(methodBinding1));
9229
	}
9230
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908
9231
	public void test0278() throws JavaModelException {
9232
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
9233
		String contents =
9234
			"public class X {\n" + 
9235
			"	public void method() {\n" + 
9236
			"	}\n" + 
9237
			"}\n" + 
9238
			"class Y extends X {\n" + 
9239
			"	public static void method() {\n" + 
9240
			"	}\n" + 
9241
			"}";
9242
		ASTNode node = buildAST(
9243
				contents,
9244
				this.workingCopy,
9245
				false);
9246
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9247
		CompilationUnit unit = (CompilationUnit) node;
9248
		assertProblemsSize(unit, 1, "This static method cannot hide the instance method from X");
9249
		node = getASTNode(unit, 0, 0);
9250
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
9251
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;
9252
		IMethodBinding methodBinding1 = methodDeclaration.resolveBinding();
9253
		
9254
		node = getASTNode(unit, 1, 0);
9255
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
9256
		methodDeclaration = (MethodDeclaration) node;
9257
		IMethodBinding methodBinding2 = methodDeclaration.resolveBinding();
9258
		
9259
		assertFalse("Overrides", methodBinding2.overrides(methodBinding1));
9260
	}
9261
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908
9262
	public void test0279() throws JavaModelException {
9263
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
9264
		String contents =
9265
			"public class X {\n" + 
9266
			"	public static void method() {\n" + 
9267
			"	}\n" + 
9268
			"}\n" + 
9269
			"class Y extends X {\n" + 
9270
			"	public void method() {\n" + 
9271
			"	}\n" + 
9272
			"}";
9273
		ASTNode node = buildAST(
9274
				contents,
9275
				this.workingCopy,
9276
				false);
9277
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9278
		CompilationUnit unit = (CompilationUnit) node;
9279
		assertProblemsSize(unit, 1, "This instance method cannot override the static method from X");
9280
		node = getASTNode(unit, 0, 0);
9281
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
9282
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;
9283
		IMethodBinding methodBinding1 = methodDeclaration.resolveBinding();
9284
		
9285
		node = getASTNode(unit, 1, 0);
9286
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
9287
		methodDeclaration = (MethodDeclaration) node;
9288
		IMethodBinding methodBinding2 = methodDeclaration.resolveBinding();
9289
		
9290
		assertFalse("Overrides", methodBinding2.overrides(methodBinding1));
9291
	}
9292
	
9293
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908
9294
	public void test0280() throws JavaModelException {
9295
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
9296
		String contents =
9297
			"public class X {\n" + 
9298
			"	public void method() {\n" + 
9299
			"	}\n" + 
9300
			"}\n" + 
9301
			"class Y extends X {\n" + 
9302
			"	@Override\n" +
9303
			"	public void method() {\n" + 
9304
			"	}\n" + 
9305
			"}";
9306
		ASTNode node = buildAST(
9307
				contents,
9308
				this.workingCopy,
9309
				true);
9310
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9311
		CompilationUnit unit = (CompilationUnit) node;
9312
		assertProblemsSize(unit, 0);
9313
		node = getASTNode(unit, 0, 0);
9314
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
9315
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;
9316
		IMethodBinding methodBinding1 = methodDeclaration.resolveBinding();
9317
		
9318
		node = getASTNode(unit, 1, 0);
9319
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
9320
		methodDeclaration = (MethodDeclaration) node;
9321
		IMethodBinding methodBinding2 = methodDeclaration.resolveBinding();
9322
		
9323
		assertTrue("Doesn't overrides", methodBinding2.overrides(methodBinding1));
9324
	}
9199
}
9325
}

Return to bug 186114