| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.google.javascript.jscomp; |
| 18 |
|
| 19 |
import com.google.javascript.rhino.Node; |
| 20 |
import com.google.javascript.rhino.Token; |
| 21 |
|
| 22 |
import junit.framework.TestCase; |
| 23 |
|
| 24 |
import java.util.Map; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public class CompilerOptionsTest extends TestCase { |
| 31 |
|
| 32 |
public void testDefines() throws Exception { |
| 33 |
CompilerOptions options = new CompilerOptions(); |
| 34 |
options.setDefineToBooleanLiteral("trueVar", true); |
| 35 |
options.setDefineToBooleanLiteral("falseVar", false); |
| 36 |
options.setDefineToNumberLiteral("threeVar", 3); |
| 37 |
options.setDefineToStringLiteral("strVar", "str"); |
| 38 |
|
| 39 |
Map<String, Node> actual = options.getDefineReplacements(); |
| 40 |
assertEquivalent(new Node(Token.TRUE), actual.get("trueVar")); |
| 41 |
assertEquivalent(new Node(Token.FALSE), actual.get("falseVar")); |
| 42 |
assertEquivalent(Node.newNumber(3), actual.get("threeVar")); |
| 43 |
assertEquivalent(Node.newString("str"), actual.get("strVar")); |
| 44 |
} |
| 45 |
|
| 46 |
public void assertEquivalent(Node a, Node b) { |
| 47 |
assertTrue(a.isEquivalentTo(b)); |
| 48 |
} |
| 49 |
} |