Get remaining language2 tests passing
This commit is contained in:
parent
0eae962abf
commit
65045b9c52
4 changed files with 1475 additions and 1471 deletions
|
@ -163,6 +163,10 @@ impl Executor {
|
||||||
future: impl Future<Output = R>,
|
future: impl Future<Output = R>,
|
||||||
) -> Result<R, impl Future<Output = R>> {
|
) -> Result<R, impl Future<Output = R>> {
|
||||||
let mut future = Box::pin(future);
|
let mut future = Box::pin(future);
|
||||||
|
if duration.is_zero() {
|
||||||
|
return Err(future);
|
||||||
|
}
|
||||||
|
|
||||||
let timeout = {
|
let timeout = {
|
||||||
let future = &mut future;
|
let future = &mut future;
|
||||||
async {
|
async {
|
||||||
|
|
|
@ -311,134 +311,134 @@ async fn test_normalize_whitespace(cx: &mut gpui2::TestAppContext) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[gpui2::test]
|
#[gpui2::test]
|
||||||
// async fn test_reparse(cx: &mut gpui2::TestAppContext) {
|
async fn test_reparse(cx: &mut gpui2::TestAppContext) {
|
||||||
// let text = "fn a() {}";
|
let text = "fn a() {}";
|
||||||
// let buffer = cx.entity(|cx| {
|
let buffer = cx.entity(|cx| {
|
||||||
// Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx)
|
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx)
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Wait for the initial text to parse
|
// Wait for the initial text to parse
|
||||||
// cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
// assert!(!buffer.update(cx, |buffer, _| buffer.is_parsing()));
|
assert!(!buffer.update(cx, |buffer, _| buffer.is_parsing()));
|
||||||
// assert_eq!(
|
assert_eq!(
|
||||||
// get_tree_sexp(&buffer, cx),
|
get_tree_sexp(&buffer, cx),
|
||||||
// concat!(
|
concat!(
|
||||||
// "(source_file (function_item name: (identifier) ",
|
"(source_file (function_item name: (identifier) ",
|
||||||
// "parameters: (parameters) ",
|
"parameters: (parameters) ",
|
||||||
// "body: (block)))"
|
"body: (block)))"
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
|
|
||||||
// buffer.update(cx, |buffer, _| {
|
buffer.update(cx, |buffer, _| {
|
||||||
// buffer.set_sync_parse_timeout(Duration::ZERO)
|
buffer.set_sync_parse_timeout(Duration::ZERO)
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Perform some edits (add parameter and variable reference)
|
// Perform some edits (add parameter and variable reference)
|
||||||
// // Parsing doesn't begin until the transaction is complete
|
// Parsing doesn't begin until the transaction is complete
|
||||||
// buffer.update(cx, |buf, cx| {
|
buffer.update(cx, |buf, cx| {
|
||||||
// buf.start_transaction();
|
buf.start_transaction();
|
||||||
|
|
||||||
// let offset = buf.text().find(')').unwrap();
|
let offset = buf.text().find(')').unwrap();
|
||||||
// buf.edit([(offset..offset, "b: C")], None, cx);
|
buf.edit([(offset..offset, "b: C")], None, cx);
|
||||||
// assert!(!buf.is_parsing());
|
assert!(!buf.is_parsing());
|
||||||
|
|
||||||
// let offset = buf.text().find('}').unwrap();
|
let offset = buf.text().find('}').unwrap();
|
||||||
// buf.edit([(offset..offset, " d; ")], None, cx);
|
buf.edit([(offset..offset, " d; ")], None, cx);
|
||||||
// assert!(!buf.is_parsing());
|
assert!(!buf.is_parsing());
|
||||||
|
|
||||||
// buf.end_transaction(cx);
|
buf.end_transaction(cx);
|
||||||
// assert_eq!(buf.text(), "fn a(b: C) { d; }");
|
assert_eq!(buf.text(), "fn a(b: C) { d; }");
|
||||||
// assert!(buf.is_parsing());
|
assert!(buf.is_parsing());
|
||||||
// });
|
});
|
||||||
// cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
// assert!(!buffer.update(cx, |buffer, _| buffer.is_parsing()));
|
assert!(!buffer.update(cx, |buffer, _| buffer.is_parsing()));
|
||||||
// assert_eq!(
|
assert_eq!(
|
||||||
// get_tree_sexp(&buffer, cx),
|
get_tree_sexp(&buffer, cx),
|
||||||
// concat!(
|
concat!(
|
||||||
// "(source_file (function_item name: (identifier) ",
|
"(source_file (function_item name: (identifier) ",
|
||||||
// "parameters: (parameters (parameter pattern: (identifier) type: (type_identifier))) ",
|
"parameters: (parameters (parameter pattern: (identifier) type: (type_identifier))) ",
|
||||||
// "body: (block (expression_statement (identifier)))))"
|
"body: (block (expression_statement (identifier)))))"
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
|
|
||||||
// // Perform a series of edits without waiting for the current parse to complete:
|
// Perform a series of edits without waiting for the current parse to complete:
|
||||||
// // * turn identifier into a field expression
|
// * turn identifier into a field expression
|
||||||
// // * turn field expression into a method call
|
// * turn field expression into a method call
|
||||||
// // * add a turbofish to the method call
|
// * add a turbofish to the method call
|
||||||
// buffer.update(cx, |buf, cx| {
|
buffer.update(cx, |buf, cx| {
|
||||||
// let offset = buf.text().find(';').unwrap();
|
let offset = buf.text().find(';').unwrap();
|
||||||
// buf.edit([(offset..offset, ".e")], None, cx);
|
buf.edit([(offset..offset, ".e")], None, cx);
|
||||||
// assert_eq!(buf.text(), "fn a(b: C) { d.e; }");
|
assert_eq!(buf.text(), "fn a(b: C) { d.e; }");
|
||||||
// assert!(buf.is_parsing());
|
assert!(buf.is_parsing());
|
||||||
// });
|
});
|
||||||
// buffer.update(cx, |buf, cx| {
|
buffer.update(cx, |buf, cx| {
|
||||||
// let offset = buf.text().find(';').unwrap();
|
let offset = buf.text().find(';').unwrap();
|
||||||
// buf.edit([(offset..offset, "(f)")], None, cx);
|
buf.edit([(offset..offset, "(f)")], None, cx);
|
||||||
// assert_eq!(buf.text(), "fn a(b: C) { d.e(f); }");
|
assert_eq!(buf.text(), "fn a(b: C) { d.e(f); }");
|
||||||
// assert!(buf.is_parsing());
|
assert!(buf.is_parsing());
|
||||||
// });
|
});
|
||||||
// buffer.update(cx, |buf, cx| {
|
buffer.update(cx, |buf, cx| {
|
||||||
// let offset = buf.text().find("(f)").unwrap();
|
let offset = buf.text().find("(f)").unwrap();
|
||||||
// buf.edit([(offset..offset, "::<G>")], None, cx);
|
buf.edit([(offset..offset, "::<G>")], None, cx);
|
||||||
// assert_eq!(buf.text(), "fn a(b: C) { d.e::<G>(f); }");
|
assert_eq!(buf.text(), "fn a(b: C) { d.e::<G>(f); }");
|
||||||
// assert!(buf.is_parsing());
|
assert!(buf.is_parsing());
|
||||||
// });
|
});
|
||||||
// cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
// assert_eq!(
|
assert_eq!(
|
||||||
// get_tree_sexp(&buffer, cx),
|
get_tree_sexp(&buffer, cx),
|
||||||
// concat!(
|
concat!(
|
||||||
// "(source_file (function_item name: (identifier) ",
|
"(source_file (function_item name: (identifier) ",
|
||||||
// "parameters: (parameters (parameter pattern: (identifier) type: (type_identifier))) ",
|
"parameters: (parameters (parameter pattern: (identifier) type: (type_identifier))) ",
|
||||||
// "body: (block (expression_statement (call_expression ",
|
"body: (block (expression_statement (call_expression ",
|
||||||
// "function: (generic_function ",
|
"function: (generic_function ",
|
||||||
// "function: (field_expression value: (identifier) field: (field_identifier)) ",
|
"function: (field_expression value: (identifier) field: (field_identifier)) ",
|
||||||
// "type_arguments: (type_arguments (type_identifier))) ",
|
"type_arguments: (type_arguments (type_identifier))) ",
|
||||||
// "arguments: (arguments (identifier)))))))",
|
"arguments: (arguments (identifier)))))))",
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
|
|
||||||
// buffer.update(cx, |buf, cx| {
|
buffer.update(cx, |buf, cx| {
|
||||||
// buf.undo(cx);
|
buf.undo(cx);
|
||||||
// buf.undo(cx);
|
buf.undo(cx);
|
||||||
// buf.undo(cx);
|
buf.undo(cx);
|
||||||
// buf.undo(cx);
|
buf.undo(cx);
|
||||||
// assert_eq!(buf.text(), "fn a() {}");
|
assert_eq!(buf.text(), "fn a() {}");
|
||||||
// assert!(buf.is_parsing());
|
assert!(buf.is_parsing());
|
||||||
// });
|
});
|
||||||
|
|
||||||
// cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
// assert_eq!(
|
assert_eq!(
|
||||||
// get_tree_sexp(&buffer, cx),
|
get_tree_sexp(&buffer, cx),
|
||||||
// concat!(
|
concat!(
|
||||||
// "(source_file (function_item name: (identifier) ",
|
"(source_file (function_item name: (identifier) ",
|
||||||
// "parameters: (parameters) ",
|
"parameters: (parameters) ",
|
||||||
// "body: (block)))"
|
"body: (block)))"
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
|
|
||||||
// buffer.update(cx, |buf, cx| {
|
buffer.update(cx, |buf, cx| {
|
||||||
// buf.redo(cx);
|
buf.redo(cx);
|
||||||
// buf.redo(cx);
|
buf.redo(cx);
|
||||||
// buf.redo(cx);
|
buf.redo(cx);
|
||||||
// buf.redo(cx);
|
buf.redo(cx);
|
||||||
// assert_eq!(buf.text(), "fn a(b: C) { d.e::<G>(f); }");
|
assert_eq!(buf.text(), "fn a(b: C) { d.e::<G>(f); }");
|
||||||
// assert!(buf.is_parsing());
|
assert!(buf.is_parsing());
|
||||||
// });
|
});
|
||||||
// cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
// assert_eq!(
|
assert_eq!(
|
||||||
// get_tree_sexp(&buffer, cx),
|
get_tree_sexp(&buffer, cx),
|
||||||
// concat!(
|
concat!(
|
||||||
// "(source_file (function_item name: (identifier) ",
|
"(source_file (function_item name: (identifier) ",
|
||||||
// "parameters: (parameters (parameter pattern: (identifier) type: (type_identifier))) ",
|
"parameters: (parameters (parameter pattern: (identifier) type: (type_identifier))) ",
|
||||||
// "body: (block (expression_statement (call_expression ",
|
"body: (block (expression_statement (call_expression ",
|
||||||
// "function: (generic_function ",
|
"function: (generic_function ",
|
||||||
// "function: (field_expression value: (identifier) field: (field_identifier)) ",
|
"function: (field_expression value: (identifier) field: (field_identifier)) ",
|
||||||
// "type_arguments: (type_arguments (type_identifier))) ",
|
"type_arguments: (type_arguments (type_identifier))) ",
|
||||||
// "arguments: (arguments (identifier)))))))",
|
"arguments: (arguments (identifier)))))))",
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
#[gpui2::test]
|
#[gpui2::test]
|
||||||
async fn test_resetting_language(cx: &mut gpui2::TestAppContext) {
|
async fn test_resetting_language(cx: &mut gpui2::TestAppContext) {
|
||||||
|
|
|
@ -76,36 +76,36 @@ impl Default for HighlightId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(test)]
|
#[cfg(test)]
|
||||||
// mod tests {
|
mod tests {
|
||||||
// use super::*;
|
use super::*;
|
||||||
// use gpui2::color::Color;
|
use gpui2::rgba;
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn test_highlight_map() {
|
fn test_highlight_map() {
|
||||||
// let theme = SyntaxTheme::new(
|
let theme = SyntaxTheme {
|
||||||
// [
|
highlights: [
|
||||||
// ("function", Color::from_u32(0x100000ff)),
|
("function", rgba(0x100000ff)),
|
||||||
// ("function.method", Color::from_u32(0x200000ff)),
|
("function.method", rgba(0x200000ff)),
|
||||||
// ("function.async", Color::from_u32(0x300000ff)),
|
("function.async", rgba(0x300000ff)),
|
||||||
// ("variable.builtin.self.rust", Color::from_u32(0x400000ff)),
|
("variable.builtin.self.rust", rgba(0x400000ff)),
|
||||||
// ("variable.builtin", Color::from_u32(0x500000ff)),
|
("variable.builtin", rgba(0x500000ff)),
|
||||||
// ("variable", Color::from_u32(0x600000ff)),
|
("variable", rgba(0x600000ff)),
|
||||||
// ]
|
]
|
||||||
// .iter()
|
.iter()
|
||||||
// .map(|(name, color)| (name.to_string(), (*color).into()))
|
.map(|(name, color)| (name.to_string(), (*color).into()))
|
||||||
// .collect(),
|
.collect(),
|
||||||
// );
|
};
|
||||||
|
|
||||||
// let capture_names = &[
|
let capture_names = &[
|
||||||
// "function.special".to_string(),
|
"function.special".to_string(),
|
||||||
// "function.async.rust".to_string(),
|
"function.async.rust".to_string(),
|
||||||
// "variable.builtin.self".to_string(),
|
"variable.builtin.self".to_string(),
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// let map = HighlightMap::new(capture_names, &theme);
|
let map = HighlightMap::new(capture_names, &theme);
|
||||||
// assert_eq!(map.get(0).name(&theme), Some("function"));
|
assert_eq!(map.get(0).name(&theme), Some("function"));
|
||||||
// assert_eq!(map.get(1).name(&theme), Some("function.async"));
|
assert_eq!(map.get(1).name(&theme), Some("function.async"));
|
||||||
// assert_eq!(map.get(2).name(&theme), Some("variable.builtin"));
|
assert_eq!(map.get(2).name(&theme), Some("variable.builtin"));
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue