Skip to content

Commit e0b484e

Browse files
committed
Expand test example to assert AST
1 parent 648c024 commit e0b484e

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

tests/sqlparser_mssql.rs

+36-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
mod test_utils;
2424

2525
use helpers::attached_token::AttachedToken;
26-
use sqlparser::tokenizer::{Location, Span};
26+
use sqlparser::keywords::Keyword;
27+
use sqlparser::tokenizer::{Location, Span, Token, TokenWithSpan, Word};
2728
use test_utils::*;
2829

2930
use sqlparser::ast::DataType::{Int, Text, Varbinary};
@@ -1419,7 +1420,40 @@ fn test_mssql_cursor() {
14191420
#[test]
14201421
fn test_mssql_while_statement() {
14211422
let while_single_statement = "WHILE 1 = 0 PRINT 'Hello World';";
1422-
let _ = ms().verified_stmt(while_single_statement);
1423+
let stmt = ms().verified_stmt(while_single_statement);
1424+
assert_eq!(
1425+
stmt,
1426+
Statement::While(sqlparser::ast::WhileStatement {
1427+
while_block: ConditionalStatementBlock {
1428+
start_token: AttachedToken(TokenWithSpan {
1429+
token: Token::Word(Word {
1430+
value: "WHILE".to_string(),
1431+
quote_style: None,
1432+
keyword: Keyword::WHILE
1433+
}),
1434+
span: Span::empty()
1435+
}),
1436+
condition: Some(Expr::BinaryOp {
1437+
left: Box::new(Expr::Value(
1438+
(Value::Number("1".to_string(), false)).with_empty_span()
1439+
)),
1440+
op: BinaryOperator::Eq,
1441+
right: Box::new(Expr::Value(
1442+
(Value::Number("0".to_string(), false)).with_empty_span()
1443+
)),
1444+
}),
1445+
then_token: None,
1446+
conditional_statements: ConditionalStatements::Sequence {
1447+
statements: vec![Statement::Print(PrintStatement {
1448+
message: Box::new(Expr::Value(
1449+
(Value::SingleQuotedString("Hello World".to_string()))
1450+
.with_empty_span()
1451+
)),
1452+
}),],
1453+
}
1454+
}
1455+
})
1456+
);
14231457

14241458
let while_begin_end = "\
14251459
WHILE @@FETCH_STATUS = 0 \

0 commit comments

Comments
 (0)