Package com.google.javascript.rhino.jstype

Examples of com.google.javascript.rhino.jstype.ObjectType


    testSame(
        "/** @constructor */ function f() { " +
        "  /** @const */ this.foo = 3;" +
        "}" +
        "var x = new f();");
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    assertTrue(x.hasProperty("foo"));
    assertEquals("number", x.getPropertyType("foo").toString());
    assertFalse(x.isPropertyTypeInferred("foo"));
    assertTrue(x.isPropertyTypeDeclared("foo"));
  }
View Full Code Here


        "/** @constructor */ function f() { " +
        "  /** @const */ this.foo = unknown;" +
        "}" +
        "var x = new f();",
        TypedScopeCreator.CANNOT_INFER_CONST_TYPE);
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    assertTrue(x.hasProperty("foo"));
    assertEquals("?", x.getPropertyType("foo").toString());
    assertTrue(x.isPropertyTypeInferred("foo"));
  }
View Full Code Here

    testSame(
        "/** @constructor */ function f() { " +
        "  /** @const */ this.foo = 'abc' + 'def';" +
        "}" +
        "var x = new f();");
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    assertTrue(x.hasProperty("foo"));
    assertEquals("string", x.getPropertyType("foo").toString());
    assertFalse(x.isPropertyTypeInferred("foo"));
    assertTrue(x.isPropertyTypeDeclared("foo"));
  }
View Full Code Here

        "/** @this {f} */ var init_f = function() {" +
        "  /** @const */ this.foo = unknown;" +
        "};" +
        "var x = new f();",
        TypedScopeCreator.CANNOT_INFER_CONST_TYPE);
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    // assertTrue(x.hasProperty("foo"));  // ? why doesn't "f" have "foo" ?
  }
View Full Code Here

        "var init_f = function() {" +
        "  /** @const */ this.FOO = unknown;" +
        "};" +
        "var x = new f();",
        TypedScopeCreator.CANNOT_INFER_CONST_TYPE);
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    assertFalse(x.hasProperty("FOO"));
  }
View Full Code Here

        "f.prototype.init_f = function() {" +
        "  /** @const */ this.FOO = unknown;" +
        "};" +
        "var x = new f();",
        TypedScopeCreator.CANNOT_INFER_CONST_TYPE);
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    // assertTrue(x.hasProperty("FOO"));  // ? why doesn't "f" have "foo" ?
  }
View Full Code Here

        "/** @constructor */ function f() {}\n" +
        "f.prototype.init_f = function() {" +
        "  /** @const */ this.FOO = 'abc';" +
        "};" +
        "var x = new f();");
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    assertTrue(x.hasProperty("FOO"));
    assertEquals("string", x.getPropertyType("FOO").toString());
    assertFalse(x.isPropertyTypeInferred("FOO"));
    assertTrue(x.isPropertyTypeDeclared("FOO"));
  }
View Full Code Here

        "/** @constructor */ function f() {}\n" +
        "f.prototype.init_f = function() {" +
        "  /** @const */ this.foo = new String();" +
        "};" +
        "var x = new f();");
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    assertTrue(x.hasProperty("foo"));
    assertEquals("String", x.getPropertyType("foo").toString());
    assertFalse(x.isPropertyTypeInferred("foo"));
    assertTrue(x.isPropertyTypeDeclared("foo"));
  }
View Full Code Here

        "/** @constructor */ function f() {}\n" +
        "f.prototype.init_f = function() {" +
        "  /** @const */ this.foo = [];" +
        "};" +
        "var x = new f();");
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    assertTrue(x.hasProperty("foo"));
    assertEquals("Array", x.getPropertyType("foo").toString());
    assertFalse(x.isPropertyTypeInferred("foo"));
    assertTrue(x.isPropertyTypeDeclared("foo"));
  }
View Full Code Here

        "/** @constructor */ function f() {}\n" +
        "f.prototype.init_f = function() {" +
        "  /** @const */ this.foo = !!unknown;" +
        "};" +
        "var x = new f();");
    ObjectType x = (ObjectType) findNameType("x", globalScope);
    assertEquals("f", x.toString());
    assertTrue(x.hasProperty("foo"));
    assertEquals("boolean", x.getPropertyType("foo").toString());
    assertFalse(x.isPropertyTypeInferred("foo"));
    assertTrue(x.isPropertyTypeDeclared("foo"));
  }
View Full Code Here

TOP

Related Classes of com.google.javascript.rhino.jstype.ObjectType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.