luau-syntax 0.732.0

Luau lexer, parser, AST, CST, and source utilities
Documentation
use crate::pretty_printer::assert_round_trips;

// PrettyPrinter.test.cpp: do_blocks
#[test]
fn do_blocks() {
    assert_round_trips(
        r#"
        foo()

        do
            local bar=baz()
            quux()
        end

        foo2()
    "#,
    );
}

// PrettyPrinter.test.cpp: nested_do_block
#[test]
fn nested_do_block() {
    assert_round_trips(
        r#"
        do
            do
                local x = 1
            end
        end
    "#,
    );
}

// PrettyPrinter.test.cpp: emit_a_do_block_in_cases_of_potentially_ambiguous_syntax
#[test]
fn emit_a_do_block_in_cases_of_potentially_ambiguous_syntax() {
    assert_round_trips(
        r#"
        f();
        (g or f)()
"#,
    );
}

// PrettyPrinter.test.cpp: parentheses_multiline
#[test]
fn parentheses_multiline() {
    assert_round_trips(
        r#"
local a = (
    b
)
"#,
    );
}

// PrettyPrinter.test.cpp: stmt_semicolon
#[test]
fn stmt_semicolon() {
    assert_round_trips(r" local test = 1; ");
    assert_round_trips(r" local test = 1  ; ");
}

// PrettyPrinter.test.cpp: do_block_ending_with_semicolon
#[test]
fn do_block_ending_with_semicolon() {
    assert_round_trips(
        r#"
        do
            return;
        end;
    "#,
    );
}

// PrettyPrinter.test.cpp: if_stmt_semicolon
#[test]
fn if_stmt_semicolon() {
    assert_round_trips(
        r#"
        if init then
            x = string.sub(x, utf8.offset(x, init));
        end;
    "#,
    );
}

// PrettyPrinter.test.cpp: if_stmt_semicolon_2
#[test]
fn if_stmt_semicolon_2() {
    assert_round_trips(
        r#"
        if (t < 1) then return c/2*t*t + b end;
    "#,
    );
}

// PrettyPrinter.test.cpp: for_loop_stmt_semicolon
#[test]
fn for_loop_stmt_semicolon() {
    assert_round_trips(
        r#"
        for i,v in ... do
        end;
    "#,
    );
}

// PrettyPrinter.test.cpp: while_do_semicolon
#[test]
fn while_do_semicolon() {
    assert_round_trips(
        r#"
        while true do
        end;
    "#,
    );
}

// PrettyPrinter.test.cpp: function_definition_semicolon
#[test]
fn function_definition_semicolon() {
    assert_round_trips(
        r#"
        function foo()
        end;
    "#,
    );
}