| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.google.javascript.jscomp; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 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 |
} |