Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix doc printer missing [] around tuple type #6523

Merged
merged 4 commits into from Jun 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/doc/printer.rs
Expand Up @@ -206,14 +206,15 @@ fn render_ts_type(ts_type: doc::ts_type::TsTypeDef) -> String {
TsTypeDefKind::This => "this".to_string(),
TsTypeDefKind::Tuple => {
let tuple = ts_type.tuple.unwrap();
let mut output = "".to_string();
let mut output = "[".to_string();
if !tuple.is_empty() {
for ts_type in tuple {
output += render_ts_type(ts_type).as_str();
output += ", "
}
output.truncate(output.len() - 2);
}
output += "]";
output
}
TsTypeDefKind::TypeLiteral => {
Expand Down
2 changes: 2 additions & 0 deletions cli/tests/doc/generic_tuple.out
@@ -0,0 +1,2 @@
function f(): Generic<[string, number]>

4 changes: 4 additions & 0 deletions cli/tests/doc/generic_tuple.ts
@@ -0,0 +1,4 @@
interface Generic<_T> {}
export function f(): Generic<[string, number]> {
return {};
}
29 changes: 29 additions & 0 deletions cli/tests/integration_tests.rs
Expand Up @@ -45,6 +45,35 @@ fn std_lint() {
assert!(status.success());
}

#[test]
fn doc_tests() {
for file in util::root_path()
.join("cli/tests/doc")
.as_path()
.read_dir()
.unwrap()
{
let file = file.unwrap();
assert!(file.file_type().unwrap().is_file());

SyrupThinker marked this conversation as resolved.
Show resolved Hide resolved
let name = file.file_name();
let name = name.to_str().unwrap();

if name.ends_with(".js") || name.ends_with(".ts") {
let doc_path = file.path();
let mut out_path = doc_path.clone();
out_path.set_extension("out");

(util::CheckOutputIntegrationTest {
args: &format!("doc {}", doc_path.to_str().unwrap()),
output: out_path.to_str().unwrap(),
..Default::default()
})
.run();
}
}
}

#[test]
fn x_deno_warning() {
let g = util::http_server();
Expand Down
12 changes: 6 additions & 6 deletions test_util/src/lib.rs
Expand Up @@ -191,16 +191,16 @@ pub fn run_python_script(script: &str) {
}

#[derive(Debug, Default)]
pub struct CheckOutputIntegrationTest {
pub args: &'static str,
pub output: &'static str,
pub input: Option<&'static str>,
pub output_str: Option<&'static str>,
pub struct CheckOutputIntegrationTest<'a> {
pub args: &'a str,
pub output: &'a str,
pub input: Option<&'a str>,
pub output_str: Option<&'a str>,
SyrupThinker marked this conversation as resolved.
Show resolved Hide resolved
pub exit_code: i32,
pub http_server: bool,
}

impl CheckOutputIntegrationTest {
impl<'a> CheckOutputIntegrationTest<'a> {
pub fn run(&self) {
let args = self.args.split_whitespace();
let root = root_path();
Expand Down
1 change: 1 addition & 0 deletions tools/lint.py
Expand Up @@ -68,6 +68,7 @@ def eslint():
":!:std/**/node_modules/*",
":!:cli/compilers/wasm_wrap.js",
":!:cli/tests/error_syntax.js",
":!:cli/tests/doc/**",
":!:cli/tests/lint/**",
])
if source_files:
Expand Down