use of com.google.javascript.rhino.jstype.JSType in project closure-compiler by google.
the class TypeCheckTest method testGatherProperyWithoutAnnotation1.
public void testGatherProperyWithoutAnnotation1() {
Node n = parseAndTypeCheck("/** @constructor */ var T = function() {};" + "/** @type {!T} */var t; t.x; t;");
JSType type = n.getLastChild().getLastChild().getJSType();
assertFalse(type.isUnknownType());
assertThat(type).isInstanceOf(ObjectType.class);
ObjectType objectType = (ObjectType) type;
assertFalse(objectType.hasProperty("x"));
}
use of com.google.javascript.rhino.jstype.JSType in project closure-compiler by google.
the class TypeInferenceTest method testAssertNumber2.
public void testAssertNumber2() {
// Make sure it ignores expressions.
JSType startType = createNullableType(ALL_TYPE);
assuming("x", startType);
inFunction("goog.asserts.assertNumber(x + x); out1 = x;");
verify("out1", startType);
}
use of com.google.javascript.rhino.jstype.JSType in project closure-compiler by google.
the class TypeInferenceTest method testAssert8.
public void testAssert8() {
JSType startType = createNullableType(OBJECT_TYPE);
assuming("x", startType);
inFunction("out1 = x; out2 = goog.asserts.assert(x != null);");
verify("out1", startType);
verify("out2", BOOLEAN_TYPE);
}
use of com.google.javascript.rhino.jstype.JSType in project closure-compiler by google.
the class TypeInferenceTest method testIsDefAndNoResolvedType.
public void testIsDefAndNoResolvedType() {
JSType startType = createUndefinableType(NO_RESOLVED_TYPE);
assuming("x", startType);
inFunction("out1 = x;" + "if (goog.isDef(x)) { out2a = x; out2b = x.length; out2c = x; }" + "out3 = x;" + "if (goog.isDef(x)) { out4 = x; }");
verify("out1", startType);
verify("out2a", NO_RESOLVED_TYPE);
verify("out2b", CHECKED_UNKNOWN_TYPE);
verify("out2c", NO_RESOLVED_TYPE);
verify("out3", startType);
verify("out4", NO_RESOLVED_TYPE);
}
use of com.google.javascript.rhino.jstype.JSType in project closure-compiler by google.
the class TypeInferenceTest method testAssertElement.
public void testAssertElement() {
JSType elementType = registry.createObjectType("Element", registry.getNativeObjectType(OBJECT_TYPE));
assuming("x", elementType);
inFunction("out1 = x; goog.asserts.assertElement(x); out2 = x;");
verify("out1", elementType);
}
Aggregations