#[cfg(test)]
mod tests {
use crate::*;
#[test]
fn tab_basic() {
let source = r#"
Sub Test()
Print Tab(10); "Hello"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_print_to_file() {
let source = r#"
Sub Test()
Print #1, Tab(20); "World"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_omitted_column() {
let source = r#"
Sub Test()
Print Tab; "Next zone"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_multiple_columns() {
let source = r#"
Sub Test()
Print Tab(5); "A"; Tab(15); "B"; Tab(25); "C"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_table_header() {
let source = r#"
Sub Test()
Print Tab(1); "ID"; Tab(10); "Name"; Tab(30); "Score"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_data_rows() {
let source = r"
Sub Test()
For i = 1 To 10
Print Tab(1); i; Tab(10); names(i); Tab(30); scores(i)
Next i
End Sub
";
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_with_spc() {
let source = r#"
Sub Test()
Print Tab(10); Spc(5); "Data"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_debug_print() {
let source = r#"
Sub Test()
Debug.Print Tab(15); "Debug info"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_print_to_file_2() {
let source = r#"
Sub Test()
Print #1, Tab(8); "File data"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_omitted_column_2() {
let source = r#"
Sub Test()
Print Tab; "Default zone"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_calculated_column() {
let source = r#"
Sub Test()
Print Tab(i * 5); "Value"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_with_variable() {
let source = r#"
Sub Test()
col = 12
Print Tab(col); "Text"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_multiple_tab_calls() {
let source = r#"
Sub Test()
Print Tab(5); "A"; Tab(15); "B"; Tab(25); "C"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_with_tab_and_spc() {
let source = r#"
Sub Test()
Print Tab(10); Spc(3); "Mix"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_formatted_report() {
let source = r#"
Sub Test()
Print Tab(1); "Header1"; Tab(20); "Header2"
For i = 1 To 5
Print Tab(1); data1(i); Tab(20); data2(i)
Next i
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_dynamic_columns() {
let source = r#"
Sub Test()
For i = 1 To 3
Print #1, Tab(i * 10); "Col" & i
Next i
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_omitted_column_loop() {
let source = r#"
Sub Test()
For i = 1 To 3
Print Tab; "Row" & i
Next i
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
#[test]
fn tab_alignment() {
let source = r#"
Sub Test()
Print Tab(10); Spc(2); "Aligned"
End Sub
"#;
let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
let cst = cst_opt.expect("CST should be parsed");
let tree = cst.to_serializable();
let mut settings = insta::Settings::clone_current();
settings
.set_snapshot_path("../../../../../snapshots/syntax/library/functions/graphics/tab");
settings.set_prepend_module_to_snapshot(false);
let _guard = settings.bind_to_scope();
insta::assert_yaml_snapshot!(tree);
}
}