use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testInheritance.
@Test
public void testInheritance() {
builder.recordImplementedInterface(new JSTypeExpression(JsDocInfoParser.parseTypeString("Foo"), "<testInheritance>"));
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/**\n * @implements {Foo}\n */\n");
builder.recordImplementedInterface(new JSTypeExpression(JsDocInfoParser.parseTypeString("!Foo"), "<testInheritance>"));
info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/**\n * @implements {Foo}\n */\n");
builder.recordBaseType(new JSTypeExpression(JsDocInfoParser.parseTypeString("Foo"), "<testInheritance>"));
info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/**\n * @extends {Foo}\n */\n");
builder.recordBaseType(new JSTypeExpression(JsDocInfoParser.parseTypeString("!Foo"), "<testInheritance>"));
builder.recordImplementedInterface(new JSTypeExpression(JsDocInfoParser.parseTypeString("Bar"), "<testInheritance>"));
builder.recordImplementedInterface(new JSTypeExpression(JsDocInfoParser.parseTypeString("Bar.Baz"), "<testInheritance>"));
info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/**\n * @extends {Foo}\n * @implements {Bar}\n * @implements {Bar.Baz}\n */\n");
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testTemplatesBound_multiple.
@Test
public void testTemplatesBound_multiple() {
builder.recordTemplateTypeName("T", new JSTypeExpression(JsDocInfoParser.parseTypeString("!Array<number>"), ""));
builder.recordTemplateTypeName("U", new JSTypeExpression(JsDocInfoParser.parseTypeString("boolean"), ""));
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(lines(//
"/**", " * @template {!Array<number>} T", " * @template {boolean} U", " */", ""));
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testDefines.
@Test
public void testDefines() {
builder.recordDefineType(new JSTypeExpression(JsDocInfoParser.parseTypeString("string"), "<testDefines>"));
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo("/** @define {string} */ ");
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testParamDescriptions.
@Test
public void testParamDescriptions() {
builder.recordParameter("foo", new JSTypeExpression(JsDocInfoParser.parseTypeString("number"), "<testParam>"));
builder.recordParameter("bar", new JSTypeExpression(JsDocInfoParser.parseTypeString("string"), "<testParam>"));
// The parser will retain leading whitespace for descriptions.
builder.recordParameterDescription("foo", " A number for foo");
builder.recordParameterDescription("bar", " A multline\n description for bar");
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(LINE_JOINER.join("/**", " * @param {number} foo A number for foo", " * @param {string} bar A multline", " * description for bar", " */", ""));
}
use of com.google.javascript.rhino.JSTypeExpression in project closure-compiler by google.
the class JSDocInfoPrinterTest method testAuthorReferencePrintedWithOtherAnnotations.
@Test
public void testAuthorReferencePrintedWithOtherAnnotations() {
builder.recordType(new JSTypeExpression(JsDocInfoParser.parseTypeString("string"), "<testAuthor>"));
builder.recordAuthor("John Doe.");
JSDocInfo info = builder.buildAndReset();
assertThat(jsDocInfoPrinter.print(info)).isEqualTo(LINE_JOINER.join("/**", " * @author John Doe.", " * @type {string}", " */", ""));
}
Aggregations