Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2006 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.compiler.regression; |
12 |
|
13 |
import java.util.HashMap; |
14 |
import java.util.Map; |
15 |
|
16 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
17 |
|
18 |
import junit.framework.Test; |
19 |
|
20 |
/** |
21 |
* This class is meant to gather test cases related to the invocation of the |
22 |
* compiler, be it at an API or non API level. |
23 |
*/ |
24 |
public class CompilerInvocationTests extends AbstractRegressionTest { |
25 |
|
26 |
public CompilerInvocationTests(String name) { |
27 |
super(name); |
28 |
} |
29 |
|
30 |
// Static initializer to specify tests subset using TESTS_* static variables |
31 |
// All specified tests which does not belong to the class are skipped... |
32 |
// Only the highest compliance level is run; add the VM argument |
33 |
// -Dcompliance=1.4 (for example) to lower it if needed |
34 |
static { |
35 |
// TESTS_NAMES = new String[] { "test001" }; |
36 |
// TESTS_NUMBERS = new int[] { 1 }; |
37 |
// TESTS_RANGE = new int[] { 1, -1 }; |
38 |
// TESTS_RANGE = new int[] { 1, 2049 }; |
39 |
// TESTS_RANGE = new int[] { 449, 451 }; |
40 |
// TESTS_RANGE = new int[] { 900, 999 }; |
41 |
} |
42 |
|
43 |
public static Test suite() { |
44 |
return buildTestSuite(testClass()); |
45 |
} |
46 |
|
47 |
public static Class testClass() { |
48 |
return CompilerInvocationTests.class; |
49 |
} |
50 |
|
51 |
// irritant vs warning token |
52 |
public void test001_irritant_warning_token() { |
53 |
String [] tokens = new String[64]; |
54 |
Map matcher = new HashMap(); |
55 |
long irritant; |
56 |
String token; |
57 |
for (int i = 0; i < 64; i++) { |
58 |
if ((token = tokens[i] = CompilerOptions.warningTokenFromIrritant(irritant = 1L << i)) != null) { |
59 |
matcher.put(token, token); |
60 |
assertTrue((irritant & CompilerOptions.warningTokenToIrritant(token)) != 0); |
61 |
} |
62 |
} |
63 |
String [] allTokens = CompilerOptions.warningTokens; |
64 |
int length = allTokens.length; |
65 |
matcher.put("all", "all"); // all gets undetected in the From/To loop |
66 |
assertEquals(allTokens.length, matcher.size()); |
67 |
for (int i = 0; i < length; i++) { |
68 |
assertNotNull(matcher.get(allTokens[i])); |
69 |
} |
70 |
} |
71 |
|
72 |
} |