diff --git a/src/com/google/javascript/jscomp/testing/NodeSubject.java b/src/com/google/javascript/jscomp/testing/NodeSubject.java deleted file mode 100644 index 8bd7d027c7d..00000000000 --- a/src/com/google/javascript/jscomp/testing/NodeSubject.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2015 The Closure Compiler Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.javascript.jscomp.testing; - -import static com.google.common.base.Strings.lenientFormat; -import static com.google.common.truth.Fact.simpleFact; -import static com.google.common.truth.Truth.assertAbout; -import static org.junit.Assert.assertEquals; - -import com.google.common.truth.FailureMetadata; -import com.google.common.truth.Subject; -import com.google.javascript.rhino.Node; -import com.google.javascript.rhino.Token; -import javax.annotation.CheckReturnValue; - -/** - * A Truth Subject for the Node class. Usage: - *
- *   import static com.google.javascript.jscomp.testing.NodeSubject.assertNode;
- *   ...
- *   assertNode(node1).isEqualTo(node2);
- *   assertNode(node1).hasType(Token.FUNCTION);
- * 
- */ -public final class NodeSubject extends Subject { - @CheckReturnValue - public static NodeSubject assertNode(Node node) { - return assertAbout(NodeSubject::new).that(node); - } - - public NodeSubject(FailureMetadata failureMetadata, Node node) { - super(failureMetadata, node); - } - - public void isEqualTo(Node node) { - String treeDiff = node.checkTreeEquals(actual()); - if (treeDiff != null) { - failWithoutActual(simpleFact(lenientFormat("%s", treeDiff))); - } - } - - public void hasType(Token type) { - String message = "Node is of type " + actual().getToken() + " not of type " + type; - assertEquals(message, type, actual().getToken()); - } - - public void isName(String name) { - Node node = actual(); - if (!node.isName()) { - failWithActual(simpleFact("expected to be a NAME node")); - } - if (!node.getString().equals(name)) { - failWithActual("expected name to be", name); - } - } - - public void matchesQualifiedName(String qname) { - Node node = actual(); - if (!node.matchesQualifiedName(qname)) { - failWithActual("expected qualified name", qname); - } - } - - public void hasCharno(int charno) { - assertEquals(charno, actual().getCharno()); - } - - public void hasLineno(int lineno) { - assertEquals(lineno, actual().getLineno()); - } - - public void hasLength(int length) { - assertEquals(length, actual().getLength()); - } -} diff --git a/src/com/google/javascript/jscomp/testing/TypeSubject.java b/src/com/google/javascript/jscomp/testing/TypeSubject.java deleted file mode 100644 index 51767371fae..00000000000 --- a/src/com/google/javascript/jscomp/testing/TypeSubject.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2017 The Closure Compiler Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.javascript.jscomp.testing; - -import static com.google.common.truth.Truth.assertAbout; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import com.google.common.truth.FailureMetadata; -import com.google.common.truth.Subject; -import com.google.javascript.rhino.jstype.JSType; -import com.google.javascript.rhino.jstype.ObjectType; -import javax.annotation.CheckReturnValue; - -/** - * A Truth Subject for the JSType interface. Usage: - *
- *   import static com.google.javascript.jscomp.testing.TypeSubject.assertType;
- *   ...
- *   assertType(type1).isLiteralObject();
- *   assertType(type2).isObjectTypeWithProperty("propName").withTypeOfProp("propName").isNumber();
- * 
- */ -public final class TypeSubject extends Subject { - @CheckReturnValue - public static TypeSubject assertType(JSType type) { - return assertAbout(types()).that(type); - } - - public static Subject.Factory types() { - return TypeSubject::new; - } - - public TypeSubject(FailureMetadata failureMetadata, JSType type) { - super(failureMetadata, type); - } - - public void isNumber() { - String message = "Type is of type " + actualAsString() + " not a number."; - assertTrue(message, actual().isNumberValueType()); - } - - public void isString() { - String message = "Type is of type " + actualAsString() + " not a string."; - assertTrue(message, actual().isStringValueType()); - } - - public void isBoolean() { - String message = "Type is of type " + actualAsString() + " not a boolean."; - assertTrue(message, actual().isBooleanValueType()); - } - - public void isUnknown() { - String message = "Type is of type " + actualAsString() + " not unknown."; - assertTrue(message, actual().isUnknownType()); - } - - public void isLiteralObject() { - String message = "Type is of type " + actualAsString() + " not a literal object."; - assertTrue(message, actual().isLiteralObject()); - } - - public TypeSubject isObjectTypeWithProperty(String propName) { - isLiteralObject(); - ObjectType objType = actual().toMaybeObjectType(); - JSType actualPropType = objType.getPropertyType(propName); - assertNotNull( - "Type " + actualAsString() + " does not have property " + propName, actualPropType); - return this; - } - - /** - * Returns a {@code TypeSubject} that is the type of the property with name propName, - * to make assertions about the objectType's property Type message. - * Assumes that {@code actual()} is an object type with property propName, - * so it should be run after {@link #isObjectTypeWithProperty}. - */ - public TypeSubject withTypeOfProp(String propName) { - JSType actualPropType = actual().toMaybeObjectType().getPropertyType(propName); - return check().about(types()).that(actualPropType); - } - - public void isObjectTypeWithoutProperty(String propName) { - isLiteralObject(); - ObjectType objType = actual().toMaybeObjectType(); - JSType actualPropType = objType.getPropertyType(propName); - assertNull( - "Type " + actualAsString() + " should not have property " + propName, actualPropType); - } - - public void isSubtypeOf(JSType superType) { - String message = "Type " + actualAsString() + " should be a subtype of " + superType; - assertTrue(message, actual().isSubtypeOf(superType)); - } - - public void toStringIsEqualTo(String typeString) { - assertEquals(typeString, actual().toString()); - } -} diff --git a/src/com/google/javascript/rhino/testing/NodeSubject.java b/src/com/google/javascript/rhino/testing/NodeSubject.java new file mode 100644 index 00000000000..28f4b1bb5af --- /dev/null +++ b/src/com/google/javascript/rhino/testing/NodeSubject.java @@ -0,0 +1,106 @@ +/* + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Rhino code, released + * May 6, 1999. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1997-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Bob Jervis + * Google Inc. + * + * Alternatively, the contents of this file may be used under the terms of + * the GNU General Public License Version 2 or later (the "GPL"), in which + * case the provisions of the GPL are applicable instead of those above. If + * you wish to allow use of your version of this file only under the terms of + * the GPL and not to allow others to use your version of this file under the + * MPL, indicate your decision by deleting the provisions above and replacing + * them with the notice and other provisions required by the GPL. If you do + * not delete the provisions above, a recipient may use your version of this + * file under either the MPL or the GPL. + * + * ***** END LICENSE BLOCK ***** */ + +package com.google.javascript.rhino.testing; + +import static com.google.common.truth.Truth.assertAbout; + +import com.google.common.truth.FailureMetadata; +import com.google.common.truth.Subject; +import com.google.javascript.rhino.Node; +import com.google.javascript.rhino.Token; +import javax.annotation.CheckReturnValue; + +/** + * A Truth Subject for the Node class. Usage: + * + *
+ *   import static com.google.javascript.rhino.testing.NodeSubject.assertNode;
+ *   ...
+ *   assertNode(node1).isEqualTo(node2);
+ *   assertNode(node1).hasType(Token.FUNCTION);
+ * 
+ */ +public final class NodeSubject extends Subject { + @CheckReturnValue + public static NodeSubject assertNode(Node node) { + return assertAbout(nodes()).that(node); + } + + public static Subject.Factory nodes() { + return NodeSubject::new; + } + + private NodeSubject(FailureMetadata failureMetadata, Node node) { + super(failureMetadata, node); + } + + public void isEqualTo(Node node) { + check("checkTreeEquals(%s)", node).that(actual().checkTreeEquals(node)).isNull(); + } + + public void hasType(Token type) { + hasToken(type); + } + + public void hasToken(Token token) { + check("getToken()").that(actual().getToken()).isEqualTo(token); + } + + public void isName(String name) { + check("isName()").that(actual().isName()).isTrue(); + check("getString()").that(actual().getString()).isEqualTo(name); + } + + public void matchesQualifiedName(String qname) { + check("matchesQualifiedName(%s)", qname).that(actual().matchesQualifiedName(qname)).isTrue(); + } + + public void hasCharno(int charno) { + check("getCharno()").that(actual().getCharno()).isEqualTo(charno); + } + + public void hasLineno(int lineno) { + check("getLineno()").that(actual().getLineno()).isEqualTo(lineno); + } + + public void hasLength(int length) { + check("getLength()").that(actual().getLength()).isEqualTo(length); + } +} diff --git a/src/com/google/javascript/rhino/testing/TypeSubject.java b/src/com/google/javascript/rhino/testing/TypeSubject.java new file mode 100644 index 00000000000..eed844bb28b --- /dev/null +++ b/src/com/google/javascript/rhino/testing/TypeSubject.java @@ -0,0 +1,125 @@ +/* + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Rhino code, released + * May 6, 1999. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1997-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Bob Jervis + * Google Inc. + * + * Alternatively, the contents of this file may be used under the terms of + * the GNU General Public License Version 2 or later (the "GPL"), in which + * case the provisions of the GPL are applicable instead of those above. If + * you wish to allow use of your version of this file only under the terms of + * the GPL and not to allow others to use your version of this file under the + * MPL, indicate your decision by deleting the provisions above and replacing + * them with the notice and other provisions required by the GPL. If you do + * not delete the provisions above, a recipient may use your version of this + * file under either the MPL or the GPL. + * + * ***** END LICENSE BLOCK ***** */ + +package com.google.javascript.rhino.testing; + +import static com.google.common.truth.Truth.assertAbout; + +import com.google.common.truth.FailureMetadata; +import com.google.common.truth.Subject; +import com.google.javascript.rhino.jstype.JSType; +import javax.annotation.CheckReturnValue; + +/** + * A Truth Subject for the JSType interface. Usage: + * + *
+ *   import static com.google.javascript.rhino.testing.TypeSubject.assertType;
+ *   ...
+ *   assertType(type1).isLiteralObject();
+ *   assertType(type2).isObjectTypeWithProperty("propName").withTypeOfProp("propName").isNumber();
+ * 
+ */ +public final class TypeSubject extends Subject { + @CheckReturnValue + public static TypeSubject assertType(JSType type) { + return assertAbout(types()).that(type); + } + + public static Subject.Factory types() { + return TypeSubject::new; + } + + private TypeSubject(FailureMetadata failureMetadata, JSType type) { + super(failureMetadata, type); + } + + public void isNumber() { + check("isNumberValueType()").that(actual().isNumberValueType()).isTrue(); + } + + public void isString() { + check("isStringValueType()").that(actual().isStringValueType()).isTrue(); + } + + public void isBoolean() { + check("isBooleanValueType()").that(actual().isBooleanValueType()).isTrue(); + } + + public void isUnknown() { + check("isUnknownType()").that(actual().isUnknownType()).isTrue(); + } + + public void isLiteralObject() { + check("isLiteralObject()").that(actual().isLiteralObject()).isTrue(); + } + + public TypeSubject isObjectTypeWithProperty(String propName) { + isLiteralObject(); + withTypeOfProp(propName).isNotNull(); + return this; + } + + /** + * Returns a {@code TypeSubject} that is the type of the property with name propName, + * to make assertions about the objectType's property Type message. + * Assumes that {@code actual()} is an object type with property propName, + * so it should be run after {@link #isObjectTypeWithProperty}. + */ + public TypeSubject withTypeOfProp(String propName) { + check("isObjectType()").that(actual().isObjectType()).isTrue(); + + return check("toMaybeObjectType().getPropertyType(%s)", propName) + .about(types()) + .that(actual().toMaybeObjectType().getPropertyType(propName)); + } + + public void isObjectTypeWithoutProperty(String propName) { + isLiteralObject(); + withTypeOfProp(propName).isNull(); + } + + public void isSubtypeOf(JSType superType) { + check("isSubtypeOf(%s)", superType).that(actual().isSubtypeOf(superType)).isTrue(); + } + + public void toStringIsEqualTo(String typeString) { + check("toString()").that(actual().toString()).isEqualTo(typeString); + } +} diff --git a/test/com/google/javascript/jscomp/AstValidatorTest.java b/test/com/google/javascript/jscomp/AstValidatorTest.java index d7e8a35a6b8..fbec14ab3a8 100644 --- a/test/com/google/javascript/jscomp/AstValidatorTest.java +++ b/test/com/google/javascript/jscomp/AstValidatorTest.java @@ -16,7 +16,7 @@ package com.google.javascript.jscomp; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.javascript.jscomp.AstValidator.ViolationHandler; import com.google.javascript.jscomp.CompilerOptions.LanguageMode; diff --git a/test/com/google/javascript/jscomp/CrossModuleReferenceCollectorTest.java b/test/com/google/javascript/jscomp/CrossModuleReferenceCollectorTest.java index fb4ac880e6a..fab30e7adf4 100644 --- a/test/com/google/javascript/jscomp/CrossModuleReferenceCollectorTest.java +++ b/test/com/google/javascript/jscomp/CrossModuleReferenceCollectorTest.java @@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT_NEXT; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; diff --git a/test/com/google/javascript/jscomp/Es6SyntacticScopeCreatorTest.java b/test/com/google/javascript/jscomp/Es6SyntacticScopeCreatorTest.java index 5fecc087bc6..bac57b8a9f9 100644 --- a/test/com/google/javascript/jscomp/Es6SyntacticScopeCreatorTest.java +++ b/test/com/google/javascript/jscomp/Es6SyntacticScopeCreatorTest.java @@ -21,7 +21,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.javascript.jscomp.CompilerTestCase.lines; import static com.google.javascript.jscomp.ScopeSubject.assertScope; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.collect.HashMultiset; import com.google.common.collect.Iterables; diff --git a/test/com/google/javascript/jscomp/ExpressionDecomposerTest.java b/test/com/google/javascript/jscomp/ExpressionDecomposerTest.java index 1653071ad88..aac3e02171e 100644 --- a/test/com/google/javascript/jscomp/ExpressionDecomposerTest.java +++ b/test/com/google/javascript/jscomp/ExpressionDecomposerTest.java @@ -21,7 +21,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static com.google.javascript.jscomp.CompilerTestCase.lines; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.jscomp.ExpressionDecomposer.DecompositionType; diff --git a/test/com/google/javascript/jscomp/FunctionArgumentInjectorTest.java b/test/com/google/javascript/jscomp/FunctionArgumentInjectorTest.java index 39a958db918..9abf48e318b 100644 --- a/test/com/google/javascript/jscomp/FunctionArgumentInjectorTest.java +++ b/test/com/google/javascript/jscomp/FunctionArgumentInjectorTest.java @@ -23,7 +23,7 @@ import static com.google.javascript.jscomp.FunctionArgumentInjector.inject; import static com.google.javascript.jscomp.FunctionArgumentInjector.maybeAddTempsForCallArguments; import static com.google.javascript.jscomp.NodeUtil.getFunctionBody; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; diff --git a/test/com/google/javascript/jscomp/IntegrationTest.java b/test/com/google/javascript/jscomp/IntegrationTest.java index 4a5ae5c233f..e74078ea291 100644 --- a/test/com/google/javascript/jscomp/IntegrationTest.java +++ b/test/com/google/javascript/jscomp/IntegrationTest.java @@ -31,9 +31,9 @@ import com.google.javascript.jscomp.CompilerOptions.PropertyCollapseLevel; import com.google.javascript.jscomp.CompilerOptions.Reach; import com.google.javascript.jscomp.CompilerTestCase.NoninjectingCompiler; -import com.google.javascript.jscomp.testing.NodeSubject; import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Token; +import com.google.javascript.rhino.testing.NodeSubject; /** * Integration tests for the compiler. diff --git a/test/com/google/javascript/jscomp/NodeTraversalTest.java b/test/com/google/javascript/jscomp/NodeTraversalTest.java index abf9eb53bb0..6815cd36aa4 100644 --- a/test/com/google/javascript/jscomp/NodeTraversalTest.java +++ b/test/com/google/javascript/jscomp/NodeTraversalTest.java @@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.javascript.jscomp.CompilerTestCase.lines; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; diff --git a/test/com/google/javascript/jscomp/NodeUtilTest.java b/test/com/google/javascript/jscomp/NodeUtilTest.java index 0382a4e8e81..c9e40f3da14 100644 --- a/test/com/google/javascript/jscomp/NodeUtilTest.java +++ b/test/com/google/javascript/jscomp/NodeUtilTest.java @@ -22,7 +22,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static com.google.javascript.jscomp.DiagnosticGroups.ES5_STRICT; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.base.Joiner; import com.google.common.base.Predicates; diff --git a/test/com/google/javascript/jscomp/PolymerClassDefinitionTest.java b/test/com/google/javascript/jscomp/PolymerClassDefinitionTest.java index ce65e6fa33e..16c168af9c5 100644 --- a/test/com/google/javascript/jscomp/PolymerClassDefinitionTest.java +++ b/test/com/google/javascript/jscomp/PolymerClassDefinitionTest.java @@ -16,7 +16,7 @@ package com.google.javascript.jscomp; import static com.google.common.truth.Truth.assertThat; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Token; diff --git a/test/com/google/javascript/jscomp/PolymerClassRewriterTest.java b/test/com/google/javascript/jscomp/PolymerClassRewriterTest.java index 9f23ddcd3ce..784d19b4683 100644 --- a/test/com/google/javascript/jscomp/PolymerClassRewriterTest.java +++ b/test/com/google/javascript/jscomp/PolymerClassRewriterTest.java @@ -15,7 +15,7 @@ */ package com.google.javascript.jscomp; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.rhino.Node; diff --git a/test/com/google/javascript/jscomp/PolymerPassTest.java b/test/com/google/javascript/jscomp/PolymerPassTest.java index 7fda89bd745..c7f982fce6a 100644 --- a/test/com/google/javascript/jscomp/PolymerPassTest.java +++ b/test/com/google/javascript/jscomp/PolymerPassTest.java @@ -28,7 +28,7 @@ import static com.google.javascript.jscomp.PolymerPassErrors.POLYMER_UNEXPECTED_PARAMS; import static com.google.javascript.jscomp.PolymerPassErrors.POLYMER_UNQUALIFIED_BEHAVIOR; import static com.google.javascript.jscomp.TypeValidator.TYPE_MISMATCH_WARNING; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.jscomp.NodeUtil.Visitor; diff --git a/test/com/google/javascript/jscomp/ReferenceCollectingCallbackTest.java b/test/com/google/javascript/jscomp/ReferenceCollectingCallbackTest.java index df8fc186fcf..c13dc172f31 100644 --- a/test/com/google/javascript/jscomp/ReferenceCollectingCallbackTest.java +++ b/test/com/google/javascript/jscomp/ReferenceCollectingCallbackTest.java @@ -20,7 +20,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT_NEXT; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.collect.Iterables; import com.google.javascript.jscomp.ReferenceCollectingCallback.Behavior; diff --git a/test/com/google/javascript/jscomp/ScopeSubject.java b/test/com/google/javascript/jscomp/ScopeSubject.java index 0f249aced67..dbfc4123ecd 100644 --- a/test/com/google/javascript/jscomp/ScopeSubject.java +++ b/test/com/google/javascript/jscomp/ScopeSubject.java @@ -19,13 +19,14 @@ import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.truth.Truth.assertAbout; +import static com.google.javascript.rhino.testing.TypeSubject.assertType; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.truth.FailureMetadata; import com.google.common.truth.Subject; -import com.google.javascript.jscomp.testing.TypeSubject; import com.google.javascript.rhino.Node; +import com.google.javascript.rhino.testing.TypeSubject; import javax.annotation.CheckReturnValue; import javax.annotation.Nullable; @@ -170,7 +171,7 @@ public DeclarationSubject onScopeLabeled(String expectedLabel) { public TypeSubject withTypeThat() { TypedVar typedVar = (TypedVar) var.getSymbol(); - return TypeSubject.assertType(typedVar.getType()); + return assertType(typedVar.getType()); } } diff --git a/test/com/google/javascript/jscomp/SimpleReplaceScriptTest.java b/test/com/google/javascript/jscomp/SimpleReplaceScriptTest.java index 9f5b8ac98b8..8ef90f45e17 100644 --- a/test/com/google/javascript/jscomp/SimpleReplaceScriptTest.java +++ b/test/com/google/javascript/jscomp/SimpleReplaceScriptTest.java @@ -17,7 +17,7 @@ package com.google.javascript.jscomp; import static com.google.common.truth.Truth.assertThat; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; diff --git a/test/com/google/javascript/jscomp/TypeInferenceTest.java b/test/com/google/javascript/jscomp/TypeInferenceTest.java index 329874fd65e..7a98fdf3721 100644 --- a/test/com/google/javascript/jscomp/TypeInferenceTest.java +++ b/test/com/google/javascript/jscomp/TypeInferenceTest.java @@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.google.javascript.jscomp.CompilerTypeTestCase.lines; import static com.google.javascript.jscomp.ScopeSubject.assertScope; -import static com.google.javascript.jscomp.testing.TypeSubject.assertType; import static com.google.javascript.rhino.jstype.JSTypeNative.ALL_TYPE; import static com.google.javascript.rhino.jstype.JSTypeNative.ARRAY_TYPE; import static com.google.javascript.rhino.jstype.JSTypeNative.BOOLEAN_TYPE; @@ -36,13 +35,13 @@ import static com.google.javascript.rhino.jstype.JSTypeNative.STRING_TYPE; import static com.google.javascript.rhino.jstype.JSTypeNative.UNKNOWN_TYPE; import static com.google.javascript.rhino.jstype.JSTypeNative.VOID_TYPE; +import static com.google.javascript.rhino.testing.TypeSubject.assertType; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.javascript.jscomp.CodingConvention.AssertionFunctionSpec; import com.google.javascript.jscomp.DataFlowAnalysis.BranchedFlowState; import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; -import com.google.javascript.jscomp.testing.TypeSubject; import com.google.javascript.jscomp.type.FlowScope; import com.google.javascript.jscomp.type.ReverseAbstractInterpreter; import com.google.javascript.rhino.Node; @@ -53,6 +52,7 @@ import com.google.javascript.rhino.jstype.ObjectType; import com.google.javascript.rhino.jstype.StaticTypedSlot; import com.google.javascript.rhino.testing.Asserts; +import com.google.javascript.rhino.testing.TypeSubject; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; diff --git a/test/com/google/javascript/jscomp/TypedScopeCreatorTest.java b/test/com/google/javascript/jscomp/TypedScopeCreatorTest.java index be9a3c1ed2c..73fb54c298b 100644 --- a/test/com/google/javascript/jscomp/TypedScopeCreatorTest.java +++ b/test/com/google/javascript/jscomp/TypedScopeCreatorTest.java @@ -23,12 +23,12 @@ import static com.google.javascript.jscomp.ScopeSubject.assertScope; import static com.google.javascript.jscomp.TypedScopeCreator.CTOR_INITIALIZER; import static com.google.javascript.jscomp.TypedScopeCreator.IFACE_INITIALIZER; -import static com.google.javascript.jscomp.testing.TypeSubject.assertType; import static com.google.javascript.rhino.jstype.JSTypeNative.BOOLEAN_TYPE; import static com.google.javascript.rhino.jstype.JSTypeNative.NUMBER_TYPE; import static com.google.javascript.rhino.jstype.JSTypeNative.OBJECT_TYPE; import static com.google.javascript.rhino.jstype.JSTypeNative.STRING_TYPE; import static com.google.javascript.rhino.jstype.JSTypeNative.UNKNOWN_TYPE; +import static com.google.javascript.rhino.testing.TypeSubject.assertType; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; diff --git a/test/com/google/javascript/jscomp/parsing/JsDocInfoParserTest.java b/test/com/google/javascript/jscomp/parsing/JsDocInfoParserTest.java index 1525cb703c2..888de286e76 100644 --- a/test/com/google/javascript/jscomp/parsing/JsDocInfoParserTest.java +++ b/test/com/google/javascript/jscomp/parsing/JsDocInfoParserTest.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkState; import static com.google.common.truth.Truth.assertThat; import static com.google.javascript.jscomp.parsing.JsDocInfoParser.BAD_TYPE_WIKI_LINK; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; diff --git a/test/com/google/javascript/jscomp/parsing/ParserTest.java b/test/com/google/javascript/jscomp/parsing/ParserTest.java index 7023b5e2658..13ac4551bbc 100644 --- a/test/com/google/javascript/jscomp/parsing/ParserTest.java +++ b/test/com/google/javascript/jscomp/parsing/ParserTest.java @@ -22,7 +22,7 @@ import static com.google.javascript.jscomp.parsing.Config.StrictMode.STRICT; import static com.google.javascript.jscomp.parsing.JsDocInfoParser.BAD_TYPE_WIKI_LINK; import static com.google.javascript.jscomp.parsing.parser.testing.FeatureSetSubject.assertFS; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; diff --git a/test/com/google/javascript/jscomp/parsing/TypeSyntaxTest.java b/test/com/google/javascript/jscomp/parsing/TypeSyntaxTest.java index b1ebfabfd25..d1a5465732d 100644 --- a/test/com/google/javascript/jscomp/parsing/TypeSyntaxTest.java +++ b/test/com/google/javascript/jscomp/parsing/TypeSyntaxTest.java @@ -17,7 +17,6 @@ package com.google.javascript.jscomp.parsing; import static com.google.common.truth.Truth.assertThat; -import static com.google.javascript.jscomp.testing.NodeSubject.assertNode; import static com.google.javascript.rhino.TypeDeclarationsIR.anyType; import static com.google.javascript.rhino.TypeDeclarationsIR.arrayType; import static com.google.javascript.rhino.TypeDeclarationsIR.booleanType; @@ -26,6 +25,7 @@ import static com.google.javascript.rhino.TypeDeclarationsIR.parameterizedType; import static com.google.javascript.rhino.TypeDeclarationsIR.stringType; import static com.google.javascript.rhino.TypeDeclarationsIR.voidType; +import static com.google.javascript.rhino.testing.NodeSubject.assertNode; import com.google.common.collect.ImmutableList; import com.google.javascript.jscomp.CodePrinter;