mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
improved handle_new_char structure, test updates
This commit is contained in:
parent
f851215917
commit
a2d802dd04
3 changed files with 545 additions and 498 deletions
|
@ -8,6 +8,7 @@ use crate::editor::grid_node_map::GridNodeMap;
|
||||||
use crate::editor::markup::attribute::Attributes;
|
use crate::editor::markup::attribute::Attributes;
|
||||||
use crate::editor::markup::common_nodes::new_blank_mn;
|
use crate::editor::markup::common_nodes::new_blank_mn;
|
||||||
use crate::editor::markup::nodes;
|
use crate::editor::markup::nodes;
|
||||||
|
use crate::editor::markup::nodes::LEFT_ACCOLADE;
|
||||||
use crate::editor::markup::nodes::MarkupNode;
|
use crate::editor::markup::nodes::MarkupNode;
|
||||||
use crate::editor::markup::nodes::EQUALS;
|
use crate::editor::markup::nodes::EQUALS;
|
||||||
use crate::editor::mvc::app_update::InputOutcome;
|
use crate::editor::mvc::app_update::InputOutcome;
|
||||||
|
@ -29,6 +30,7 @@ use crate::editor::slow_pool::MarkNodeId;
|
||||||
use crate::editor::slow_pool::SlowPool;
|
use crate::editor::slow_pool::SlowPool;
|
||||||
use crate::editor::syntax_highlight::HighlightStyle;
|
use crate::editor::syntax_highlight::HighlightStyle;
|
||||||
use crate::lang::ast::Def2;
|
use crate::lang::ast::Def2;
|
||||||
|
use crate::lang::ast::DefId;
|
||||||
use crate::lang::ast::{Expr2, ExprId};
|
use crate::lang::ast::{Expr2, ExprId};
|
||||||
use crate::lang::constrain::constrain_expr;
|
use crate::lang::constrain::constrain_expr;
|
||||||
use crate::lang::parse::ASTNodeId;
|
use crate::lang::parse::ASTNodeId;
|
||||||
|
@ -664,41 +666,20 @@ pub fn get_node_context<'a>(ed_model: &'a EdModel) -> EdResult<NodeContext<'a>>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
// current(=caret is here) MarkupNode correspondes to a Def2 in the AST
|
||||||
let input_outcome = match received_char {
|
pub fn handle_new_char_def(received_char: &char, def_id: DefId, ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
||||||
'\u{1}' // Ctrl + A
|
|
||||||
| '\u{3}' // Ctrl + C
|
|
||||||
| '\u{16}' // Ctrl + V
|
|
||||||
| '\u{18}' // Ctrl + X
|
|
||||||
| '\u{e000}'..='\u{f8ff}' // http://www.unicode.org/faq/private_use.html
|
|
||||||
| '\u{f0000}'..='\u{ffffd}' // ^
|
|
||||||
| '\u{100000}'..='\u{10fffd}' // ^
|
|
||||||
=> {
|
|
||||||
// chars that can be ignored
|
|
||||||
InputOutcome::Ignored
|
|
||||||
}
|
|
||||||
'\u{8}' | '\u{7f}' => {
|
|
||||||
// On Linux, '\u{8}' is backspace,
|
|
||||||
// on macOS '\u{7f}'.
|
|
||||||
|
|
||||||
ed_model.replace_selected_expr_with_blank()?;
|
|
||||||
|
|
||||||
InputOutcome::Accepted
|
|
||||||
}
|
|
||||||
ch => {
|
|
||||||
let outcome =
|
|
||||||
if ed_model.node_exists_at_caret() {
|
|
||||||
let curr_mark_node_id = ed_model.get_curr_mark_node_id()?;
|
|
||||||
let curr_mark_node = ed_model.mark_node_pool.get(curr_mark_node_id);
|
|
||||||
let prev_mark_node_id_opt = ed_model.get_prev_mark_node_id()?;
|
|
||||||
|
|
||||||
let ast_node_id = curr_mark_node.get_ast_node_id();
|
|
||||||
|
|
||||||
match ast_node_id {
|
|
||||||
ASTNodeId::ADefId(def_id) => {
|
|
||||||
let def_ref = ed_model.module.env.pool.get(def_id);
|
let def_ref = ed_model.module.env.pool.get(def_id);
|
||||||
|
let ch = received_char;
|
||||||
|
|
||||||
match def_ref {
|
let NodeContext {
|
||||||
|
old_caret_pos,
|
||||||
|
curr_mark_node_id,
|
||||||
|
curr_mark_node,
|
||||||
|
parent_id_opt: _,
|
||||||
|
ast_node_id,
|
||||||
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
|
let outcome =match def_ref {
|
||||||
Def2::Blank {..} => {
|
Def2::Blank {..} => {
|
||||||
match ch {
|
match ch {
|
||||||
'a'..='z' => {
|
'a'..='z' => {
|
||||||
|
@ -709,6 +690,9 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||||
}
|
}
|
||||||
Def2::ValueDef { .. } => {
|
Def2::ValueDef { .. } => {
|
||||||
let val_name_mn_id = if curr_mark_node.get_content() == EQUALS {
|
let val_name_mn_id = if curr_mark_node.get_content() == EQUALS {
|
||||||
|
|
||||||
|
let prev_mark_node_id_opt = ed_model.get_prev_mark_node_id()?;
|
||||||
|
|
||||||
if let Some(prev_mark_node_id) = prev_mark_node_id_opt {
|
if let Some(prev_mark_node_id) = prev_mark_node_id_opt {
|
||||||
prev_mark_node_id
|
prev_mark_node_id
|
||||||
} else {
|
} else {
|
||||||
|
@ -725,11 +709,29 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||||
ch
|
ch
|
||||||
)?
|
)?
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
},
|
|
||||||
ASTNodeId::AExprId(expr_id) => {
|
Ok(outcome)
|
||||||
|
}
|
||||||
|
|
||||||
|
// current(=caret is here) MarkupNode correspondes to an Expr2 in the AST
|
||||||
|
pub fn handle_new_char_expr(received_char: &char, expr_id: ExprId, ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
||||||
|
let expr_ref = ed_model.module.env.pool.get(expr_id);
|
||||||
|
let ch = received_char;
|
||||||
|
|
||||||
|
let NodeContext {
|
||||||
|
old_caret_pos,
|
||||||
|
curr_mark_node_id,
|
||||||
|
curr_mark_node,
|
||||||
|
parent_id_opt: _,
|
||||||
|
ast_node_id,
|
||||||
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
|
let prev_mark_node_id_opt = ed_model.get_prev_mark_node_id()?;
|
||||||
|
|
||||||
let expr_ref = ed_model.module.env.pool.get(expr_id);
|
let expr_ref = ed_model.module.env.pool.get(expr_id);
|
||||||
|
|
||||||
|
let outcome =
|
||||||
if let Expr2::Blank {..} = expr_ref {
|
if let Expr2::Blank {..} = expr_ref {
|
||||||
match ch {
|
match ch {
|
||||||
'a'..='z' => {
|
'a'..='z' => {
|
||||||
|
@ -749,7 +751,7 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||||
start_new_list(ed_model)?
|
start_new_list(ed_model)?
|
||||||
}
|
}
|
||||||
'\r' => {
|
'\r' => {
|
||||||
// For consistency and convenience there is only one way to format Roc, you can't add extra blank lines.
|
// For convenience and consitency there is only one way to format Roc, you can't add extra blank lines.
|
||||||
InputOutcome::Ignored
|
InputOutcome::Ignored
|
||||||
}
|
}
|
||||||
_ => InputOutcome::Ignored
|
_ => InputOutcome::Ignored
|
||||||
|
@ -796,21 +798,12 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||||
}
|
}
|
||||||
_ => InputOutcome::Ignored
|
_ => InputOutcome::Ignored
|
||||||
}
|
}
|
||||||
} else { // prev_mark_node_id != curr_mark_node_id
|
} else if ch.is_ascii_alphanumeric() { // prev_mark_node_id != curr_mark_node_id
|
||||||
match expr_ref {
|
|
||||||
Expr2::SmallStr(_) | Expr2::Str(_) | Expr2::EmptyRecord | Expr2::Record{ .. } => {
|
|
||||||
// prev_mark_node and curr_mark_node are different.
|
|
||||||
// Caret is located before first quote or `{`, no input is allowed here
|
|
||||||
InputOutcome::Ignored
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
if ch.is_ascii_alphanumeric() {
|
|
||||||
match expr_ref {
|
match expr_ref {
|
||||||
Expr2::SmallInt{ .. } => {
|
Expr2::SmallInt{ .. } => {
|
||||||
update_int(ed_model, curr_mark_node_id, ch)?
|
update_int(ed_model, curr_mark_node_id, ch)?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
let prev_ast_node_id =
|
let prev_ast_node_id =
|
||||||
ed_model
|
ed_model
|
||||||
|
@ -820,13 +813,102 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||||
|
|
||||||
match prev_ast_node_id {
|
match prev_ast_node_id {
|
||||||
ASTNodeId::ADefId(_) => {
|
ASTNodeId::ADefId(_) => {
|
||||||
//let prev_node_def = ed_model.module.env.pool.get(prev_def_id);
|
InputOutcome::Ignored
|
||||||
unimplemented!("TODO")
|
|
||||||
},
|
},
|
||||||
ASTNodeId::AExprId(prev_expr_id) => {
|
ASTNodeId::AExprId(prev_expr_id) => {
|
||||||
let prev_node_expr = ed_model.module.env.pool.get(prev_expr_id);
|
handle_new_char_diff_mark_nodes_prev_is_expr(ch, prev_expr_id, expr_id, prev_mark_node_id, curr_mark_node_id, ed_model)?
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if *ch == ':' {
|
||||||
|
let mark_parent_id_opt = curr_mark_node.get_parent_id_opt();
|
||||||
|
|
||||||
match prev_node_expr {
|
if let Some(mark_parent_id) = mark_parent_id_opt {
|
||||||
|
let parent_ast_id = ed_model.mark_node_pool.get(mark_parent_id).get_ast_node_id();
|
||||||
|
|
||||||
|
match parent_ast_id {
|
||||||
|
ASTNodeId::ADefId(_) => InputOutcome::Ignored,
|
||||||
|
ASTNodeId::AExprId(parent_expr_id) => update_record_colon(ed_model, parent_expr_id)?
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
InputOutcome::Ignored
|
||||||
|
}
|
||||||
|
} else if *ch == ',' {
|
||||||
|
if curr_mark_node.get_content() == nodes::LEFT_SQUARE_BR {
|
||||||
|
InputOutcome::Ignored
|
||||||
|
} else {
|
||||||
|
let mark_parent_id_opt = curr_mark_node.get_parent_id_opt();
|
||||||
|
|
||||||
|
if let Some(mark_parent_id) = mark_parent_id_opt {
|
||||||
|
let parent_ast_id = ed_model.mark_node_pool.get(mark_parent_id).get_ast_node_id();
|
||||||
|
|
||||||
|
match parent_ast_id {
|
||||||
|
ASTNodeId::ADefId(_) => {
|
||||||
|
InputOutcome::Ignored
|
||||||
|
},
|
||||||
|
ASTNodeId::AExprId(parent_expr_id) => {
|
||||||
|
let parent_expr2 = ed_model.module.env.pool.get(parent_expr_id);
|
||||||
|
|
||||||
|
match parent_expr2 {
|
||||||
|
Expr2::List { elem_var:_, elems:_} => {
|
||||||
|
|
||||||
|
let (new_child_index, new_ast_child_index) = ed_model.get_curr_child_indices()?;
|
||||||
|
// insert a Blank first, this results in cleaner code
|
||||||
|
add_blank_child(
|
||||||
|
new_child_index,
|
||||||
|
new_ast_child_index,
|
||||||
|
ed_model
|
||||||
|
)?
|
||||||
|
}
|
||||||
|
Expr2::Record { record_var:_, fields:_ } => {
|
||||||
|
todo!("multiple record fields")
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
InputOutcome::Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
InputOutcome::Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if "\"{[".contains(*ch) {
|
||||||
|
let prev_mark_node = ed_model.mark_node_pool.get(prev_mark_node_id);
|
||||||
|
|
||||||
|
if prev_mark_node.get_content() == nodes::LEFT_SQUARE_BR && curr_mark_node.get_content() == nodes::RIGHT_SQUARE_BR {
|
||||||
|
let (new_child_index, new_ast_child_index) = ed_model.get_curr_child_indices()?;
|
||||||
|
// insert a Blank first, this results in cleaner code
|
||||||
|
add_blank_child(
|
||||||
|
new_child_index,
|
||||||
|
new_ast_child_index,
|
||||||
|
ed_model
|
||||||
|
)?;
|
||||||
|
handle_new_char(received_char, ed_model)?
|
||||||
|
} else {
|
||||||
|
InputOutcome::Ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
InputOutcome::Ignored
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
InputOutcome::Ignored
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(outcome)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle new char when prev_mark_node != curr_mark_node and prev_mark_node's AST node is an Expr2
|
||||||
|
pub fn handle_new_char_diff_mark_nodes_prev_is_expr(received_char: &char, prev_expr_id: ExprId, curr_expr_id: ExprId, prev_mark_node_id: MarkNodeId, curr_mark_node_id: MarkNodeId, ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
||||||
|
|
||||||
|
let prev_expr_ref = ed_model.module.env.pool.get(prev_expr_id);
|
||||||
|
let curr_expr_ref = ed_model.module.env.pool.get(curr_expr_id);
|
||||||
|
let ch = received_char;
|
||||||
|
let curr_mark_node = ed_model.mark_node_pool.get(curr_mark_node_id);
|
||||||
|
|
||||||
|
let outcome = match prev_expr_ref {
|
||||||
Expr2::SmallInt{ .. } => {
|
Expr2::SmallInt{ .. } => {
|
||||||
update_int(ed_model, prev_mark_node_id, ch)?
|
update_int(ed_model, prev_mark_node_id, ch)?
|
||||||
}
|
}
|
||||||
|
@ -877,11 +959,8 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||||
InputOutcome::Ignored
|
InputOutcome::Ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr2::LetValue{ def_id, body_id, body_var:_ } => {
|
|
||||||
update_let_value(prev_mark_node_id, *def_id, *body_id, ed_model, ch)?
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
match prev_node_expr {
|
match curr_expr_ref {
|
||||||
Expr2::EmptyRecord => {
|
Expr2::EmptyRecord => {
|
||||||
let sibling_ids = curr_mark_node.get_sibling_ids(&ed_model.mark_node_pool);
|
let sibling_ids = curr_mark_node.get_sibling_ids(&ed_model.mark_node_pool);
|
||||||
|
|
||||||
|
@ -895,87 +974,47 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||||
_ => InputOutcome::Ignored
|
_ => InputOutcome::Ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if *ch == ':' {
|
|
||||||
let mark_parent_id_opt = curr_mark_node.get_parent_id_opt();
|
|
||||||
|
|
||||||
if let Some(mark_parent_id) = mark_parent_id_opt {
|
Ok(outcome)
|
||||||
let parent_ast_id = ed_model.mark_node_pool.get(mark_parent_id).get_ast_node_id();
|
}
|
||||||
|
|
||||||
update_record_colon(ed_model, parent_ast_id.to_expr_id()?)?
|
pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
||||||
} else {
|
let input_outcome = match received_char {
|
||||||
|
'\u{1}' // Ctrl + A
|
||||||
|
| '\u{3}' // Ctrl + C
|
||||||
|
| '\u{16}' // Ctrl + V
|
||||||
|
| '\u{18}' // Ctrl + X
|
||||||
|
| '\u{e000}'..='\u{f8ff}' // http://www.unicode.org/faq/private_use.html
|
||||||
|
| '\u{f0000}'..='\u{ffffd}' // ^
|
||||||
|
| '\u{100000}'..='\u{10fffd}' // ^
|
||||||
|
=> {
|
||||||
|
// chars that can be ignored
|
||||||
InputOutcome::Ignored
|
InputOutcome::Ignored
|
||||||
}
|
}
|
||||||
} else if *ch == ',' {
|
'\u{8}' | '\u{7f}' => {
|
||||||
if curr_mark_node.get_content() == nodes::LEFT_SQUARE_BR {
|
// On Linux, '\u{8}' is backspace,
|
||||||
InputOutcome::Ignored
|
// on macOS '\u{7f}'.
|
||||||
} else {
|
|
||||||
let mark_parent_id_opt = curr_mark_node.get_parent_id_opt();
|
|
||||||
|
|
||||||
if let Some(mark_parent_id) = mark_parent_id_opt {
|
ed_model.replace_selected_expr_with_blank()?;
|
||||||
let parent_ast_id = ed_model.mark_node_pool.get(mark_parent_id).get_ast_node_id();
|
|
||||||
|
|
||||||
match parent_ast_id {
|
InputOutcome::Accepted
|
||||||
ASTNodeId::ADefId(_) => {
|
}
|
||||||
unimplemented!("TODO")
|
ch => {
|
||||||
|
let outcome =
|
||||||
|
if ed_model.node_exists_at_caret() {
|
||||||
|
let curr_mark_node_id = ed_model.get_curr_mark_node_id()?;
|
||||||
|
let curr_mark_node = ed_model.mark_node_pool.get(curr_mark_node_id);
|
||||||
|
let prev_mark_node_id_opt = ed_model.get_prev_mark_node_id()?;
|
||||||
|
|
||||||
|
let ast_node_id = curr_mark_node.get_ast_node_id();
|
||||||
|
|
||||||
|
match ast_node_id {
|
||||||
|
ASTNodeId::ADefId(def_id) => {
|
||||||
|
handle_new_char_def(received_char, def_id, ed_model)?
|
||||||
},
|
},
|
||||||
ASTNodeId::AExprId(parent_expr_id) => {
|
ASTNodeId::AExprId(expr_id) => {
|
||||||
let parent_expr2 = ed_model.module.env.pool.get(parent_expr_id);
|
handle_new_char_expr(received_char, expr_id, ed_model)?
|
||||||
|
|
||||||
match parent_expr2 {
|
|
||||||
Expr2::List { elem_var:_, elems:_} => {
|
|
||||||
|
|
||||||
let (new_child_index, new_ast_child_index) = ed_model.get_curr_child_indices()?;
|
|
||||||
// insert a Blank first, this results in cleaner code
|
|
||||||
add_blank_child(
|
|
||||||
new_child_index,
|
|
||||||
new_ast_child_index,
|
|
||||||
ed_model
|
|
||||||
)?
|
|
||||||
}
|
|
||||||
Expr2::Record { record_var:_, fields:_ } => {
|
|
||||||
todo!("multiple record fields")
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
InputOutcome::Ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
InputOutcome::Ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if "\"{[".contains(*ch) {
|
|
||||||
let prev_mark_node = ed_model.mark_node_pool.get(prev_mark_node_id);
|
|
||||||
|
|
||||||
if prev_mark_node.get_content() == nodes::LEFT_SQUARE_BR && curr_mark_node.get_content() == nodes::RIGHT_SQUARE_BR {
|
|
||||||
let (new_child_index, new_ast_child_index) = ed_model.get_curr_child_indices()?;
|
|
||||||
// insert a Blank first, this results in cleaner code
|
|
||||||
add_blank_child(
|
|
||||||
new_child_index,
|
|
||||||
new_ast_child_index,
|
|
||||||
ed_model
|
|
||||||
)?;
|
|
||||||
handle_new_char(received_char, ed_model)?
|
|
||||||
} else {
|
|
||||||
InputOutcome::Ignored
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
InputOutcome::Ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
InputOutcome::Ignored
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1233,6 +1272,7 @@ pub mod test_ed_update {
|
||||||
} else if input_char == '🡰' {
|
} else if input_char == '🡰' {
|
||||||
ed_model.simple_move_carets_left(1);
|
ed_model.simple_move_carets_left(1);
|
||||||
} else {
|
} else {
|
||||||
|
//dbg!(input_char);
|
||||||
ed_res_to_res(handle_new_char(&input_char, &mut ed_model))?;
|
ed_res_to_res(handle_new_char(&input_char, &mut ed_model))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1352,30 +1392,36 @@ pub mod test_ed_update {
|
||||||
.join("")
|
.join("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const IGNORE_CHARS: &str = "{}()[]-><-_\"azAZ:@09";
|
||||||
|
const IGNORE_CHARS_NO_NUM: &str = ",{}()[]-><-_\"azAZ:@";
|
||||||
|
const IGNORE_NO_LTR: &str = "{\"5";
|
||||||
|
const IGNORE_NO_NUM: &str = "a{\"";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ignore_int() -> Result<(), String> {
|
fn test_ignore_int() -> Result<(), String> {
|
||||||
assert_insert_seq_ignore(ovec!["vec = ┃0"], "{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = ┃0"], IGNORE_CHARS_NO_NUM)?;
|
||||||
assert_insert_seq_ignore(ovec!["vec = ┃7"], "{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = ┃7"], IGNORE_CHARS_NO_NUM)?;
|
||||||
|
|
||||||
assert_insert_seq_ignore(ovec!["vec = 0┃"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = 0┃"], IGNORE_CHARS_NO_NUM)?;
|
||||||
assert_insert_seq_ignore(ovec!["vec = 8┃"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = 8┃"], IGNORE_CHARS_NO_NUM)?;
|
||||||
assert_insert_seq_ignore(ovec!["vec = 20┃"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = 20┃"], IGNORE_CHARS_NO_NUM)?;
|
||||||
assert_insert_seq_ignore(ovec!["vec = 83┃"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = 83┃"], IGNORE_CHARS_NO_NUM)?;
|
||||||
|
|
||||||
assert_insert_seq_ignore(ovec!["vec = 1┃0"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = 1┃0"], IGNORE_CHARS_NO_NUM)?;
|
||||||
assert_insert_seq_ignore(ovec!["vec = 8┃4"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = 8┃4"], IGNORE_CHARS_NO_NUM)?;
|
||||||
|
|
||||||
assert_insert_seq_ignore(ovec!["vec = ┃10"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = ┃10"], IGNORE_CHARS_NO_NUM)?;
|
||||||
assert_insert_seq_ignore(ovec!["vec = ┃84"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = ┃84"], IGNORE_CHARS_NO_NUM)?;
|
||||||
|
|
||||||
assert_insert_seq_ignore(ovec!["vec = 129┃96"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = 129┃96"], IGNORE_CHARS_NO_NUM)?;
|
||||||
assert_insert_seq_ignore(ovec!["vec = 97┃684"], ",{}()[]-><-_\"azAZ:@")?;
|
assert_insert_seq_ignore_nls(ovec!["vec = 97┃684"], IGNORE_CHARS_NO_NUM)?;
|
||||||
|
|
||||||
assert_insert_ignore(ovec!["vec = 0┃"], '0')?;
|
assert_insert_ignore_nls(ovec!["vec = 0┃"], '0')?;
|
||||||
assert_insert_ignore(ovec!["vec = 0┃"], '9')?;
|
assert_insert_ignore_nls(ovec!["vec = 0┃"], '9')?;
|
||||||
assert_insert_ignore(ovec!["vec = ┃0"], '0')?;
|
assert_insert_ignore_nls(ovec!["vec = ┃0"], '0')?;
|
||||||
assert_insert_ignore(ovec!["vec = ┃1234"], '0')?;
|
assert_insert_ignore_nls(ovec!["vec = ┃1234"], '0')?;
|
||||||
assert_insert_ignore(ovec!["vec = ┃100"], '0')?;
|
assert_insert_ignore_nls(ovec!["vec = ┃100"], '0')?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1727,10 +1773,6 @@ pub mod test_ed_update {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
const IGNORE_CHARS: &str = "{}()[]-><-_\"azAZ:@09";
|
|
||||||
const IGNORE_NO_LTR: &str = "{\"5";
|
|
||||||
const IGNORE_NO_NUM: &str = "a{\"";
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ignore_record() -> Result<(), String> {
|
fn test_ignore_record() -> Result<(), String> {
|
||||||
assert_insert_seq_ignore_nls(ovec!["val = ┃{ }"], IGNORE_CHARS)?;
|
assert_insert_seq_ignore_nls(ovec!["val = ┃{ }"], IGNORE_CHARS)?;
|
||||||
|
@ -1819,187 +1861,187 @@ pub mod test_ed_update {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ignore_nested_record() -> Result<(), String> {
|
fn test_ignore_nested_record() -> Result<(), String> {
|
||||||
assert_insert_seq(ovec!["{ a: { ┃ } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { a: { ┃ } }"], IGNORE_NO_LTR)?;
|
||||||
/*assert_insert_seq(ovec!["{ a: ┃{ } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { a: ┃{ } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ a: {┃ } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { a: {┃ } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ a: { }┃ }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { a: { }┃ }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ a: { } ┃}"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { a: { } ┃}"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ a: { } }┃"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { a: { } }┃"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ a:┃ { } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { a:┃ { } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{┃ a: { } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = {┃ a: { } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["┃{ a: { } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = ┃{ a: { } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ ┃a: { } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { ┃a: { } }"], "1")?;
|
||||||
|
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a:┃ RunTimeError } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a:┃ RunTimeError } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: {┃ z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: {┃ z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: ┃{ z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: ┃{ z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: ┃RunTimeError } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: ┃RunTimeError } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: R┃unTimeError } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: R┃unTimeError } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: Ru┃nTimeError } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: Ru┃nTimeError } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1:┃ { z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1:┃ { z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{┃ camelCaseB1: { z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = {┃ camelCaseB1: { z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["┃{ camelCaseB1: { z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = ┃{ camelCaseB1: { z15a: RunTimeError } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ ┃camelCaseB1: { z15a: RunTimeError } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { ┃camelCaseB1: { z15a: RunTimeError } }"], "1")?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { ┃z15a: RunTimeError } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { ┃z15a: RunTimeError } }"], "1")?;
|
||||||
|
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: \"\"┃ } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: \"\"┃ } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: ┃\"\" } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: ┃\"\" } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a:┃ \"\" } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a:┃ \"\" } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: \"\" ┃} }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: \"\" ┃} }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: {┃ z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: {┃ z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: ┃{ z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: ┃{ z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: \"\" }┃ }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: \"\" }┃ }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: \"\" } ┃}"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: \"\" } ┃}"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: \"\" } }┃"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: \"\" } }┃"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1:┃ { z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1:┃ { z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{┃ camelCaseB1: { z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = {┃ camelCaseB1: { z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["┃{ camelCaseB1: { z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = ┃{ camelCaseB1: { z15a: \"\" } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq(ovec!["{ ┃camelCaseB1: { z15a: \"\" } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { ┃camelCaseB1: { z15a: \"\" } }"], "1")?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { ┃z15a: \"\" } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { ┃z15a: \"\" } }"], "1")?;
|
||||||
|
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: 0┃ } }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: 0┃ } }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: ┃123 } }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: ┃123 } }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a:┃ 999 } }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a:┃ 999 } }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: 80 ┃} }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: 80 ┃} }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: {┃ z15a: 99000 } }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: {┃ z15a: 99000 } }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: ┃{ z15a: 12 } }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: ┃{ z15a: 12 } }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: 7 }┃ }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: 7 }┃ }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: 98 } ┃}"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: 98 } ┃}"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { z15a: 4582 } }┃"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { z15a: 4582 } }┃"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1:┃ { z15a: 0 } }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1:┃ { z15a: 0 } }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{┃ camelCaseB1: { z15a: 44 } }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = {┃ camelCaseB1: { z15a: 44 } }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["┃{ camelCaseB1: { z15a: 100123 } }"], IGNORE_NO_NUM)?;
|
assert_insert_seq_ignore_nls(ovec!["val = ┃{ camelCaseB1: { z15a: 100123 } }"], IGNORE_NO_NUM)?;
|
||||||
assert_insert_seq(ovec!["{ ┃camelCaseB1: { z15a: 5 } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { ┃camelCaseB1: { z15a: 5 } }"], "1")?;
|
||||||
assert_insert_seq(ovec!["{ camelCaseB1: { ┃z15a: 6 } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { ┃z15a: 6 } }"], "1")?;
|
||||||
|
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\"┃ } }"],
|
ovec!["val = { camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\"┃ } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: { z15a: ┃\"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
ovec!["val = { camelCaseB1: { z15a: ┃\"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: { z15a:┃ \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
ovec!["val = { camelCaseB1: { z15a:┃ \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" ┃} }"],
|
ovec!["val = { camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" ┃} }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: {┃ z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
ovec!["val = { camelCaseB1: {┃ z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: ┃{ z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
ovec!["val = { camelCaseB1: ┃{ z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" }┃ }"],
|
ovec!["val = { camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" }┃ }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } ┃}"],
|
ovec!["val = { camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } ┃}"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }┃"],
|
ovec!["val = { camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }┃"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1:┃ { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
ovec!["val = { camelCaseB1:┃ { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{┃ camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
ovec!["val = {┃ camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["┃{ camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
ovec!["val = ┃{ camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ ┃camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
ovec!["val = { ┃camelCaseB1: { z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
||||||
"1",
|
"1",
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ camelCaseB1: { ┃z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
ovec!["val = { camelCaseB1: { ┃z15a: \"hello, hello.0123456789ZXY{}[]-><-\" } }"],
|
||||||
"1",
|
"1",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ g: { oi: { ng: { d: { e: { e: { p: { camelCase:┃ RunTimeError } } } } } } } }"],
|
ovec!["val = { g: { oi: { ng: { d: { e: { e: { p: { camelCase:┃ RunTimeError } } } } } } } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ g: { oi: { ng: { d: { e: { e: { p: { camelCase: R┃unTimeError } } } } } } } }"],
|
ovec!["val = { g: { oi: { ng: { d: { e: { e: { p: { camelCase: R┃unTimeError } } } } } } } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeError } } } } } } } }┃"],
|
ovec!["val = { g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeError } } } } } } } }┃"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeEr┃ror } } } } } } } }"],
|
ovec!["val = { g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeEr┃ror } } } } } } } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ g: { oi: { ng: { d: { e: {┃ e: { p: { camelCase: RunTimeError } } } } } } } }"],
|
ovec!["val = { g: { oi: { ng: { d: { e: {┃ e: { p: { camelCase: RunTimeError } } } } } } } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ g: { oi: { ng: { d: { e: { e:┃ { p: { camelCase: RunTimeError } } } } } } } }"],
|
ovec!["val = { g: { oi: { ng: { d: { e: { e:┃ { p: { camelCase: RunTimeError } } } } } } } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{┃ g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeError } } } } } } } }"],
|
ovec!["val = {┃ g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeError } } } } } } } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["┃{ g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeError } } } } } } } }"],
|
ovec!["val = ┃{ g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeError } } } } } } } }"],
|
||||||
IGNORE_NO_LTR,
|
IGNORE_NO_LTR,
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_ignore_nls(
|
||||||
ovec!["{ ┃g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeError } } } } } } } }"],
|
ovec!["val = { ┃g: { oi: { ng: { d: { e: { e: { p: { camelCase: RunTimeError } } } } } } } }"],
|
||||||
"2",
|
"2",
|
||||||
)?;*/
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_single_elt_list() -> Result<(), String> {
|
fn test_single_elt_list() -> Result<(), String> {
|
||||||
/*YOLOassert_insert( ovec!["[ ┃ ]"], '[')?;
|
assert_insert_in_def( ovec!["[ ┃ ]"], '[')?;
|
||||||
|
|
||||||
assert_insert_seq( ovec!["[ 0┃ ]"], "[0")?;
|
assert_insert_nls( ovec!["val = [ ┃ ]"], ovec!["val = [ 0┃ ]"], '0')?;
|
||||||
assert_insert_seq( ovec!["[ 1┃ ]"], "[1")?;
|
assert_insert_nls( ovec!["val = [ ┃ ]"], ovec!["val = [ 1┃ ]"], '1')?;
|
||||||
assert_insert_seq( ovec!["[ 9┃ ]"], "[9")?;
|
assert_insert_nls( ovec!["val = [ ┃ ]"], ovec!["val = [ 9┃ ]"], '9')?;
|
||||||
|
|
||||||
assert_insert_seq( ovec!["[ \"┃\" ]"], "[\"")?;
|
assert_insert_nls( ovec!["val = [ ┃ ]"], ovec!["val = [ \"┃\" ]"], '\"')?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_nls(
|
||||||
ovec!["┃"],
|
ovec!["val = [ ┃ ]"],
|
||||||
ovec!["[ \"hello, hello.0123456789ZXY{}[]-><-┃\" ]"],
|
ovec!["val = [ \"hello, hello.0123456789ZXY{}[]-><-┃\" ]"],
|
||||||
"[\"hello, hello.0123456789ZXY{}[]-><-",
|
"\"hello, hello.0123456789ZXY{}[]-><-",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_insert_seq( ovec!["[ { ┃ } ]"], "[{")?;
|
assert_insert_nls( ovec!["val = [ ┃ ]"], ovec!["val = [ { ┃ } ]"], '{')?;
|
||||||
assert_insert_seq( ovec!["[ { a┃ } ]"], "[{a")?;
|
assert_insert_seq_nls( ovec!["val = [ ┃ ]"], ovec!["val = [ { a┃ } ]"], "{a")?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_nls(
|
||||||
ovec!["┃"],
|
ovec!["val = [ ┃ ]"],
|
||||||
ovec!["[ { camelCase: { zulu: \"nested┃\" } } ]"],
|
ovec!["val = [ { camelCase: { zulu: \"nested┃\" } } ]"],
|
||||||
"[{camelCase:{zulu:\"nested",
|
"{camelCase:{zulu:\"nested",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_insert_seq( ovec!["[ [ ┃ ] ]"], "[[")?;
|
assert_insert_nls( ovec!["val = [ ┃ ]"], ovec!["val = [ [ ┃ ] ]"], '[')?;
|
||||||
assert_insert_seq( ovec!["[ [ [ ┃ ] ] ]"], "[[[")?;
|
assert_insert_seq_nls( ovec!["val = [ ┃ ]"],ovec!["val = [ [ [ ┃ ] ] ]"], "[[")?;
|
||||||
assert_insert_seq( ovec!["[ [ 0┃ ] ]"], "[[0")?;
|
assert_insert_seq_nls( ovec!["val = [ ┃ ]"],ovec!["val = [ [ 0┃ ] ]"], "[0")?;
|
||||||
assert_insert_seq( ovec!["[ [ \"abc┃\" ] ]"], "[[\"abc")?;
|
assert_insert_seq_nls( ovec!["val = [ ┃ ]"],ovec!["val = [ [ \"abc┃\" ] ]"], "[\"abc")?;
|
||||||
assert_insert_seq(
|
assert_insert_seq_nls(
|
||||||
ovec!["┃"],
|
ovec!["val = [ ┃ ]"],
|
||||||
ovec!["[ [ { camelCase: { a: 79000┃ } } ] ]"],
|
ovec!["val = [ [ { camelCase: { a: 79000┃ } } ] ]"],
|
||||||
"[[{camelCase:{a:79000",
|
"[{camelCase:{a:79000",
|
||||||
)?;*/
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub fn update_invalid_lookup(
|
||||||
input_str: &str,
|
input_str: &str,
|
||||||
old_pool_str: &PoolStr,
|
old_pool_str: &PoolStr,
|
||||||
curr_mark_node_id: MarkNodeId,
|
curr_mark_node_id: MarkNodeId,
|
||||||
ast_node_id: ExprId,
|
expr_id: ExprId,
|
||||||
ed_model: &mut EdModel,
|
ed_model: &mut EdModel,
|
||||||
) -> EdResult<InputOutcome> {
|
) -> EdResult<InputOutcome> {
|
||||||
if input_str.chars().all(|ch| ch.is_ascii_alphanumeric()) {
|
if input_str.chars().all(|ch| ch.is_ascii_alphanumeric()) {
|
||||||
|
@ -32,7 +32,7 @@ pub fn update_invalid_lookup(
|
||||||
.module
|
.module
|
||||||
.env
|
.env
|
||||||
.pool
|
.pool
|
||||||
.set(ast_node_id, Expr2::InvalidLookup(new_pool_str));
|
.set(expr_id, Expr2::InvalidLookup(new_pool_str));
|
||||||
|
|
||||||
// update MarkupNode
|
// update MarkupNode
|
||||||
let curr_mark_node_mut = ed_model.mark_node_pool.get_mut(curr_mark_node_id);
|
let curr_mark_node_mut = ed_model.mark_node_pool.get_mut(curr_mark_node_id);
|
||||||
|
|
|
@ -182,14 +182,17 @@ pub fn update_record_colon(
|
||||||
if let Some(prev_mark_node_id) = prev_mark_node_id_opt {
|
if let Some(prev_mark_node_id) = prev_mark_node_id_opt {
|
||||||
let prev_mark_node = ed_model.mark_node_pool.get(prev_mark_node_id);
|
let prev_mark_node = ed_model.mark_node_pool.get(prev_mark_node_id);
|
||||||
|
|
||||||
let prev_ast_node = ed_model
|
match prev_mark_node.get_ast_node_id() {
|
||||||
|
ASTNodeId::ADefId(_) => Ok(InputOutcome::Ignored),
|
||||||
|
ASTNodeId::AExprId(prev_expr_id) => {
|
||||||
|
let prev_expr = ed_model
|
||||||
.module
|
.module
|
||||||
.env
|
.env
|
||||||
.pool
|
.pool
|
||||||
.get(prev_mark_node.get_ast_node_id().to_expr_id()?);
|
.get(prev_expr_id);
|
||||||
|
|
||||||
// current and prev node should always point to record when in valid position to add ':'
|
// current and prev node should always point to record when in valid position to add ':'
|
||||||
if matches!(prev_ast_node, Expr2::Record { .. })
|
if matches!(prev_expr, Expr2::Record { .. })
|
||||||
&& matches!(curr_ast_node, Expr2::Record { .. })
|
&& matches!(curr_ast_node, Expr2::Record { .. })
|
||||||
{
|
{
|
||||||
let sibling_ids = curr_mark_node.get_sibling_ids(&ed_model.mark_node_pool);
|
let sibling_ids = curr_mark_node.get_sibling_ids(&ed_model.mark_node_pool);
|
||||||
|
@ -278,6 +281,8 @@ pub fn update_record_colon(
|
||||||
} else {
|
} else {
|
||||||
Ok(InputOutcome::Ignored)
|
Ok(InputOutcome::Ignored)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(InputOutcome::Ignored)
|
Ok(InputOutcome::Ignored)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue