6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 05:53:06 +01:00
firebird-qa/tests/functional/gtcs/test_parser_comments_in_sql.py

116 lines
1.9 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-02-04 19:05:19 +01:00
"""
ID: gtcs.parser-comments-in-sql
TITLE: Check for problems with comments (single-line and multi-line)
DESCRIPTION:
::: NB :::
### Name of original test has no any relation with actual task of this test: ###
https://github.com/FirebirdSQL/fbtcs/blob/master/GTCS/tests/CF_ISQL_19.script
bug #781610 problems with one line comments (--)
FBTEST: functional.gtcs.parser_comments_in_sql
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set heading off;
create table test (n integer);
insert into test values (1);
-- I am a comment
/* BEGIN */
-- I am a comment
select * from test;
/* END */
/* BEGIN */
-- comment with unclosed 'quoted string
select * from test;
/* END */
/* BEGIN */
-- comment with unclosed "quoted string
select * from test;
/* END */
/* BEGIN */
-- I am a comment;
select * from test;
/* END */
/* BEGIN with unclosed "quoted */
-- I am a comment;
select * from test;
/* END */
select * /*
comment
*/
from test;
2022-02-04 19:05:19 +01:00
select *
2021-04-26 20:07:00 +02:00
/* comment */
from test;
2022-02-04 19:05:19 +01:00
select *
2021-04-26 20:07:00 +02:00
-- comment
from test;
/*
Comment
*/ select * from test;
-- Added 18.03.2020
--#################
-- single-line comment '*/
select * from test;
-- single-line comment --*/
select * from test;
2022-02-04 19:05:19 +01:00
/* * / / * q'{
2021-04-26 20:07:00 +02:00
BEGIN multi-line comment-1
'*/
select * from test;
/* '' BEGIN multi-line comment-2
'* / / * */
select * from test;
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
act = isql_act('db', test_script, substitutions=[('=', ''), ('[ \t]+', ' ')])
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
1
1
1
1
1
1
1
1
1
1
1
1
1
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout