当前位置: 首页>>代码示例>>Java>>正文


Java Asserts.assertResolvesToSame方法代码示例

本文整理汇总了Java中com.google.javascript.rhino.testing.Asserts.assertResolvesToSame方法的典型用法代码示例。如果您正苦于以下问题:Java Asserts.assertResolvesToSame方法的具体用法?Java Asserts.assertResolvesToSame怎么用?Java Asserts.assertResolvesToSame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.rhino.testing.Asserts的用法示例。


在下文中一共展示了Asserts.assertResolvesToSame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例6: 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

示例7: 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

示例8: testRecordType

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests the behavior of record types.
 */
public void testRecordType() throws Exception {
  // isXxx
  assertTrue(recordType.isObject());
  assertFalse(recordType.isFunctionPrototypeType());

  // canAssignTo
  assertTrue(recordType.canAssignTo(ALL_TYPE));
  assertFalse(recordType.canAssignTo(STRING_OBJECT_TYPE));
  assertFalse(recordType.canAssignTo(NUMBER_TYPE));
  assertFalse(recordType.canAssignTo(DATE_TYPE));
  assertFalse(recordType.canAssignTo(REGEXP_TYPE));
  assertTrue(recordType.canAssignTo(UNKNOWN_TYPE));
  assertTrue(recordType.canAssignTo(OBJECT_TYPE));
  assertFalse(recordType.canAssignTo(U2U_CONSTRUCTOR_TYPE));

  // autoboxesTo
  assertNull(recordType.autoboxesTo());

  // canBeCalled
  assertFalse(recordType.canBeCalled());

  // canTestForEqualityWith
  assertTrue(recordType.canTestForEqualityWith(ALL_TYPE));
  assertTrue(recordType.canTestForEqualityWith(STRING_OBJECT_TYPE));
  assertTrue(recordType.canTestForEqualityWith(recordType));
  assertTrue(recordType.canTestForEqualityWith(functionType));
  assertTrue(recordType.canTestForEqualityWith(OBJECT_TYPE));
  assertTrue(recordType.canTestForEqualityWith(NUMBER_TYPE));
  assertTrue(recordType.canTestForEqualityWith(DATE_TYPE));
  assertTrue(recordType.canTestForEqualityWith(REGEXP_TYPE));

  // canTestForShallowEqualityWith
  assertTrue(recordType.canTestForShallowEqualityWith(NO_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(NO_OBJECT_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(ARRAY_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(BOOLEAN_TYPE));
  assertFalse(recordType.
      canTestForShallowEqualityWith(BOOLEAN_OBJECT_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(DATE_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(ERROR_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(EVAL_ERROR_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(recordType));
  assertFalse(recordType.canTestForShallowEqualityWith(NULL_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(NUMBER_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(NUMBER_OBJECT_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(OBJECT_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(URI_ERROR_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(RANGE_ERROR_TYPE));
  assertFalse(recordType.
      canTestForShallowEqualityWith(REFERENCE_ERROR_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(REGEXP_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(STRING_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(STRING_OBJECT_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(SYNTAX_ERROR_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(TYPE_ERROR_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(ALL_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(VOID_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(UNKNOWN_TYPE));

  // matchesXxx
  assertFalse(recordType.matchesInt32Context());
  assertFalse(recordType.matchesNumberContext());
  assertTrue(recordType.matchesObjectContext());
  assertFalse(recordType.matchesStringContext());
  assertFalse(recordType.matchesUint32Context());

  Asserts.assertResolvesToSame(recordType);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:72,代码来源:JSTypeTest.java

示例9: testFunctionType

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests the behavior of functional types.
 */
public void testFunctionType() throws Exception {
  // isXxx
  assertTrue(functionType.isObject());
  assertFalse(functionType.isFunctionPrototypeType());
  assertTrue(functionType.getImplicitPrototype().getImplicitPrototype()
      .isFunctionPrototypeType());

  // canAssignTo
  assertTrue(functionType.canAssignTo(ALL_TYPE));
  assertFalse(functionType.canAssignTo(STRING_OBJECT_TYPE));
  assertFalse(functionType.canAssignTo(NUMBER_TYPE));
  assertFalse(functionType.canAssignTo(DATE_TYPE));
  assertFalse(functionType.canAssignTo(REGEXP_TYPE));
  assertTrue(functionType.canAssignTo(UNKNOWN_TYPE));
  assertTrue(functionType.canAssignTo(U2U_CONSTRUCTOR_TYPE));

  // autoboxesTo
  assertNull(functionType.autoboxesTo());

  // canBeCalled
  assertTrue(functionType.canBeCalled());

  // canTestForEqualityWith
  assertTrue(functionType.canTestForEqualityWith(ALL_TYPE));
  assertTrue(functionType.canTestForEqualityWith(STRING_OBJECT_TYPE));
  assertTrue(functionType.canTestForEqualityWith(functionType));
  assertTrue(functionType.canTestForEqualityWith(OBJECT_TYPE));
  assertTrue(functionType.canTestForEqualityWith(NUMBER_TYPE));
  assertTrue(functionType.canTestForEqualityWith(DATE_TYPE));
  assertTrue(functionType.canTestForEqualityWith(REGEXP_TYPE));

  // canTestForShallowEqualityWith
  assertTrue(functionType.canTestForShallowEqualityWith(NO_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(NO_OBJECT_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(ARRAY_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(BOOLEAN_TYPE));
  assertFalse(functionType.
      canTestForShallowEqualityWith(BOOLEAN_OBJECT_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(DATE_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(ERROR_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(EVAL_ERROR_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(functionType));
  assertFalse(functionType.canTestForShallowEqualityWith(NULL_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(NUMBER_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(NUMBER_OBJECT_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(OBJECT_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(URI_ERROR_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(RANGE_ERROR_TYPE));
  assertFalse(functionType.
      canTestForShallowEqualityWith(REFERENCE_ERROR_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(REGEXP_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(STRING_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(STRING_OBJECT_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(SYNTAX_ERROR_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(TYPE_ERROR_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(ALL_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(VOID_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(UNKNOWN_TYPE));

  // matchesXxx
  assertFalse(functionType.matchesInt32Context());
  assertFalse(functionType.matchesNumberContext());
  assertTrue(functionType.matchesObjectContext());
  assertFalse(functionType.matchesStringContext());
  assertFalse(functionType.matchesUint32Context());

  // hasProperty
  assertTrue(functionType.hasProperty("prototype"));
  assertPropertyTypeInferred(functionType, "prototype");

  Asserts.assertResolvesToSame(functionType);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:76,代码来源:JSTypeTest.java

示例10: testVoidType

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests the behavior of the void type.
 */
public void testVoidType() throws Exception {
  // canAssignTo
  assertTrue(VOID_TYPE.canAssignTo(ALL_TYPE));
  assertFalse(VOID_TYPE.canAssignTo(STRING_OBJECT_TYPE));
  assertFalse(VOID_TYPE.canAssignTo(REGEXP_TYPE));

  // autoboxesTo
  assertNull(VOID_TYPE.autoboxesTo());

  // canTestForEqualityWith
  assertTrue(VOID_TYPE.canTestForEqualityWith(ALL_TYPE));
  assertFalse(VOID_TYPE.canTestForEqualityWith(REGEXP_TYPE));

  // canTestForShallowEqualityWith
  assertTrue(VOID_TYPE.canTestForShallowEqualityWith(NO_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(NO_OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(ARRAY_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(BOOLEAN_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(BOOLEAN_OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(DATE_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(EVAL_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(functionType));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(NULL_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(NUMBER_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(NUMBER_OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(URI_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(RANGE_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(REFERENCE_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(REGEXP_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(STRING_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(STRING_OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(SYNTAX_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(TYPE_ERROR_TYPE));
  assertTrue(VOID_TYPE.canTestForShallowEqualityWith(ALL_TYPE));
  assertTrue(VOID_TYPE.canTestForShallowEqualityWith(VOID_TYPE));
  assertTrue(VOID_TYPE.canTestForShallowEqualityWith(
          createUnionType(NUMBER_TYPE, VOID_TYPE)));

  // matchesXxx
  assertFalse(VOID_TYPE.matchesInt32Context());
  assertFalse(VOID_TYPE.matchesNumberContext());
  assertFalse(VOID_TYPE.matchesObjectContext());
  assertTrue(VOID_TYPE.matchesStringContext());
  assertFalse(VOID_TYPE.matchesUint32Context());

  Asserts.assertResolvesToSame(VOID_TYPE);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:53,代码来源:JSTypeTest.java

示例11: testObjectType

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests object types.
 */
public void testObjectType() throws Exception {
  PrototypeObjectType objectType =
      new PrototypeObjectType(registry, null, null);

  // isXxx
  assertFalse(objectType.isAllType());
  assertFalse(objectType.isArrayType());
  assertFalse(objectType.isDateType());
  assertFalse(objectType.isFunctionPrototypeType());
  assertTrue(objectType.getImplicitPrototype() == OBJECT_TYPE);

  // canAssignTo
  assertTrue(objectType.canAssignTo(ALL_TYPE));
  assertFalse(objectType.canAssignTo(STRING_OBJECT_TYPE));
  assertFalse(objectType.canAssignTo(NUMBER_TYPE));
  assertFalse(objectType.canAssignTo(functionType));
  assertFalse(objectType.canAssignTo(NULL_TYPE));
  assertFalse(objectType.canAssignTo(DATE_TYPE));
  assertTrue(objectType.canAssignTo(OBJECT_TYPE));
  assertTrue(objectType.canAssignTo(unresolvedNamedType));
  assertFalse(objectType.canAssignTo(namedGoogBar));
  assertFalse(objectType.canAssignTo(REGEXP_TYPE));

  // autoboxesTo
  assertNull(objectType.autoboxesTo());

  // canTestForEqualityWith
  assertTrue(objectType.canTestForEqualityWith(NUMBER_TYPE));

  // matchesXxxContext
  assertFalse(objectType.matchesInt32Context());
  assertFalse(objectType.matchesNumberContext());
  assertTrue(objectType.matchesObjectContext());
  assertFalse(objectType.matchesStringContext());
  assertFalse(objectType.matchesUint32Context());

  // isNullable
  assertFalse(objectType.isNullable());
  assertTrue(createNullableType(objectType).isNullable());

  // toString
  assertEquals("{...}", objectType.toString());

  Asserts.assertResolvesToSame(objectType);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:49,代码来源:JSTypeTest.java

示例12: testUnionType

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests the behavior of variants type.
 */
@SuppressWarnings("checked")
    public void testUnionType() throws Exception {
  UnionType nullOrString =
      (UnionType) createUnionType(NULL_TYPE, STRING_OBJECT_TYPE);
  UnionType stringOrNull =
      (UnionType) createUnionType(STRING_OBJECT_TYPE, NULL_TYPE);

  assertEquals(nullOrString, stringOrNull);
  assertEquals(stringOrNull, nullOrString);

  assertTypeCanAssignToItself(createUnionType(VOID_TYPE, NUMBER_TYPE));
  assertTypeCanAssignToItself(
      createUnionType(NUMBER_TYPE, STRING_TYPE, OBJECT_TYPE));
  assertTypeCanAssignToItself(createUnionType(NUMBER_TYPE, BOOLEAN_TYPE));
  assertTypeCanAssignToItself(createUnionType(VOID_TYPE));

  UnionType nullOrUnknown =
      (UnionType) createUnionType(NULL_TYPE, unresolvedNamedType);
  assertTrue(nullOrUnknown.isUnknownType());
  assertEquals(nullOrUnknown, NULL_TYPE.getLeastSupertype(nullOrUnknown));
  assertEquals(nullOrUnknown, nullOrUnknown.getLeastSupertype(NULL_TYPE));
  assertEquals(UNKNOWN_TYPE,
      NULL_TYPE.getGreatestSubtype(nullOrUnknown));
  assertEquals(UNKNOWN_TYPE,
      nullOrUnknown.getGreatestSubtype(NULL_TYPE));

  assertTrue(NULL_TYPE.differsFrom(nullOrUnknown));
  assertTrue(nullOrUnknown.differsFrom(NULL_TYPE));
  assertFalse(nullOrUnknown.differsFrom(unresolvedNamedType));

  assertTrue(NULL_TYPE.isSubtype(nullOrUnknown));
  assertTrue(unresolvedNamedType.isSubtype(nullOrUnknown));
  assertTrue(nullOrUnknown.isSubtype(NULL_TYPE));

  assertEquals(unresolvedNamedType,
      nullOrUnknown.restrictByNotNullOrUndefined());

  // findPropertyType
  assertEquals(NUMBER_TYPE, nullOrString.findPropertyType("length"));
  assertEquals(null, nullOrString.findPropertyType("lengthx"));

  Asserts.assertResolvesToSame(nullOrString);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:47,代码来源:UnionTypeTest.java

示例13: testRecordType

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests the behavior of record types.
 */
public void testRecordType() throws Exception {
  // isXxx
  assertTrue(recordType.isObject());
  assertFalse(recordType.isFunctionPrototypeType());

  // isSubtype
  assertTrue(recordType.isSubtype(ALL_TYPE));
  assertFalse(recordType.isSubtype(STRING_OBJECT_TYPE));
  assertFalse(recordType.isSubtype(NUMBER_TYPE));
  assertFalse(recordType.isSubtype(DATE_TYPE));
  assertFalse(recordType.isSubtype(REGEXP_TYPE));
  assertTrue(recordType.isSubtype(UNKNOWN_TYPE));
  assertTrue(recordType.isSubtype(OBJECT_TYPE));
  assertFalse(recordType.isSubtype(U2U_CONSTRUCTOR_TYPE));

  // autoboxesTo
  assertNull(recordType.autoboxesTo());

  // canBeCalled
  assertFalse(recordType.canBeCalled());

  // canTestForEqualityWith
  assertCanTestForEqualityWith(recordType, ALL_TYPE);
  assertCanTestForEqualityWith(recordType, STRING_OBJECT_TYPE);
  assertCanTestForEqualityWith(recordType, recordType);
  assertCanTestForEqualityWith(recordType, functionType);
  assertCanTestForEqualityWith(recordType, OBJECT_TYPE);
  assertCanTestForEqualityWith(recordType, NUMBER_TYPE);
  assertCanTestForEqualityWith(recordType, DATE_TYPE);
  assertCanTestForEqualityWith(recordType, REGEXP_TYPE);

  // canTestForShallowEqualityWith
  assertTrue(recordType.canTestForShallowEqualityWith(NO_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(NO_OBJECT_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(ARRAY_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(BOOLEAN_TYPE));
  assertFalse(recordType.
      canTestForShallowEqualityWith(BOOLEAN_OBJECT_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(DATE_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(ERROR_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(EVAL_ERROR_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(recordType));
  assertFalse(recordType.canTestForShallowEqualityWith(NULL_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(NUMBER_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(NUMBER_OBJECT_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(OBJECT_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(URI_ERROR_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(RANGE_ERROR_TYPE));
  assertFalse(recordType.
      canTestForShallowEqualityWith(REFERENCE_ERROR_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(REGEXP_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(STRING_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(STRING_OBJECT_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(SYNTAX_ERROR_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(TYPE_ERROR_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(ALL_TYPE));
  assertFalse(recordType.canTestForShallowEqualityWith(VOID_TYPE));
  assertTrue(recordType.canTestForShallowEqualityWith(UNKNOWN_TYPE));

  // matchesXxx
  assertFalse(recordType.matchesInt32Context());
  assertFalse(recordType.matchesNumberContext());
  assertTrue(recordType.matchesObjectContext());
  assertFalse(recordType.matchesStringContext());
  assertFalse(recordType.matchesUint32Context());

  Asserts.assertResolvesToSame(recordType);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:72,代码来源:JSTypeTest.java

示例14: testFunctionType

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests the behavior of functional types.
 */
public void testFunctionType() throws Exception {
  // isXxx
  assertTrue(functionType.isObject());
  assertFalse(functionType.isFunctionPrototypeType());
  assertTrue(functionType.getImplicitPrototype().getImplicitPrototype()
      .isFunctionPrototypeType());

  // isSubtype
  assertTrue(functionType.isSubtype(ALL_TYPE));
  assertFalse(functionType.isSubtype(STRING_OBJECT_TYPE));
  assertFalse(functionType.isSubtype(NUMBER_TYPE));
  assertFalse(functionType.isSubtype(DATE_TYPE));
  assertFalse(functionType.isSubtype(REGEXP_TYPE));
  assertTrue(functionType.isSubtype(UNKNOWN_TYPE));
  assertTrue(functionType.isSubtype(U2U_CONSTRUCTOR_TYPE));

  // autoboxesTo
  assertNull(functionType.autoboxesTo());

  // canBeCalled
  assertTrue(functionType.canBeCalled());

  // canTestForEqualityWith
  assertCanTestForEqualityWith(functionType, ALL_TYPE);
  assertCanTestForEqualityWith(functionType, STRING_OBJECT_TYPE);
  assertCanTestForEqualityWith(functionType, functionType);
  assertCanTestForEqualityWith(functionType, OBJECT_TYPE);
  assertCannotTestForEqualityWith(functionType, NUMBER_TYPE);
  assertCanTestForEqualityWith(functionType, DATE_TYPE);
  assertCanTestForEqualityWith(functionType, REGEXP_TYPE);

  // canTestForShallowEqualityWith
  assertTrue(functionType.canTestForShallowEqualityWith(NO_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(NO_OBJECT_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(ARRAY_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(BOOLEAN_TYPE));
  assertFalse(functionType.
      canTestForShallowEqualityWith(BOOLEAN_OBJECT_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(DATE_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(ERROR_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(EVAL_ERROR_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(functionType));
  assertFalse(functionType.canTestForShallowEqualityWith(NULL_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(NUMBER_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(NUMBER_OBJECT_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(OBJECT_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(URI_ERROR_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(RANGE_ERROR_TYPE));
  assertFalse(functionType.
      canTestForShallowEqualityWith(REFERENCE_ERROR_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(REGEXP_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(STRING_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(STRING_OBJECT_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(SYNTAX_ERROR_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(TYPE_ERROR_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(ALL_TYPE));
  assertFalse(functionType.canTestForShallowEqualityWith(VOID_TYPE));
  assertTrue(functionType.canTestForShallowEqualityWith(UNKNOWN_TYPE));

  // matchesXxx
  assertFalse(functionType.matchesInt32Context());
  assertFalse(functionType.matchesNumberContext());
  assertTrue(functionType.matchesObjectContext());
  assertFalse(functionType.matchesStringContext());
  assertFalse(functionType.matchesUint32Context());

  // hasProperty
  assertTrue(functionType.hasProperty("prototype"));
  assertPropertyTypeInferred(functionType, "prototype");

  Asserts.assertResolvesToSame(functionType);


  assertEquals("aFunctionName", new FunctionBuilder(registry).
      withName("aFunctionName").build().getDisplayName());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:80,代码来源:JSTypeTest.java

示例15: testVoidType

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests the behavior of the void type.
 */
public void testVoidType() throws Exception {
  // isSubtype
  assertTrue(VOID_TYPE.isSubtype(ALL_TYPE));
  assertFalse(VOID_TYPE.isSubtype(STRING_OBJECT_TYPE));
  assertFalse(VOID_TYPE.isSubtype(REGEXP_TYPE));

  // autoboxesTo
  assertNull(VOID_TYPE.autoboxesTo());

  // canTestForEqualityWith
  assertCanTestForEqualityWith(VOID_TYPE, ALL_TYPE);
  assertCannotTestForEqualityWith(VOID_TYPE, REGEXP_TYPE);

  // canTestForShallowEqualityWith
  assertTrue(VOID_TYPE.canTestForShallowEqualityWith(NO_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(NO_OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(ARRAY_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(BOOLEAN_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(BOOLEAN_OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(DATE_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(EVAL_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(functionType));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(NULL_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(NUMBER_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(NUMBER_OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(URI_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(RANGE_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(REFERENCE_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(REGEXP_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(STRING_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(STRING_OBJECT_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(SYNTAX_ERROR_TYPE));
  assertFalse(VOID_TYPE.canTestForShallowEqualityWith(TYPE_ERROR_TYPE));
  assertTrue(VOID_TYPE.canTestForShallowEqualityWith(ALL_TYPE));
  assertTrue(VOID_TYPE.canTestForShallowEqualityWith(VOID_TYPE));
  assertTrue(VOID_TYPE.canTestForShallowEqualityWith(
          createUnionType(NUMBER_TYPE, VOID_TYPE)));

  // matchesXxx
  assertFalse(VOID_TYPE.matchesInt32Context());
  assertFalse(VOID_TYPE.matchesNumberContext());
  assertFalse(VOID_TYPE.matchesObjectContext());
  assertTrue(VOID_TYPE.matchesStringContext());
  assertFalse(VOID_TYPE.matchesUint32Context());

  Asserts.assertResolvesToSame(VOID_TYPE);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:53,代码来源:JSTypeTest.java


注:本文中的com.google.javascript.rhino.testing.Asserts.assertResolvesToSame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。