Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 405038 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java (+107 lines)
Lines 64-69 Link Here
64
	static {
64
	static {
65
//		TESTS_NUMBERS = new int[] { 783 };
65
//		TESTS_NUMBERS = new int[] { 783 };
66
//		TESTS_RANGE = new int[] { 734, -1 };
66
//		TESTS_RANGE = new int[] { 734, -1 };
67
//		TESTS_NAMES = new String[] {
68
//			"testBug405038",
69
//			"testBug405038_2",
70
//			"testBug405038_3",
71
//			"testBug405038_4",
72
//			"testBug405038_5"
73
//		};
67
	}
74
	}
68
	public static Test suite() {
75
	public static Test suite() {
69
		return buildModelTestSuite(FormatterRegressionTests.class);
76
		return buildModelTestSuite(FormatterRegressionTests.class);
Lines 12938-12941 Link Here
12938
		"}\n"
12945
		"}\n"
12939
	);
12946
	);
12940
}
12947
}
12948
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038
12949
//To verify that the whitespace options for resources in try statement work correctly
12950
public void testBug405038() throws Exception {
12951
	this.formatterPrefs = null;
12952
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
12953
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
12954
	String source =
12955
		"public class FormatterError {\n" +
12956
		"  int foo(int a, int b, int c) {\n" + 
12957
		"        return a + b + ++c;\n" + 
12958
		"    }\n" +
12959
		"}\n";
12960
	formatSource(source,
12961
		"public class FormatterError {\n" + 
12962
		"	int foo(int a, int b, int c) {\n" + 
12963
		"		return a+b+ ++c;\n" + 
12964
		"	}\n" + 
12965
		"}\n"
12966
	);
12967
}
12968
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038
12969
//To verify that the whitespace options for resources in try statement work correctly
12970
public void testBug405038_2() throws Exception {
12971
	this.formatterPrefs = null;
12972
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
12973
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
12974
	String source =
12975
		"public class FormatterError {\n" +
12976
		"  int foo(int a, int b, int c) {\n" + 
12977
		"        return a + ++b + c;\n" + 
12978
		"    }\n" +
12979
		"}\n";
12980
	formatSource(source,
12981
		"public class FormatterError {\n" + 
12982
		"	int foo(int a, int b, int c) {\n" + 
12983
		"		return a+ ++b+c;\n" + 
12984
		"	}\n" + 
12985
		"}\n"
12986
	);
12987
}
12988
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038
12989
//To verify that the whitespace options for resources in try statement work correctly
12990
public void testBug405038_3() throws Exception {
12991
	this.formatterPrefs = null;
12992
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
12993
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
12994
	String source =
12995
		"public class FormatterError {\n" +
12996
		"  int foo(int a, int b, int c) {\n" + 
12997
		"        return a - --b + c;\n" + 
12998
		"    }\n" +
12999
		"}\n";
13000
	formatSource(source,
13001
		"public class FormatterError {\n" + 
13002
		"	int foo(int a, int b, int c) {\n" + 
13003
		"		return a- --b+c;\n" + 
13004
		"	}\n" + 
13005
		"}\n"
13006
	);
13007
}
13008
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038
13009
//To verify that the whitespace options for resources in try statement work correctly
13010
public void testBug405038_4() throws Exception {
13011
	this.formatterPrefs = null;
13012
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
13013
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
13014
	String source =
13015
		"public class FormatterError {\n" +
13016
		"  int foo(int a, int b, int c) {\n" + 
13017
		"        return a - -b + c;\n" + 
13018
		"    }\n" +
13019
		"}\n";
13020
	formatSource(source,
13021
		"public class FormatterError {\n" + 
13022
		"	int foo(int a, int b, int c) {\n" + 
13023
		"		return a- -b+c;\n" + 
13024
		"	}\n" + 
13025
		"}\n"
13026
	);
13027
}
13028
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038
13029
//To verify that the whitespace options for resources in try statement work correctly
13030
public void testBug405038_5() throws Exception {
13031
	this.formatterPrefs = null;
13032
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
13033
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, JavaCore.DO_NOT_INSERT);
13034
	String source =
13035
		"public class FormatterError {\n" +
13036
		"  int foo(int a, int b, int c) {\n" + 
13037
		"        return a - -b + ++c;\n" + 
13038
		"    }\n" +
13039
		"}\n";
13040
	formatSource(source,
13041
		"public class FormatterError {\n" + 
13042
		"	int foo(int a, int b, int c) {\n" + 
13043
		"		return a- -b+ ++c;\n" + 
13044
		"	}\n" + 
13045
		"}\n"
13046
	);
13047
}
12941
}
13048
}

Return to bug 405038