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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java (-7 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 57-63 Link Here
57
			"	       ^^^^^^^^^\n" + 
57
			"	       ^^^^^^^^^\n" + 
58
			"The import java.util is never used\n" + 
58
			"The import java.util is never used\n" + 
59
			"----------\n",
59
			"----------\n",
60
			"SUCCESS",
60
			"SUCCESS" /* expectedOuputString */,
61
			null /* expectedErrorString */,
61
			null,
62
			null,
62
			true,
63
			true,
63
			null,
64
			null,
Lines 86-93 Link Here
86
			"	       ^^^^^^^^^\n" + 
87
			"	       ^^^^^^^^^\n" + 
87
			"The import java.util is never used\n" + 
88
			"The import java.util is never used\n" + 
88
			"----------\n",
89
			"----------\n",
89
			"Unexpected target error running resulting class file for X.java:\n" + 
90
			null /* expectedOutputString */,
90
			"java.lang.Error: Unresolved compilation problem: \n" + 
91
			"java.lang.Error: Unresolved compilation problem: \n" + /* expectedErrorString */ 
91
			"\n",
92
			"\n",
92
			null,
93
			null,
93
			true,
94
			true,
Lines 116-121 Link Here
116
			"Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" + 
117
			"Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" + 
117
			"----------\n",
118
			"----------\n",
118
			"SUCCESS",
119
			"SUCCESS",
120
			null /* expectedErrorString */,
119
			null,
121
			null,
120
			true,
122
			true,
121
			null,
123
			null,
Lines 145-150 Link Here
145
			"Empty block should be documented\n" + 
147
			"Empty block should be documented\n" + 
146
			"----------\n",
148
			"----------\n",
147
			"SUCCESS",
149
			"SUCCESS",
150
			null /* expectedErrorString */,
148
			null,
151
			null,
149
			true,
152
			true,
150
			null,
153
			null,
Lines 173-181 Link Here
173
			"	                         ^^\n" + 
176
			"	                         ^^\n" + 
174
			"Empty block should be documented\n" + 
177
			"Empty block should be documented\n" + 
175
			"----------\n",
178
			"----------\n",
176
			"Unexpected target error running resulting class file for X.java:\n" + 
179
			null,
177
			"java.lang.Error: Unresolved compilation problem: \n" + 
180
			"java.lang.Error: Unresolved compilation problem: \n" + /* expectedErrorString */ 
178
			"	Empty block should be documented\n" + 
181
			"	Empty block should be documented\n" +  
179
			"\n",
182
			"\n",
180
			null,
183
			null,
181
			true,
184
			true,
(-)src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1375-1380 Link Here
1375
		"The label label is never explicitly referenced\n" + 
1375
		"The label label is never explicitly referenced\n" + 
1376
		"----------\n" /* expectedCompilerLog */,
1376
		"----------\n" /* expectedCompilerLog */,
1377
		"" /* expectedOutputString */,
1377
		"" /* expectedOutputString */,
1378
		"" /* expectedErrorString */,
1378
		false /* forceExecution */,
1379
		false /* forceExecution */,
1379
		null /* classLib */,
1380
		null /* classLib */,
1380
		true /* shouldFlushOutputDirectory */, 
1381
		true /* shouldFlushOutputDirectory */, 
Lines 1408-1413 Link Here
1408
		false /* expectingCompilerErrors */,
1409
		false /* expectingCompilerErrors */,
1409
		"" /* expectedCompilerLog */,
1410
		"" /* expectedCompilerLog */,
1410
		"" /* expectedOutputString */,
1411
		"" /* expectedOutputString */,
1412
		"" /* expectedErrorString */,
1411
		false /* forceExecution */,
1413
		false /* forceExecution */,
1412
		null /* classLib */,
1414
		null /* classLib */,
1413
		true /* shouldFlushOutputDirectory */, 
1415
		true /* shouldFlushOutputDirectory */, 
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java (-5 / +9 lines)
Lines 1131-1137 Link Here
1131
	protected void runNegativeTestWithExecution(
1131
	protected void runNegativeTestWithExecution(
1132
			String[] testFiles, 
1132
			String[] testFiles, 
1133
			String expectedProblemLog, 
1133
			String expectedProblemLog, 
1134
			String expectedSuccessOutputString, 
1134
			String expectedOutputString,
1135
			String expectedErrorString,
1135
			String[] classLib,
1136
			String[] classLib,
1136
			boolean shouldFlushOutputDirectory, 
1137
			boolean shouldFlushOutputDirectory, 
1137
			String[] vmArguments, 
1138
			String[] vmArguments, 
Lines 1211-1223 Link Here
1211
		boolean passed = 
1212
		boolean passed = 
1212
			this.verifier.verifyClassFiles(
1213
			this.verifier.verifyClassFiles(
1213
				sourceFile, 
1214
				sourceFile, 
1214
				className, 
1215
				className,
1215
				expectedSuccessOutputString,
1216
				expectedOutputString /* expectedOutputString */,
1217
				expectedErrorString /* expectedErrorString */,
1216
				this.classpaths, 
1218
				this.classpaths, 
1217
				null, 
1219
				null, 
1218
				vmArguments);
1220
				vmArguments);
1219
		if (!passed) {
1221
		if (!passed) {
1220
			String platformIndependantExpectedSuccessOutputString = Util.convertToIndependantLineDelimiter(expectedSuccessOutputString);
1222
			String platformIndependantExpectedSuccessOutputString = Util.convertToIndependantLineDelimiter(expectedOutputString);
1221
			String platformIndependantFailureReason = Util.convertToIndependantLineDelimiter(this.verifier.failureReason);
1223
			String platformIndependantFailureReason = Util.convertToIndependantLineDelimiter(this.verifier.failureReason);
1222
			if (platformIndependantFailureReason.indexOf(platformIndependantExpectedSuccessOutputString) == -1) {
1224
			if (platformIndependantFailureReason.indexOf(platformIndependantExpectedSuccessOutputString) == -1) {
1223
				System.out.println(getClass().getName() + '#' + getName());
1225
				System.out.println(getClass().getName() + '#' + getName());
Lines 1245-1250 Link Here
1245
			boolean expectingCompilerErrors,
1247
			boolean expectingCompilerErrors,
1246
			String expectedCompilerLog,
1248
			String expectedCompilerLog,
1247
			String expectedOutputString,
1249
			String expectedOutputString,
1250
			String expectedErrorString,
1248
			boolean forceExecution,
1251
			boolean forceExecution,
1249
			String[] classLib,
1252
			String[] classLib,
1250
			boolean shouldFlushOutputDirectory, 
1253
			boolean shouldFlushOutputDirectory, 
Lines 1330-1337 Link Here
1330
				boolean passed = 
1333
				boolean passed = 
1331
					this.verifier.verifyClassFiles(
1334
					this.verifier.verifyClassFiles(
1332
						sourceFile, 
1335
						sourceFile, 
1333
						className, 
1336
						className,
1334
						expectedOutputString,
1337
						expectedOutputString,
1338
						expectedErrorString,
1335
						this.classpaths, 
1339
						this.classpaths, 
1336
						null, 
1340
						null, 
1337
						vmArguments);
1341
						vmArguments);
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java (+1 lines)
Lines 88-93 Link Here
88
		expectingCompilerErrors,
88
		expectingCompilerErrors,
89
		expectedCompilerLog,
89
		expectedCompilerLog,
90
		expectedOutputString,
90
		expectedOutputString,
91
		"" /* expectedErrorString */,
91
		forceExecution,
92
		forceExecution,
92
		classLib,
93
		classLib,
93
		shouldFlushOutputDirectory, 
94
		shouldFlushOutputDirectory, 
(-)src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java (-1 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 5194-5199 Link Here
5194
		false /* expectingCompilerErrors */,
5194
		false /* expectingCompilerErrors */,
5195
		"" /* expectedCompilerLog */,
5195
		"" /* expectedCompilerLog */,
5196
		"" /* expectedOutputString */,
5196
		"" /* expectedOutputString */,
5197
		"" /* expectedErrorString */,
5197
		false /* forceExecution */,
5198
		false /* forceExecution */,
5198
		null /* classLib */,
5199
		null /* classLib */,
5199
		true /* shouldFlushOutputDirectory */, 
5200
		true /* shouldFlushOutputDirectory */, 
Lines 5725-5730 Link Here
5725
		"Null pointer access: The variable t can only be null at this location\n" + 
5726
		"Null pointer access: The variable t can only be null at this location\n" + 
5726
		"----------\n" /* expectedCompilerLog */,
5727
		"----------\n" /* expectedCompilerLog */,
5727
		"" /* expectedOutputString */,
5728
		"" /* expectedOutputString */,
5729
		"" /* expectedErrorString */,
5728
		false /* forceExecution */,
5730
		false /* forceExecution */,
5729
		null /* classLib */,
5731
		null /* classLib */,
5730
		true /* shouldFlushOutputDirectory */, 
5732
		true /* shouldFlushOutputDirectory */, 
Lines 5759-5764 Link Here
5759
		"Potential null pointer access: The variable t may be null at this location\n" + 
5761
		"Potential null pointer access: The variable t may be null at this location\n" + 
5760
		"----------\n" /* expectedCompilerLog */,
5762
		"----------\n" /* expectedCompilerLog */,
5761
		"" /* expectedOutputString */,
5763
		"" /* expectedOutputString */,
5764
		"" /* expectedErrorString */,
5762
		false /* forceExecution */,
5765
		false /* forceExecution */,
5763
		null /* classLib */,
5766
		null /* classLib */,
5764
		true /* shouldFlushOutputDirectory */, 
5767
		true /* shouldFlushOutputDirectory */, 
Lines 5788-5793 Link Here
5788
		false /* expectingCompilerErrors */,
5791
		false /* expectingCompilerErrors */,
5789
		"" /* expectedCompilerLog */,
5792
		"" /* expectedCompilerLog */,
5790
		"" /* expectedOutputString */,
5793
		"" /* expectedOutputString */,
5794
		"" /* expectedErrorString */,
5791
		false /* forceExecution */,
5795
		false /* forceExecution */,
5792
		null /* classLib */,
5796
		null /* classLib */,
5793
		true /* shouldFlushOutputDirectory */, 
5797
		true /* shouldFlushOutputDirectory */, 
Lines 7238-7243 Link Here
7238
		"Potential null pointer access: The variable str may be null at this location\n" + 
7242
		"Potential null pointer access: The variable str may be null at this location\n" + 
7239
		"----------\n" /* expectedCompilerLog */,
7243
		"----------\n" /* expectedCompilerLog */,
7240
		"" /* expectedOutputString */,
7244
		"" /* expectedOutputString */,
7245
		"" /* expectedErrorString */,
7241
		false /* forceExecution */,
7246
		false /* forceExecution */,
7242
		null /* classLib */,
7247
		null /* classLib */,
7243
		true /* shouldFlushOutputDirectory */, 
7248
		true /* shouldFlushOutputDirectory */, 
Lines 7276-7281 Link Here
7276
		"Potential null pointer access: The variable str may be null at this location\n" + 
7281
		"Potential null pointer access: The variable str may be null at this location\n" + 
7277
		"----------\n" /* expectedCompilerLog */,
7282
		"----------\n" /* expectedCompilerLog */,
7278
		"" /* expectedOutputString */,
7283
		"" /* expectedOutputString */,
7284
		"" /* expectedErrorString */,
7279
		false /* forceExecution */,
7285
		false /* forceExecution */,
7280
		null /* classLib */,
7286
		null /* classLib */,
7281
		true /* shouldFlushOutputDirectory */, 
7287
		true /* shouldFlushOutputDirectory */, 
Lines 8760-8765 Link Here
8760
			"Null pointer access: The variable o can only be null at this location\n" + 
8766
			"Null pointer access: The variable o can only be null at this location\n" + 
8761
			"----------\n" /* expectedCompilerLog */,
8767
			"----------\n" /* expectedCompilerLog */,
8762
			"" /* expectedOutputString */,
8768
			"" /* expectedOutputString */,
8769
			"" /* expectedErrorString */,
8763
			false /* forceExecution */,
8770
			false /* forceExecution */,
8764
			null /* classLib */,
8771
			null /* classLib */,
8765
			true /* shouldFlushOutputDirectory */, 
8772
			true /* shouldFlushOutputDirectory */, 
(-)src/org/eclipse/jdt/core/tests/compiler/regression/RuntimeTests.java (-5 / +14 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 44-51 Link Here
44
44
45
// memory exhaustion - try to allocate too big an instance
45
// memory exhaustion - try to allocate too big an instance
46
public void test0001_memory_exhaustion() {
46
public void test0001_memory_exhaustion() {
47
	this.runConformTest(
47
	runTest(
48
		new String[] {
48
		new String[] { /* testFiles */
49
			"X.java",
49
			"X.java",
50
			"public class X {\n" + 
50
			"public class X {\n" + 
51
			"  public static void main(String args[]) {\n" + 
51
			"  public static void main(String args[]) {\n" + 
Lines 65-72 Link Here
65
			"    storage = new long[itemsNb];\n" +
65
			"    storage = new long[itemsNb];\n" +
66
			"  }\n" + 
66
			"  }\n" + 
67
			"}\n"},
67
			"}\n"},
68
		"SUCCESS"
68
		false /* expectingCompilerErrors */,
69
	);
69
		"" /* expectedCompilerLog */,
70
		"SUCCESS" /* expectedOutputString */,
71
		null /* expectedErrorString - skip this because some JREs emit additional info to stderr in case of exception */,
72
		false /* forceExecution */,
73
		null /* classLib */,
74
		true /* shouldFlushOutputDirectory */, 
75
		null /* vmArguments */, 
76
		null /* customOptions */,
77
		null /* clientRequestor */,
78
		true /* skipJavac */);
70
}
79
}
71
80
72
// synchronization - concurrent access to a resource with explicit and
81
// synchronization - concurrent access to a resource with explicit and
(-)src/org/eclipse/jdt/core/tests/util/TestVerifier.java (-25 / +46 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 30-58 Link Here
30
public TestVerifier(boolean reuseVM) {
30
public TestVerifier(boolean reuseVM) {
31
	this.reuseVM = reuseVM;
31
	this.reuseVM = reuseVM;
32
}
32
}
33
private boolean checkBuffers(String errorString, String outputString, String sourceFileName, String expectedSuccessOutputString) {
33
private boolean checkBuffers(String outputString, String errorString, 
34
34
		String sourceFileName, String expectedOutputString, String expectedErrorStringStart) {
35
	if (errorString.trim().length() > 0) {
35
	String platformIndependantString;
36
		this.failureReason =
36
	if (expectedOutputString != null) {
37
			"Unexpected target error running resulting class file for "
37
		platformIndependantString = Util.convertToIndependantLineDelimiter(outputString.trim());
38
				+ sourceFileName
38
		if (!Util.convertToIndependantLineDelimiter(expectedOutputString).equals(platformIndependantString)) {
39
				+ ":\n"
39
			System.out.println(Util.displayString(platformIndependantString, 2));
40
				+ errorString;
40
			this.failureReason =
41
		return false;
41
				"Unexpected output running resulting class file for "
42
	}
42
					+ sourceFileName
43
	String platformIndependantOutputString = Util.convertToIndependantLineDelimiter(outputString.trim());
43
					+ ":\n"
44
	if (expectedSuccessOutputString != null && !Util.convertToIndependantLineDelimiter(expectedSuccessOutputString).equals(platformIndependantOutputString)) {
44
					+ "--[START]--\n"
45
		System.out.println(Util.displayString(platformIndependantOutputString, 2));
45
					+ outputString
46
		this.failureReason =
46
					+ "---[END]---\n";
47
			"Unexpected output running resulting class file for "
47
			return false;
48
				+ sourceFileName
48
		}
49
				+ ":\n"
49
	}	
50
				+ "--[START]--\n"
50
	if (expectedErrorStringStart != null) {
51
				+ outputString
51
		platformIndependantString = Util.convertToIndependantLineDelimiter(errorString.trim());
52
				+ "---[END]---\n";
52
		if (expectedErrorStringStart.length() == 0 && platformIndependantString.length() > 0 ||
53
		return false;
53
				!platformIndependantString.startsWith(Util.convertToIndependantLineDelimiter(expectedErrorStringStart))) {
54
			/*
55
			 * This is an opportunistic heuristic for error strings comparison:
56
			 * - null means skip test;
57
			 * - empty means exactly empty;
58
			 * - other means starts with.
59
			 * If this became insufficient, we could envision using specific
60
			 * matchers for specific needs.
61
			 */
62
			System.out.println(Util.displayString(platformIndependantString, 2));
63
			this.failureReason =
64
				"Unexpected error running resulting class file for "
65
					+ sourceFileName
66
					+ ":\n"
67
					+ "--[START]--\n"
68
					+ errorString
69
					+ "---[END]---\n";
70
			return false;
71
		}
54
	}
72
	}
55
	
56
	return true;
73
	return true;
57
}
74
}
58
75
Lines 557-569 Link Here
557
 * a virtual machine.
574
 * a virtual machine.
558
 */
575
 */
559
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths) {
576
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths) {
560
	return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, classpaths, null, null);
577
	return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, "", classpaths, null, null);
561
}
578
}
562
/**
579
/**
563
 * Verify that the class files created for the given test file can be loaded by
580
 * Verify that the class files created for the given test file can be loaded by
564
 * a virtual machine.
581
 * a virtual machine.
565
 */
582
 */
566
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String[] programArguments, String[] vmArguments) {
583
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String[] programArguments, String[] vmArguments) {
584
	return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, "", classpaths, programArguments, vmArguments);
585
}
586
public boolean verifyClassFiles(String sourceFilePath, String className, String expectedOutputString, 
587
		String expectedErrorStringStart, String[] classpaths, String[] programArguments, String[] vmArguments) {
567
	this.outputBuffer = new StringBuffer();
588
	this.outputBuffer = new StringBuffer();
568
	this.errorBuffer = new StringBuffer();
589
	this.errorBuffer = new StringBuffer();
569
	if (this.reuseVM && programArguments == null) {
590
	if (this.reuseVM && programArguments == null) {
Lines 574-580 Link Here
574
	}
595
	}
575
	
596
	
576
	this.failureReason = null;
597
	this.failureReason = null;
577
	return this.checkBuffers(this.errorBuffer.toString(), this.outputBuffer.toString(), sourceFilePath, expectedSuccessOutputString);
598
	return this.checkBuffers(this.outputBuffer.toString(), this.errorBuffer.toString(), sourceFilePath, expectedOutputString, expectedErrorStringStart);
578
}
599
}
579
600
580
/**
601
/**

Return to bug 217078