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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiterals15Test.java (-1 / +78 lines)
Lines 20-26 Link Here
20
20
21
static {
21
static {
22
//	TESTS_NAMES = new String[] { "test000" };
22
//	TESTS_NAMES = new String[] { "test000" };
23
//	TESTS_NUMBERS = new int[] { 3 };
23
//	TESTS_NUMBERS = new int[] { 6 };
24
//	TESTS_RANGE = new int[] { 11, -1 };
24
//	TESTS_RANGE = new int[] { 11, -1 };
25
}
25
}
26
public ExternalizeStringLiterals15Test(String name) {
26
public ExternalizeStringLiterals15Test(String name) {
Lines 81-86 Link Here
81
		"	String s3 = \"test2\"; //$NON-NLS-1$//$NON-NLS-2$\n" + 
81
		"	String s3 = \"test2\"; //$NON-NLS-1$//$NON-NLS-2$\n" + 
82
		"	                                  ^^^^^^^^^^^^^\n" + 
82
		"	                                  ^^^^^^^^^^^^^\n" + 
83
		"Unnecessary $NON-NLS$ tag\n" + 
83
		"Unnecessary $NON-NLS$ tag\n" + 
84
		"----------\n" + 
85
		"2. ERROR in X.java (at line 8)\n" + 
86
		"	String s5 = \"test3\";\n" + 
87
		"	            ^^^^^^^\n" + 
88
		"Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" + 
89
		"----------\n" + 
90
		"3. ERROR in X.java (at line 9)\n" + 
91
		"	String s6 = \"test4\";\n" + 
92
		"	            ^^^^^^^\n" + 
93
		"Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" + 
94
		"----------\n" + 
95
		"4. ERROR in X.java (at line 10)\n" + 
96
		"	System.out.println(\"test5\");\n" + 
97
		"	                   ^^^^^^^\n" + 
98
		"Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" + 
84
		"----------\n",
99
		"----------\n",
85
		null,
100
		null,
86
		true,
101
		true,
Lines 110-115 Link Here
110
		"	String s3 = \"test2\"; //$NON-NLS-1$//$NON-NLS-2$\n" + 
125
		"	String s3 = \"test2\"; //$NON-NLS-1$//$NON-NLS-2$\n" + 
111
		"	                                  ^^^^^^^^^^^^^\n" + 
126
		"	                                  ^^^^^^^^^^^^^\n" + 
112
		"Unnecessary $NON-NLS$ tag\n" + 
127
		"Unnecessary $NON-NLS$ tag\n" + 
128
		"----------\n" + 
129
		"2. ERROR in X.java (at line 8)\n" + 
130
		"	String s5 = null;//$NON-NLS-1$\n" + 
131
		"	                 ^^^^^^^^^^^^^\n" + 
132
		"Unnecessary $NON-NLS$ tag\n" + 
133
		"----------\n" + 
134
		"3. ERROR in X.java (at line 9)\n" + 
135
		"	String s6 = \"test4\";\n" + 
136
		"	            ^^^^^^^\n" + 
137
		"Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" + 
138
		"----------\n" + 
139
		"4. ERROR in X.java (at line 10)\n" + 
140
		"	System.out.println(\"test5\");\n" + 
141
		"	                   ^^^^^^^\n" + 
142
		"Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" + 
113
		"----------\n",
143
		"----------\n",
114
		null,
144
		null,
115
		true,
145
		true,
Lines 144-149 Link Here
144
		true,
174
		true,
145
		customOptions);
175
		customOptions);
146
}
176
}
177
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162903
178
public void test005() {
179
	Map customOptions = getCompilerOptions();
180
	customOptions.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.ERROR);
181
	this.runNegativeTest(
182
		new String[] {
183
			"X.java",
184
			"class X {\n" +
185
			"	@SuppressWarnings(\"nls\")\n" +
186
			"	void foo() {\n" +
187
			"		String s6 = \"SUCCESS\";\n" +
188
			"		System.out.println(s6);\n" +
189
			"	}\n" +
190
			"}",
191
		},
192
		"----------\n" + 
193
		"1. ERROR in X.java (at line 4)\n" + 
194
		"	String s6 = \"SUCCESS\";\n" + 
195
		"	            ^^^^^^^^^\n" + 
196
		"Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" + 
197
		"----------\n",
198
		null,
199
		true,
200
		customOptions);
201
}
202
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162903
203
public void test006() {
204
	Map customOptions = getCompilerOptions();
205
	customOptions.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.WARNING);
206
	this.runConformTest(
207
		new String[] {
208
			"X.java",
209
			"public class X {\n" +
210
			"	@SuppressWarnings(\"nls\")\n" +
211
			"	public static void main(String[] args) {\n" +
212
			"		String s6 = \"SUCCESS\";\n" +
213
			"		System.out.println(s6);\n" +
214
			"	}\n" +
215
			"}",
216
		},
217
		"SUCCESS",
218
		null,
219
		true,
220
		null,
221
		customOptions,
222
		null);
223
}
147
public static Class testClass() {
224
public static Class testClass() {
148
	return ExternalizeStringLiterals15Test.class;
225
	return ExternalizeStringLiterals15Test.class;
149
}
226
}

Return to bug 162903