Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions prqlc/bindings/prqlc-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod test {

assert_snapshot!(
compile("from employees | filter (age | in 20..30)", opts).unwrap(),
@r"
@"
SELECT
*
FROM
Expand All @@ -206,7 +206,7 @@ mod test {

let prql = r#"from artists | select {name, id} | filter (id | in [1, 2, 3])"#;
assert_snapshot!(
prql_to_pl(prql).and_then(|x| pl_to_rq(x.as_str())).and_then(|x|rq_to_sql(x.as_str(), opts)).unwrap(), @r"
prql_to_pl(prql).and_then(|x| pl_to_rq(x.as_str())).and_then(|x|rq_to_sql(x.as_str(), opts)).unwrap(), @"
SELECT
name,
id
Expand All @@ -221,7 +221,7 @@ mod test {
fn prql_pl_prql_roundtrip() {
let prql = r#"from artists | select {name, id} | filter (id | in [1, 2, 3])"#;
assert_snapshot!(
prql_to_pl(prql).and_then(|x| pl_to_prql(x.as_str())).unwrap(), @r"
prql_to_pl(prql).and_then(|x| pl_to_prql(x.as_str())).unwrap(), @"
from artists
select {name, id}
filter (id | in [1, 2, 3])
Expand Down
92 changes: 46 additions & 46 deletions prqlc/prqlc-parser/src/lexer/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn line_wrap() {

// Basic line wrap test
assert_debug_snapshot!(test_line_wrap_tokens(r"5 +
\ 3 "), @r"
\ 3 "), @"
Tokens(
[
0..1: Literal(Integer(5)),
Expand Down Expand Up @@ -77,7 +77,7 @@ fn debug_display() {
Tokens(lexer().parse(input).output().unwrap().to_vec())
}

assert_debug_snapshot!(test_tokens("5 + 3"), @r"
assert_debug_snapshot!(test_tokens("5 + 3"), @"
Tokens(
[
0..1: Literal(Integer(5)),
Expand Down Expand Up @@ -221,7 +221,7 @@ fn range() {
Tokens(lexer().parse(input).output().unwrap().to_vec())
}

assert_debug_snapshot!(test_range_tokens("1..2"), @r"
assert_debug_snapshot!(test_range_tokens("1..2"), @"
Tokens(
[
0..1: Literal(Integer(1)),
Expand All @@ -231,7 +231,7 @@ fn range() {
)
");

assert_debug_snapshot!(test_range_tokens("..2"), @r"
assert_debug_snapshot!(test_range_tokens("..2"), @"
Tokens(
[
0..2: Range { bind_left: true, bind_right: true },
Expand All @@ -240,7 +240,7 @@ fn range() {
)
");

assert_debug_snapshot!(test_range_tokens("1.."), @r"
assert_debug_snapshot!(test_range_tokens("1.."), @"
Tokens(
[
0..1: Literal(Integer(1)),
Expand All @@ -267,7 +267,7 @@ fn range() {
fn test_lex_source() {
use insta::assert_debug_snapshot;

assert_debug_snapshot!(lex_source("5 + 3"), @r"
assert_debug_snapshot!(lex_source("5 + 3"), @"
Ok(
Tokens(
[
Expand All @@ -291,20 +291,20 @@ fn test_annotation_tokens() {
// Test basic annotation token
let result = super::lex_source("@{binding_strength=1}");
assert_debug_snapshot!(result, @r#"
Ok(
Tokens(
[
0..0: Start,
0..1: Annotate,
1..2: Control('{'),
2..18: Ident("binding_strength"),
18..19: Control('='),
19..20: Literal(Integer(1)),
20..21: Control('}'),
],
),
)
"#);
Ok(
Tokens(
[
0..0: Start,
0..1: Annotate,
1..2: Control('{'),
2..18: Ident("binding_strength"),
18..19: Control('='),
19..20: Literal(Integer(1)),
20..21: Control('}'),
],
),
)
"#);

// Test multi-line annotation
let result = super::lex_source(
Expand All @@ -314,32 +314,32 @@ fn test_annotation_tokens() {
"#,
);
assert_debug_snapshot!(result, @r#"
Ok(
Tokens(
[
0..0: Start,
0..1: NewLine,
9..10: Annotate,
10..11: Control('{'),
11..27: Ident("binding_strength"),
27..28: Control('='),
28..29: Literal(Integer(1)),
29..30: Control('}'),
30..31: NewLine,
39..42: Keyword("let"),
43..46: Ident("add"),
47..48: Control('='),
49..50: Ident("a"),
51..52: Ident("b"),
53..55: ArrowThin,
56..57: Ident("a"),
58..59: Control('+'),
60..61: Ident("b"),
61..62: NewLine,
],
),
)
"#);
Ok(
Tokens(
[
0..0: Start,
0..1: NewLine,
9..10: Annotate,
10..11: Control('{'),
11..27: Ident("binding_strength"),
27..28: Control('='),
28..29: Literal(Integer(1)),
29..30: Control('}'),
30..31: NewLine,
39..42: Keyword("let"),
43..46: Ident("add"),
47..48: Control('='),
49..50: Ident("a"),
51..52: Ident("b"),
53..55: ArrowThin,
56..57: Ident("a"),
58..59: Control('+'),
60..61: Ident("b"),
61..62: NewLine,
],
),
)
"#);
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions prqlc/prqlc/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ sort full
"",
);

assert_snapshot!(&result.unwrap_err().to_string(), @r"
assert_snapshot!(&result.unwrap_err().to_string(), @"
Error:
╭─[ :1:1 ]
Expand Down Expand Up @@ -742,7 +742,7 @@ sort full
"main",
)
.unwrap();
assert_snapshot!(String::from_utf8(result).unwrap().trim(), @r"
assert_snapshot!(String::from_utf8(result).unwrap().trim(), @"
WITH x AS (
SELECT
y,
Expand All @@ -769,7 +769,7 @@ sort full
)
.unwrap();

assert_snapshot!(String::from_utf8(output).unwrap().trim(), @r"
assert_snapshot!(String::from_utf8(output).unwrap().trim(), @"
name: Project
stmts:
- VarDef:
Expand Down Expand Up @@ -816,7 +816,7 @@ sort full

// TODO: terser output; maybe serialize span as `0..4`? Remove the
// `!Ident` complication?
assert_snapshot!(String::from_utf8(output).unwrap().trim(), @r"
assert_snapshot!(String::from_utf8(output).unwrap().trim(), @"
- kind: Start
span:
start: 0
Expand Down Expand Up @@ -859,7 +859,7 @@ sort full
)
.unwrap();

assert_snapshot!(String::from_utf8(output).unwrap().trim(), @r"
assert_snapshot!(String::from_utf8(output).unwrap().trim(), @"
- kind: Start
span:
start: 0
Expand Down
22 changes: 11 additions & 11 deletions prqlc/prqlc/src/cli/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use walkdir::WalkDir;
#[cfg(not(windows))] // Windows has slightly different output (e.g. `prqlc.exe`), so we exclude.
#[test]
fn help() {
assert_cmd_snapshot!(prqlc_command().arg("--help"), @r"
assert_cmd_snapshot!(prqlc_command().arg("--help"), @"
success: true
exit_code: 0
----- stdout -----
Expand Down Expand Up @@ -42,7 +42,7 @@ fn help() {
");

// without arguments
assert_cmd_snapshot!(prqlc_command(), @r"
assert_cmd_snapshot!(prqlc_command(), @"
success: true
exit_code: 0
----- stdout -----
Expand Down Expand Up @@ -73,7 +73,7 @@ fn help() {

#[test]
fn get_targets() {
assert_cmd_snapshot!(prqlc_command().arg("list-targets"), @r"
assert_cmd_snapshot!(prqlc_command().arg("list-targets"), @"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -100,7 +100,7 @@ fn get_targets() {
fn compile() {
assert_cmd_snapshot!(prqlc_command()
.args(["compile", "--hide-signature-comment"])
.pass_stdin("from tracks"), @r"
.pass_stdin("from tracks"), @"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -116,7 +116,7 @@ fn compile() {
#[cfg(not(windows))] // Windows has slightly different output (e.g. `prqlc.exe`), so we exclude.
#[test]
fn compile_help() {
assert_cmd_snapshot!(prqlc_command().args(["compile", "--help"]), @r"
assert_cmd_snapshot!(prqlc_command().args(["compile", "--help"]), @"
success: true
exit_code: 0
----- stdout -----
Expand Down Expand Up @@ -194,7 +194,7 @@ let long_query = (
take 20
)
from long_query
"#), @r"
"#), @"
success: true
exit_code: 0
----- stdout -----
Expand Down Expand Up @@ -278,7 +278,7 @@ fn compile_project() {
"main",
]);

assert_cmd_snapshot!(cmd, @r"
assert_cmd_snapshot!(cmd, @"
success: true
exit_code: 0
----- stdout -----
Expand Down Expand Up @@ -332,7 +332,7 @@ fn compile_project() {
project_path().to_str().unwrap(),
"-",
"favorite_artists",
]), @r"
]), @"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -359,7 +359,7 @@ fn compile_project() {
#[test]
fn format() {
// Test stdin formatting
assert_cmd_snapshot!(prqlc_command().args(["fmt"]).pass_stdin("from tracks | take 20"), @r"
assert_cmd_snapshot!(prqlc_command().args(["fmt"]).pass_stdin("from tracks | take 20"), @"
success: true
exit_code: 0
----- stdout -----
Expand Down Expand Up @@ -604,7 +604,7 @@ fn normalize_prqlc(cmd: &mut Command) -> &mut Command {

#[test]
fn compile_no_prql_files() {
assert_cmd_snapshot!(prqlc_command().args(["compile", "README.md"]), @r"
assert_cmd_snapshot!(prqlc_command().args(["compile", "README.md"]), @"
success: false
exit_code: 1
----- stdout -----
Expand All @@ -616,7 +616,7 @@ fn compile_no_prql_files() {

#[test]
fn lex() {
assert_cmd_snapshot!(prqlc_command().args(["lex"]).pass_stdin("from tracks"), @r"
assert_cmd_snapshot!(prqlc_command().args(["lex"]).pass_stdin("from tracks"), @"
success: true
exit_code: 0
----- stdout -----
Expand Down
2 changes: 1 addition & 1 deletion prqlc/prqlc/src/codegen/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ mod test {
exprs: vec![short.clone(), long.clone(), long, short.clone()],
}));
// colons are a workaround to avoid trimming
assert_snapshot!(pipeline.write(opt.clone()).unwrap(), @r"
assert_snapshot!(pipeline.write(opt.clone()).unwrap(), @"
(
short
some_really_long_and_really_long_name
Expand Down
2 changes: 1 addition & 1 deletion prqlc/prqlc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ mod tests {

#[test]
fn test_target_from_str() {
assert_debug_snapshot!(Target::from_str("sql.postgres"), @r"
assert_debug_snapshot!(Target::from_str("sql.postgres"), @"
Ok(
Sql(
Some(
Expand Down
8 changes: 4 additions & 4 deletions prqlc/prqlc/src/semantic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub mod test {
window range:-4..4 (
derive {next_four_days = sum b}
)
"###).unwrap().relation.columns, @r"
"###).unwrap().relation.columns, @"
- Single: day
- Single: b
- Wildcard
Expand All @@ -205,7 +205,7 @@ pub mod test {
from a=albums
filter is_sponsored
select {a.*}
"###).unwrap().relation.columns, @r"
"###).unwrap().relation.columns, @"
- Single: is_sponsored
- Wildcard
")
Expand All @@ -216,7 +216,7 @@ pub mod test {
assert_yaml_snapshot!(parse_resolve_and_lower(r###"
from x
select {a, a, a = a + 1}
"###).unwrap().relation.columns, @r"
"###).unwrap().relation.columns, @"
- Single: ~
- Single: ~
- Single: a
Expand All @@ -229,7 +229,7 @@ pub mod test {
prql target:sql.mssql version:"0"

from employees
"#).unwrap(), @r"
"#).unwrap(), @"
def:
version: ^0
other:
Expand Down
4 changes: 2 additions & 2 deletions prqlc/prqlc/src/semantic/resolver/transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ mod tests {
group invoice_no (
take 1
)
").unwrap(), @r"
").unwrap(), @"
def:
version: ~
other: {}
Expand Down Expand Up @@ -1271,7 +1271,7 @@ mod tests {
sort (-issued_at)
sort {issued_at}
sort {-issued_at}
").unwrap(), @r"
").unwrap(), @"
def:
version: ~
other: {}
Expand Down
Loading
Loading