Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * Copyright 2011 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 /**
20 * Tests for {@link ClosureOptimizePrimitives}.
21 *
22 * @author [email protected] (Andrew Grieve)
23 */
24 public class ClosureOptimizePrimitivesTest extends CompilerTestCase {
25
26 @Override public CompilerPass getProcessor(final Compiler compiler) {
27 return new ClosureOptimizePrimitives(compiler);
28 }
29
30 public void testObjectCreateNonConstKey() {
31 testSame("goog.object.create('a',1,2,3,foo,bar);");
32 }
33
34 public void testObjectCreateOddParams() {
35 testSame("goog.object.create('a',1,2);");
36 }
37
38 public void testObjectCreate1() {
39 test("var a = goog.object.create()", "var a = {}");
40 }
41
42 public void testObjectCreate2() {
43 test("var a = goog$object$create('b',goog$object$create('c','d'))",
44 "var a = {'b':{'c':'d'}};");
45 }
46
47 public void testObjectCreate3() {
48 test("var a = goog.object.create(1,2)", "var a = {1:2}");
49 }
50
51 public void testObjectCreate4() {
52 test("alert(goog.object.create(1,2).toString())",
53 "alert({1:2}.toString())");
54 }
55
56 public void testObjectCreate5() {
57 test("goog.object.create('a',2).toString()", "({'a':2}).toString()");
58 }
59 }