Debian Codegraph @

test/com/google/javascript/jscomp/ObjectPropertyStringPreprocessTest.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 /**
20 * Tests for {@link ObjectPropertyStringPreprocess}
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 }