| 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 |
public class ObjectPropertyStringPreprocessTest extends CompilerTestCase { |
| 24 |
@Override |
| 25 |
protected CompilerPass getProcessor(final Compiler compiler) { |
| 26 |
return new ObjectPropertyStringPreprocess(compiler); |
| 27 |
} |
| 28 |
|
| 29 |
@Override |
| 30 |
protected int getNumRepetitions() { |
| 31 |
return 1; |
| 32 |
} |
| 33 |
|
| 34 |
@Override |
| 35 |
protected void setUp() { |
| 36 |
super.allowExternsChanges(true); |
| 37 |
} |
| 38 |
|
| 39 |
public void testDeclaration() { |
| 40 |
test("goog.testing.ObjectPropertyString = function() {}", |
| 41 |
"JSCompiler_ObjectPropertyString = function() {}"); |
| 42 |
} |
| 43 |
|
| 44 |
public void testFooBar() { |
| 45 |
test("new goog.testing.ObjectPropertyString(foo, 'bar')", |
| 46 |
"new JSCompiler_ObjectPropertyString(goog.global, foo.bar)"); |
| 47 |
} |
| 48 |
|
| 49 |
public void testFooPrototypeBar() { |
| 50 |
test("new goog.testing.ObjectPropertyString(foo.prototype, 'bar')", |
| 51 |
"new JSCompiler_ObjectPropertyString(goog.global, " + |
| 52 |
"foo.prototype.bar)"); |
| 53 |
} |
| 54 |
|
| 55 |
public void testInvalidNumArgumentsError() { |
| 56 |
testSame(new String[] {"new goog.testing.ObjectPropertyString()"}, |
| 57 |
ObjectPropertyStringPreprocess.INVALID_NUM_ARGUMENTS_ERROR); |
| 58 |
} |
| 59 |
|
| 60 |
public void testQualifedNameExpectedError() { |
| 61 |
testSame( |
| 62 |
new String[] { |
| 63 |
"new goog.testing.ObjectPropertyString(foo[a], 'bar')" |
| 64 |
}, |
| 65 |
ObjectPropertyStringPreprocess.QUALIFIED_NAME_EXPECTED_ERROR); |
| 66 |
} |
| 67 |
|
| 68 |
public void testStringLiteralExpectedError() { |
| 69 |
testSame(new String[] {"new goog.testing.ObjectPropertyString(foo, bar)"}, |
| 70 |
ObjectPropertyStringPreprocess.STRING_LITERAL_EXPECTED_ERROR); |
| 71 |
} |
| 72 |
} |