Skip to content

Commit

Permalink
Add MultiStringParser simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
judahrand committed Jun 29, 2022
1 parent db03a79 commit 94e3aa8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/core/parser/parser_test.py
@@ -0,0 +1,28 @@
"""The Test file for Parsers (Matchable Classes)."""

from sqlfluff.core.parser import (
KeywordSegment,
MultiStringParser,
)
from sqlfluff.core.parser.context import RootParseContext


def test__parser__multistringparser_match(generate_test_segments):
"""Test the MultiStringParser matchable."""
parser = MultiStringParser(["foo", "bar"], KeywordSegment)
with RootParseContext(dialect=None) as ctx:
# Check directly
seg_list = generate_test_segments(["foo", "fo"])
# Matches when it should
assert parser.match(seg_list[:1], parse_context=ctx).matched_segments == (
KeywordSegment("foo", seg_list[0].pos_marker),
)
# Doesn't match when it shouldn't
assert parser.match(seg_list[1:], parse_context=ctx).matched_segments == tuple()


def test__parser__multistringparser_simple():
"""Test the MultiStringParser matchable."""
parser = MultiStringParser(["foo", "bar"], KeywordSegment)
with RootParseContext(dialect=None) as ctx:
assert parser.simple(ctx)

0 comments on commit 94e3aa8

Please sign in to comment.