本文整理汇总了Java中com.google.javascript.rhino.testing.Asserts类的典型用法代码示例。如果您正苦于以下问题:Java Asserts类的具体用法?Java Asserts怎么用?Java Asserts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Asserts类属于com.google.javascript.rhino.testing包,在下文中一共展示了Asserts类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testGoogBar
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the goog.Bar type.
*/
public void testGoogBar() throws Exception {
assertTrue(namedGoogBar.isInstanceType());
assertFalse(googBar.isInstanceType());
assertFalse(namedGoogBar.isConstructor());
assertTrue(googBar.isConstructor());
assertTrue(googBar.getInstanceType().isInstanceType());
assertTrue(namedGoogBar.getConstructor().isConstructor());
assertTrue(namedGoogBar.getImplicitPrototype().isFunctionPrototypeType());
// canAssignTo
assertTypeCanAssignToItself(googBar);
assertTypeCanAssignToItself(namedGoogBar);
googBar.canAssignTo(namedGoogBar);
namedGoogBar.canAssignTo(googBar);
assertTrue(googBar.equals(googBar));
assertFalse(googBar.equals(googSubBar));
Asserts.assertResolvesToSame(googBar);
Asserts.assertResolvesToSame(googSubBar);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:24,代码来源:JSTypeTest.java
示例2: testGoogBar
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the goog.Bar type.
*/
public void testGoogBar() throws Exception {
assertTrue(namedGoogBar.isInstanceType());
assertFalse(googBar.isInstanceType());
assertFalse(namedGoogBar.isConstructor());
assertTrue(googBar.isConstructor());
assertTrue(googBar.getInstanceType().isInstanceType());
assertTrue(namedGoogBar.getConstructor().isConstructor());
assertTrue(namedGoogBar.getImplicitPrototype().isFunctionPrototypeType());
// canAssignTo
assertTypeCanAssignToItself(googBar);
assertTypeCanAssignToItself(namedGoogBar);
googBar.canAssignTo(namedGoogBar);
namedGoogBar.canAssignTo(googBar);
assertTrue(googBar.isEquivalentTo(googBar));
assertFalse(googBar.isEquivalentTo(googSubBar));
Asserts.assertResolvesToSame(googBar);
Asserts.assertResolvesToSame(googSubBar);
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:24,代码来源:JSTypeTest.java
示例3: testCheckedUnknownType
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the behavior of the checked unknown type.
*/
public void testCheckedUnknownType() throws Exception {
// isPropertyType*
assertPropertyTypeUnknown(CHECKED_UNKNOWN_TYPE, "XXX");
// toString
assertEquals("??", CHECKED_UNKNOWN_TYPE.toString());
assertTrue(CHECKED_UNKNOWN_TYPE.hasDisplayName());
assertEquals("Unknown", CHECKED_UNKNOWN_TYPE.getDisplayName());
Asserts.assertResolvesToSame(CHECKED_UNKNOWN_TYPE);
assertFalse(CHECKED_UNKNOWN_TYPE.isNominalConstructor());
assertEquals(CHECKED_UNKNOWN_TYPE,
CHECKED_UNKNOWN_TYPE.getPropertyType("abc"));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:JSTypeTest.java
示例4: testGoogBar
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the goog.Bar type.
*/
public void testGoogBar() throws Exception {
assertTrue(namedGoogBar.isInstanceType());
assertFalse(googBar.isInstanceType());
assertFalse(namedGoogBar.isConstructor());
assertTrue(googBar.isConstructor());
assertTrue(googBar.getInstanceType().isInstanceType());
assertTrue(namedGoogBar.getConstructor().isConstructor());
assertTrue(namedGoogBar.getImplicitPrototype().isFunctionPrototypeType());
// isSubtype
assertTypeCanAssignToItself(googBar);
assertTypeCanAssignToItself(namedGoogBar);
googBar.isSubtype(namedGoogBar);
namedGoogBar.isSubtype(googBar);
assertTypeEquals(googBar, googBar);
assertTypeNotEquals(googBar, googSubBar);
Asserts.assertResolvesToSame(googBar);
Asserts.assertResolvesToSame(googSubBar);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:24,代码来源:JSTypeTest.java
示例5: testRecursiveRecord
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testRecursiveRecord() {
ProxyObjectType loop = new ProxyObjectType(registry, NUMBER_TYPE);
JSType record = new RecordTypeBuilder(registry)
.addProperty("loop", loop, null)
.addProperty("number", NUMBER_TYPE, null)
.addProperty("string", STRING_TYPE, null)
.build();
assertEquals("{loop: number, number: number, string: string}",
record.toString());
loop.setReferencedType(record);
assertEquals("{loop: {...}, number: number, string: string}",
record.toString());
assertEquals("{loop: ?, number: number, string: string}",
record.toAnnotationString());
Asserts.assertEquivalenceOperations(record, loop);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:RecordTypeTest.java
示例6: testIsEquivalentToParams
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testIsEquivalentToParams() {
FunctionType oneNum = new FunctionBuilder(registry)
.withParamsNode(registry.createParameters(NUMBER_TYPE))
.build();
FunctionType optNum = new FunctionBuilder(registry)
.withParamsNode(registry.createOptionalParameters(NUMBER_TYPE))
.build();
FunctionType varNum = new FunctionBuilder(registry)
.withParamsNode(registry.createParametersWithVarArgs(NUMBER_TYPE))
.build();
Asserts.assertEquivalenceOperations(oneNum, oneNum);
Asserts.assertEquivalenceOperations(optNum, optNum);
Asserts.assertEquivalenceOperations(varNum, varNum);
assertFalse(oneNum.isEquivalentTo(optNum));
assertFalse(oneNum.isEquivalentTo(varNum));
assertFalse(optNum.isEquivalentTo(varNum));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:FunctionTypeTest.java
示例7: testNamespacedFunctionStubLocal
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testNamespacedFunctionStubLocal() {
testSame(
"(function() {" +
"var goog = {};" +
"/** @param {number} x */ goog.foo;" +
"});");
ObjectType goog = (ObjectType) findNameType("goog", lastLocalScope);
assertTrue(goog.hasProperty("foo"));
assertEquals("function (number): ?",
goog.getPropertyType("foo").toString());
assertTrue(goog.isPropertyTypeDeclared("foo"));
Asserts.assertTypeEquals(lastLocalScope.getVar("goog.foo").getType(),
goog.getPropertyType("foo"));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:TypedScopeCreatorTest.java
示例8: testPropertiesOnInterface
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testPropertiesOnInterface() throws Exception {
testSame("/** @interface */ var I = function() {};" +
"/** @type {number} */ I.prototype.bar;" +
"I.prototype.baz = function(){};");
Var i = globalScope.getVar("I");
assertEquals("function (this:I): ?", i.getType().toString());
assertTrue(i.getType().isInterface());
ObjectType iPrototype = (ObjectType)
((ObjectType) i.getType()).getPropertyType("prototype");
assertEquals("I.prototype", iPrototype.toString());
assertTrue(iPrototype.isFunctionPrototypeType());
assertEquals("number", iPrototype.getPropertyType("bar").toString());
assertEquals("function (this:I): undefined",
iPrototype.getPropertyType("baz").toString());
Asserts.assertTypeEquals(iPrototype, globalScope.getVar("I.prototype").getType());
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:TypedScopeCreatorTest.java
示例9: testRecursiveRecord
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testRecursiveRecord() {
ProxyObjectType loop = new ProxyObjectType(registry, NUMBER_TYPE);
JSType record = new RecordTypeBuilder(registry)
.addProperty("loop", loop, null)
.addProperty("number", NUMBER_TYPE, null)
.addProperty("string", STRING_TYPE, null)
.build();
assertEquals("{\n loop: number,\n number: number,\n string: string\n}",
record.toString());
loop.setReferencedType(record);
assertEquals("{\n loop: {...},\n number: number,\n string: string\n}",
record.toString());
assertEquals("{loop: ?, number: number, string: string}",
record.toAnnotationString(Nullability.EXPLICIT));
Asserts.assertEquivalenceOperations(record, loop);
}
开发者ID:google,项目名称:closure-compiler,代码行数:19,代码来源:RecordTypeTest.java
示例10: testNamespacedFunctionStubLocal
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testNamespacedFunctionStubLocal() {
testSame(
"(function() {" +
"var goog = {};" +
"/** @param {number} x */ goog.foo;" +
"});");
ObjectType goog = (ObjectType) findNameType("goog", lastLocalScope);
assertTrue(goog.hasProperty("foo"));
assertEquals("function(number): ?",
goog.getPropertyType("foo").toString());
assertTrue(goog.isPropertyTypeDeclared("foo"));
Asserts.assertTypeEquals(lastLocalScope.getVar("goog.foo").getType(),
goog.getPropertyType("foo"));
}
开发者ID:google,项目名称:closure-compiler,代码行数:17,代码来源:TypedScopeCreatorTest.java
示例11: testPropertiesOnInterface
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testPropertiesOnInterface() throws Exception {
testSame("/** @interface */ var I = function() {};" +
"/** @type {number} */ I.prototype.bar;" +
"I.prototype.baz = function(){};");
TypedVar i = globalScope.getVar("I");
assertEquals("function(this:I): ?", i.getType().toString());
assertTrue(i.getType().isInterface());
ObjectType iPrototype = (ObjectType)
((ObjectType) i.getType()).getPropertyType("prototype");
assertEquals("I.prototype", iPrototype.toString());
assertTrue(iPrototype.isFunctionPrototypeType());
assertEquals("number", iPrototype.getPropertyType("bar").toString());
assertEquals("function(this:I): undefined",
iPrototype.getPropertyType("baz").toString());
Asserts.assertTypeEquals(iPrototype, globalScope.getVar("I.prototype").getType());
}
开发者ID:google,项目名称:closure-compiler,代码行数:21,代码来源:TypedScopeCreatorTest.java
示例12: testStringEnumType
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testStringEnumType() throws Exception {
EnumElementType stringEnum =
new EnumType(registry, "Enum", STRING_TYPE).getElementsType();
assertEquals(UNKNOWN_TYPE, stringEnum.getPropertyType("length"));
assertEquals(NUMBER_TYPE, stringEnum.findPropertyType("length"));
assertEquals(false, stringEnum.hasProperty("length"));
assertEquals(STRING_OBJECT_TYPE, stringEnum.autoboxesTo());
assertNull(stringEnum.getConstructor());
Asserts.assertResolvesToSame(stringEnum);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:13,代码来源:JSTypeTest.java
示例13: testNamedGoogBar
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the named type goog.Bar.
*/
public void testNamedGoogBar() throws Exception {
// isXxx
assertFalse(namedGoogBar.isFunctionPrototypeType());
assertTrue(namedGoogBar.getImplicitPrototype().isFunctionPrototypeType());
// canAssignTo
assertTrue(namedGoogBar.canAssignTo(ALL_TYPE));
assertFalse(namedGoogBar.canAssignTo(STRING_OBJECT_TYPE));
assertFalse(namedGoogBar.canAssignTo(NUMBER_TYPE));
assertFalse(namedGoogBar.canAssignTo(functionType));
assertFalse(namedGoogBar.canAssignTo(NULL_TYPE));
assertTrue(namedGoogBar.canAssignTo(OBJECT_TYPE));
assertFalse(namedGoogBar.canAssignTo(DATE_TYPE));
assertTrue(namedGoogBar.canAssignTo(namedGoogBar));
assertTrue(namedGoogBar.canAssignTo(unresolvedNamedType));
assertFalse(namedGoogBar.canAssignTo(REGEXP_TYPE));
assertFalse(namedGoogBar.canAssignTo(ARRAY_TYPE));
// autoboxesTo
assertNull(namedGoogBar.autoboxesTo());
// properties
assertEquals(DATE_TYPE, namedGoogBar.getPropertyType("date"));
assertFalse(namedGoogBar.isNativeObjectType());
assertFalse(namedGoogBar.getImplicitPrototype().isNativeObjectType());
JSType resolvedNamedGoogBar = Asserts.assertValidResolve(namedGoogBar);
assertNotSame(resolvedNamedGoogBar, namedGoogBar);
assertSame(resolvedNamedGoogBar, googBar.getInstanceType());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:35,代码来源:JSTypeTest.java
示例14: testNamedTypeEquals2
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the {@link NamedType#equals} function against other types.
*/
public void testNamedTypeEquals2() {
// test == if references are equal
NamedType a = new NamedType(registry, "typeA", "source", 1, 0);
NamedType b = new NamedType(registry, "typeB", "source", 1, 0);
ObjectType realA = registry.createConstructorType(
"typeA", null, null, null).getInstanceType();
ObjectType realB = registry.createEnumType(
"typeB", NUMBER_TYPE).getElementsType();
registry.declareType("typeA", realA);
registry.declareType("typeB", realB);
assertEquals(a.hashCode(), realA.hashCode());
assertEquals(a, realA);
assertEquals(b.hashCode(), realB.hashCode());
assertEquals(b, realB);
a.resolve(null, null);
b.resolve(null, null);
assertTrue(a.isResolved());
assertTrue(b.isResolved());
assertEquals(a.hashCode(), realA.hashCode());
assertEquals(a, realA);
assertEquals(b.hashCode(), realB.hashCode());
assertEquals(b, realB);
JSType resolvedA = Asserts.assertValidResolve(a);
assertNotSame(resolvedA, a);
assertSame(resolvedA, realA);
JSType resolvedB = Asserts.assertValidResolve(b);
assertNotSame(resolvedB, b);
assertSame(resolvedB, realB);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:39,代码来源:JSTypeTest.java
示例15: testStringEnumType
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testStringEnumType() throws Exception {
EnumElementType stringEnum =
new EnumType(registry, "Enum", STRING_TYPE).getElementsType();
assertTypeEquals(UNKNOWN_TYPE, stringEnum.getPropertyType("length"));
assertTypeEquals(NUMBER_TYPE, stringEnum.findPropertyType("length"));
assertEquals(false, stringEnum.hasProperty("length"));
assertTypeEquals(STRING_OBJECT_TYPE, stringEnum.autoboxesTo());
assertNull(stringEnum.getConstructor());
Asserts.assertResolvesToSame(stringEnum);
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:13,代码来源:JSTypeTest.java
示例16: testNamedGoogBar
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the named type goog.Bar.
*/
public void testNamedGoogBar() throws Exception {
// isXxx
assertFalse(namedGoogBar.isFunctionPrototypeType());
assertTrue(namedGoogBar.getImplicitPrototype().isFunctionPrototypeType());
// canAssignTo
assertTrue(namedGoogBar.canAssignTo(ALL_TYPE));
assertFalse(namedGoogBar.canAssignTo(STRING_OBJECT_TYPE));
assertFalse(namedGoogBar.canAssignTo(NUMBER_TYPE));
assertFalse(namedGoogBar.canAssignTo(functionType));
assertFalse(namedGoogBar.canAssignTo(NULL_TYPE));
assertTrue(namedGoogBar.canAssignTo(OBJECT_TYPE));
assertFalse(namedGoogBar.canAssignTo(DATE_TYPE));
assertTrue(namedGoogBar.canAssignTo(namedGoogBar));
assertTrue(namedGoogBar.canAssignTo(unresolvedNamedType));
assertFalse(namedGoogBar.canAssignTo(REGEXP_TYPE));
assertFalse(namedGoogBar.canAssignTo(ARRAY_TYPE));
// autoboxesTo
assertNull(namedGoogBar.autoboxesTo());
// properties
assertTypeEquals(DATE_TYPE, namedGoogBar.getPropertyType("date"));
assertFalse(namedGoogBar.isNativeObjectType());
assertFalse(namedGoogBar.getImplicitPrototype().isNativeObjectType());
JSType resolvedNamedGoogBar = Asserts.assertValidResolve(namedGoogBar);
assertNotSame(resolvedNamedGoogBar, namedGoogBar);
assertSame(resolvedNamedGoogBar, googBar.getInstanceType());
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:35,代码来源:JSTypeTest.java
示例17: testNamedTypeEquals2
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the {@link NamedType#equals} function against other types.
*/
public void testNamedTypeEquals2() {
// test == if references are equal
NamedType a = new NamedType(registry, "typeA", "source", 1, 0);
NamedType b = new NamedType(registry, "typeB", "source", 1, 0);
ObjectType realA = registry.createConstructorType(
"typeA", null, null, null).getInstanceType();
ObjectType realB = registry.createEnumType(
"typeB", NUMBER_TYPE).getElementsType();
registry.declareType("typeA", realA);
registry.declareType("typeB", realB);
assertEquals(a.hashCode(), realA.hashCode());
assertTypeEquals(a, realA);
assertEquals(b.hashCode(), realB.hashCode());
assertTypeEquals(b, realB);
a.resolve(null, null);
b.resolve(null, null);
assertTrue(a.isResolved());
assertTrue(b.isResolved());
assertEquals(a.hashCode(), realA.hashCode());
assertTypeEquals(a, realA);
assertEquals(b.hashCode(), realB.hashCode());
assertTypeEquals(b, realB);
JSType resolvedA = Asserts.assertValidResolve(a);
assertNotSame(resolvedA, a);
assertSame(resolvedA, realA);
JSType resolvedB = Asserts.assertValidResolve(b);
assertNotSame(resolvedB, b);
assertSame(resolvedB, realB);
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:39,代码来源:JSTypeTest.java
示例18: testStringEnumType
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
public void testStringEnumType() throws Exception {
EnumElementType stringEnum =
new EnumType(registry, "Enum", null, STRING_TYPE).getElementsType();
assertTypeEquals(UNKNOWN_TYPE, stringEnum.getPropertyType("length"));
assertTypeEquals(NUMBER_TYPE, stringEnum.findPropertyType("length"));
assertEquals(false, stringEnum.hasProperty("length"));
assertTypeEquals(STRING_OBJECT_TYPE, stringEnum.autoboxesTo());
assertNull(stringEnum.getConstructor());
Asserts.assertResolvesToSame(stringEnum);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:13,代码来源:JSTypeTest.java
示例19: testNamedGoogBar
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the named type goog.Bar.
*/
public void testNamedGoogBar() throws Exception {
// isXxx
assertFalse(namedGoogBar.isFunctionPrototypeType());
assertTrue(namedGoogBar.getImplicitPrototype().isFunctionPrototypeType());
// isSubtype
assertTrue(namedGoogBar.isSubtype(ALL_TYPE));
assertFalse(namedGoogBar.isSubtype(STRING_OBJECT_TYPE));
assertFalse(namedGoogBar.isSubtype(NUMBER_TYPE));
assertFalse(namedGoogBar.isSubtype(functionType));
assertFalse(namedGoogBar.isSubtype(NULL_TYPE));
assertTrue(namedGoogBar.isSubtype(OBJECT_TYPE));
assertFalse(namedGoogBar.isSubtype(DATE_TYPE));
assertTrue(namedGoogBar.isSubtype(namedGoogBar));
assertTrue(namedGoogBar.isSubtype(unresolvedNamedType));
assertFalse(namedGoogBar.isSubtype(REGEXP_TYPE));
assertFalse(namedGoogBar.isSubtype(ARRAY_TYPE));
// autoboxesTo
assertNull(namedGoogBar.autoboxesTo());
// properties
assertTypeEquals(DATE_TYPE, namedGoogBar.getPropertyType("date"));
assertFalse(namedGoogBar.isNativeObjectType());
assertFalse(namedGoogBar.getImplicitPrototype().isNativeObjectType());
JSType resolvedNamedGoogBar = Asserts.assertValidResolve(namedGoogBar);
assertNotSame(resolvedNamedGoogBar, namedGoogBar);
assertSame(resolvedNamedGoogBar, googBar.getInstanceType());
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:35,代码来源:JSTypeTest.java
示例20: testNamedTypeEquals2
import com.google.javascript.rhino.testing.Asserts; //导入依赖的package包/类
/**
* Tests the {@link NamedType#equals} function against other types.
*/
public void testNamedTypeEquals2() {
// test == if references are equal
NamedType a = new NamedType(registry, "typeA", "source", 1, 0);
NamedType b = new NamedType(registry, "typeB", "source", 1, 0);
ObjectType realA = registry.createConstructorType(
"typeA", null, null, null, null).getInstanceType();
ObjectType realB = registry.createEnumType(
"typeB", null, NUMBER_TYPE).getElementsType();
registry.declareType("typeA", realA);
registry.declareType("typeB", realB);
assertTypeEquals(a, realA);
assertTypeEquals(b, realB);
a.resolve(null, null);
b.resolve(null, null);
assertTrue(a.isResolved());
assertTrue(b.isResolved());
assertTypeEquals(a, realA);
assertTypeEquals(b, realB);
JSType resolvedA = Asserts.assertValidResolve(a);
assertNotSame(resolvedA, a);
assertSame(resolvedA, realA);
JSType resolvedB = Asserts.assertValidResolve(b);
assertNotSame(resolvedB, b);
assertSame(resolvedB, realB);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:35,代码来源:JSTypeTest.java
注:本文中的com.google.javascript.rhino.testing.Asserts类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论