test/com/google/javascript/rhino/jstype/TemplatizedTypeTest.java
/** Tests the behavior of variants type. */
Tests the behavior of variants type.
Tests the behavior of variants type .
@Test
  public void testTemplatizedType() {
    TemplatizedType arrOfString = createTemplatizedType(
        ARRAY_TYPE, STRING_TYPE);
    assertTypeCanAssignToItself(arrOfString);
    assertTrue(arrOfString.isSubtype(ARRAY_TYPE));
    assertTrue(ARRAY_TYPE.isSubtypeOf(arrOfString));
    TemplatizedType arrOfNumber = createTemplatizedType(
        ARRAY_TYPE, NUMBER_TYPE);
    assertTypeCanAssignToItself(arrOfNumber);
    assertTrue(arrOfNumber.isSubtype(ARRAY_TYPE));
    assertTrue(ARRAY_TYPE.isSubtypeOf(arrOfNumber));
    assertTrue(arrOfString.isEquivalentTo(createTemplatizedType(
        ARRAY_TYPE, STRING_TYPE)));
    assertFalse(arrOfString.isEquivalentTo(ARRAY_TYPE));
    assertFalse(arrOfString.isEquivalentTo(ARRAY_TYPE));
    assertFalse(arrOfString.isEquivalentTo(arrOfNumber));
    assertFalse(arrOfNumber.isEquivalentTo(arrOfString));
  }
@ Test public void testTemplatizedType ( ) { TemplatizedType arrOfString = createTemplatizedType ( ARRAY_TYPE , STRING_TYPE ) ; assertTypeCanAssignToItself ( arrOfString ) ; assertTrue ( arrOfString . isSubtype ( ARRAY_TYPE ) ) ; assertTrue ( ARRAY_TYPE . isSubtypeOf ( arrOfString ) ) ; TemplatizedType arrOfNumber = createTemplatizedType ( ARRAY_TYPE , NUMBER_TYPE ) ; assertTypeCanAssignToItself ( arrOfNumber ) ; assertTrue ( arrOfNumber . isSubtype ( ARRAY_TYPE ) ) ; assertTrue ( ARRAY_TYPE . isSubtypeOf ( arrOfNumber ) ) ; assertTrue ( arrOfString . isEquivalentTo ( createTemplatizedType ( ARRAY_TYPE , STRING_TYPE ) ) ) ; assertFalse ( arrOfString . isEquivalentTo ( ARRAY_TYPE ) ) ; assertFalse ( arrOfString . isEquivalentTo ( ARRAY_TYPE ) ) ; assertFalse ( arrOfString . isEquivalentTo ( arrOfNumber ) ) ; assertFalse ( arrOfNumber . isEquivalentTo ( arrOfString ) ) ; }
Tests the behavior of variants type.
Tests the behavior of variants type .