use crate::pretty_printer::assert_round_trips;
#[test]
fn do_blocks() {
assert_round_trips(
r#"
foo()
do
local bar=baz()
quux()
end
foo2()
"#,
);
}
#[test]
fn nested_do_block() {
assert_round_trips(
r#"
do
do
local x = 1
end
end
"#,
);
}
#[test]
fn emit_a_do_block_in_cases_of_potentially_ambiguous_syntax() {
assert_round_trips(
r#"
f();
(g or f)()
"#,
);
}
#[test]
fn parentheses_multiline() {
assert_round_trips(
r#"
local a = (
b
)
"#,
);
}
#[test]
fn stmt_semicolon() {
assert_round_trips(r" local test = 1; ");
assert_round_trips(r" local test = 1 ; ");
}
#[test]
fn do_block_ending_with_semicolon() {
assert_round_trips(
r#"
do
return;
end;
"#,
);
}
#[test]
fn if_stmt_semicolon() {
assert_round_trips(
r#"
if init then
x = string.sub(x, utf8.offset(x, init));
end;
"#,
);
}
#[test]
fn if_stmt_semicolon_2() {
assert_round_trips(
r#"
if (t < 1) then return c/2*t*t + b end;
"#,
);
}
#[test]
fn for_loop_stmt_semicolon() {
assert_round_trips(
r#"
for i,v in ... do
end;
"#,
);
}
#[test]
fn while_do_semicolon() {
assert_round_trips(
r#"
while true do
end;
"#,
);
}
#[test]
fn function_definition_semicolon() {
assert_round_trips(
r#"
function foo()
end;
"#,
);
}