Debian Codegraph @

test/com/google/javascript/jscomp/CompilerOptionsTest.java

raw symbols SCIP
1 /*
2 * Copyright 2009 The Closure Compiler Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 * Tests for {@link CompilerOptions}.
28 * @author [email protected] (Nick Santos)
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 }