use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testTemplateBound_single.
@Test
public void testTemplateBound_single() {
builder.recordTemplateTypeName("T", new JSTypeExpression(JsDocInfoParser.parseTypeString("!Array<number>"), ""));
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(lines(//
"/**", " * @template {!Array<number>} T", " */", ""));
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testReturnDescription.
@Test
public void testReturnDescription() {
builder.recordReturnType(new JSTypeExpression(JsDocInfoParser.parseTypeString("boolean"), "<testReturn>"));
builder.recordReturnDescription("The return value");
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(LINE_JOINER.join("/**", " * @return {boolean} The return value", " */", ""));
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testTemplateBound_explicitlyOnUnknown_isOmitted.
@Test
public void testTemplateBound_explicitlyOnUnknown_isOmitted() {
builder.recordTemplateTypeName("T", new JSTypeExpression(JsDocInfoParser.parseTypeString("?"), ""));
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(lines(//
"/**", " * @template T", " */", ""));
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testTypeof.
@Test
public void testTypeof() {
builder.recordType(new JSTypeExpression(JsDocInfoParser.parseTypeString("typeof foo"), "<testTypeof>"));
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/** @type {typeof foo} */ ");
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testRecordTypes.
@Test
public void testRecordTypes() {
builder.recordType(new JSTypeExpression(JsDocInfoParser.parseTypeString("{foo: number}"), "<testRecordTypes>"));
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/** @type {{foo:number}} */ ");
builder.recordType(new JSTypeExpression(JsDocInfoParser.parseTypeString("{foo}"), "<testRecordTypes>"));
info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/** @type {{foo}} */ ");
builder.recordType(new JSTypeExpression(JsDocInfoParser.parseTypeString("{foo, bar}"), "<testRecordTypes>"));
info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/** @type {{foo,bar}} */ ");
builder.recordType(new JSTypeExpression(JsDocInfoParser.parseTypeString("{foo: number, bar}"), "<testRecordTypes>"));
info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/** @type {{foo:number,bar}} */ ");
builder.recordType(new JSTypeExpression(JsDocInfoParser.parseTypeString("{foo, bar: number}"), "<testRecordTypes>"));
info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/** @type {{foo,bar:number}} */ ");
}
Aggregations