luau-syntax 0.732.0

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

// PrettyPrinter.test.cpp: string_literals
#[test]
fn string_literals() {
    assert_round_trips(r" local S='abcdef\n\f\a\020' ");
}

// PrettyPrinter.test.cpp: string_literals_containing_utf8
#[test]
fn string_literals_containing_utf8() {
    assert_round_trips(" local S='lalala こんにちは' ");
}

// PrettyPrinter.test.cpp: single_quoted_strings
#[test]
fn single_quoted_strings() {
    assert_round_trips(r" local a = 'hello world' ");
}

// PrettyPrinter.test.cpp: double_quoted_strings
#[test]
fn double_quoted_strings() {
    assert_round_trips(r#" local a = "hello world" "#);
}

// PrettyPrinter.test.cpp: simple_interp_string
#[test]
fn simple_interp_string() {
    assert_round_trips(r" local a = `hello world` ");
}

// PrettyPrinter.test.cpp: raw_strings
#[test]
fn raw_strings() {
    assert_round_trips(r" local a = [[ hello world ]] ");
}

// PrettyPrinter.test.cpp: raw_strings_with_blocks
#[test]
fn raw_strings_with_blocks() {
    assert_round_trips(r" local a = [==[ hello world ]==] ");
}

// PrettyPrinter.test.cpp: escaped_strings
#[test]
fn escaped_strings() {
    assert_round_trips(r" local s='\\b\\t\\n\\\\' ");
}

// PrettyPrinter.test.cpp: escaped_strings_2
#[test]
fn escaped_strings_2() {
    assert_round_trips(r#" local s="\a\b\f\n\r\t\v\'\"\\" "#);
}

// PrettyPrinter.test.cpp: escaped_strings_newline
#[test]
fn escaped_strings_newline() {
    assert_round_trips(
        r#"
    print("foo \
        bar")
    "#,
    );
}

// PrettyPrinter.test.cpp: escaped_strings_raw
#[test]
fn escaped_strings_raw() {
    assert_round_trips(r#" local x = [=[\v<((do|load)file|require)\s*\(?['"]\zs[^'"]+\ze['"]]=] "#);
}

// PrettyPrinter.test.cpp: prettyPrint_string_interp
#[test]
fn pretty_print_string_interp() {
    assert_round_trips_with_types(r" local _ = `hello {name}` ");
}

// PrettyPrinter.test.cpp: prettyPrint_string_interp_multiline
#[test]
fn pretty_print_string_interp_multiline() {
    assert_round_trips_with_types(
        r#" local _ = `hello {
        name
    }!` "#,
    );
}

// PrettyPrinter.test.cpp: prettyPrint_string_interp_on_new_line
#[test]
fn pretty_print_string_interp_on_new_line() {
    assert_round_trips_with_types(
        r#"
        error(
            `a {b} c`
        )
    "#,
    );
}

// PrettyPrinter.test.cpp: prettyPrint_string_interp_multiline_escape
#[test]
fn pretty_print_string_interp_multiline_escape() {
    assert_round_trips_with_types(
        r#" local _ = `hello \
        world!` "#,
    );
}

// PrettyPrinter.test.cpp: prettyPrint_string_literal_escape
#[test]
fn pretty_print_string_literal_escape() {
    assert_round_trips_with_types(r#" local _ = ` bracket = \{, backtick = \` = {'ok'} ` "#);
}

// PrettyPrinter.test.cpp: prettyPrint_single_quoted_string_types
#[test]
fn pretty_print_single_quoted_string_types() {
    assert_round_trips_with_types(r" type a = 'hello world' ");
}

// PrettyPrinter.test.cpp: prettyPrint_double_quoted_string_types
#[test]
fn pretty_print_double_quoted_string_types() {
    assert_round_trips_with_types(r#" type a = "hello world" "#);
}

// PrettyPrinter.test.cpp: prettyPrint_raw_string_types
#[test]
fn pretty_print_raw_string_types() {
    assert_round_trips_with_types(r" type a = [[ hello world ]] ");
    assert_round_trips_with_types(r" type a = [==[ hello world ]==] ");
}

// PrettyPrinter.test.cpp: prettyPrint_escaped_string_types
#[test]
fn pretty_print_escaped_string_types() {
    assert_round_trips_with_types(r#" type a = "\\b\\t\\n\\\\" "#);
}