Rewrite syntax tests
Use matchers from hamcrest instead of eq_ assertions in syntax tests to get more detailed assertion errors when tests are failing.
This commit is contained in:
parent
9968a43f7e
commit
f14485acb9
@ -27,8 +27,7 @@ from ycm.test_utils import MockVimModule
|
|||||||
MockVimModule()
|
MockVimModule()
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from nose.tools import eq_
|
from hamcrest import assert_that, contains_inanyorder, has_item, has_items
|
||||||
from hamcrest import assert_that, has_items
|
|
||||||
from ycm import syntax_parse
|
from ycm import syntax_parse
|
||||||
from ycmd.utils import ReadFile
|
from ycmd.utils import ReadFile
|
||||||
|
|
||||||
@ -39,101 +38,100 @@ def ContentsOfTestFile( test_file ):
|
|||||||
return ReadFile( full_path_to_test_file )
|
return ReadFile( full_path_to_test_file )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_PythonSyntax_test():
|
def KeywordsFromSyntaxListOutput_PythonSyntax_test():
|
||||||
eq_( set(['bytearray', 'IndexError', 'all', 'help', 'vars',
|
expected_keywords = (
|
||||||
'SyntaxError', 'global', 'elif', 'unicode', 'sorted', 'memoryview',
|
'bytearray', 'IndexError', 'all', 'help', 'vars', 'SyntaxError', 'global',
|
||||||
'isinstance', 'except', 'nonlocal', 'NameError', 'finally',
|
'elif', 'unicode', 'sorted', 'memoryview', 'isinstance', 'except',
|
||||||
'BytesWarning', 'dict', 'IOError', 'pass', 'oct', 'match', 'bin',
|
'nonlocal', 'NameError', 'finally', 'BytesWarning', 'dict', 'IOError',
|
||||||
'SystemExit', 'return', 'StandardError', 'format', 'TabError',
|
'pass', 'oct', 'match', 'bin', 'SystemExit', 'return', 'StandardError',
|
||||||
'break', 'next', 'not', 'UnicodeDecodeError', 'False',
|
'format', 'TabError', 'break', 'next', 'not', 'UnicodeDecodeError',
|
||||||
'RuntimeWarning', 'list', 'iter', 'try', 'reload', 'Warning',
|
'False', 'RuntimeWarning', 'list', 'iter', 'try', 'reload', 'Warning',
|
||||||
'round', 'dir', 'cmp', 'set', 'bytes', 'UnicodeTranslateError',
|
'round', 'dir', 'cmp', 'set', 'bytes', 'UnicodeTranslateError', 'intern',
|
||||||
'intern', 'issubclass', 'yield', 'Ellipsis', 'hash', 'locals',
|
'issubclass', 'yield', 'Ellipsis', 'hash', 'locals', 'BufferError',
|
||||||
'BufferError', 'slice', 'for', 'FloatingPointError', 'sum',
|
'slice', 'for', 'FloatingPointError', 'sum', 'VMSError', 'getattr', 'abs',
|
||||||
'VMSError', 'getattr', 'abs', 'print', 'import', 'True',
|
'print', 'import', 'True', 'FutureWarning', 'ImportWarning', 'None',
|
||||||
'FutureWarning', 'ImportWarning', 'None', 'EOFError', 'len',
|
'EOFError', 'len', 'frozenset', 'ord', 'super', 'raise', 'TypeError',
|
||||||
'frozenset', 'ord', 'super', 'raise', 'TypeError',
|
'KeyboardInterrupt', 'UserWarning', 'filter', 'range', 'staticmethod',
|
||||||
'KeyboardInterrupt', 'UserWarning', 'filter', 'range',
|
'SystemError', 'or', 'BaseException', 'pow', 'RuntimeError', 'float',
|
||||||
'staticmethod', 'SystemError', 'or', 'BaseException', 'pow',
|
'MemoryError', 'StopIteration', 'globals', 'divmod', 'enumerate', 'apply',
|
||||||
'RuntimeError', 'float', 'MemoryError', 'StopIteration', 'globals',
|
'LookupError', 'open', 'basestring', 'from', 'UnicodeError', 'zip', 'hex',
|
||||||
'divmod', 'enumerate', 'apply', 'LookupError', 'open', 'basestring',
|
'long', 'IndentationError', 'int', 'chr', '__import__', 'type',
|
||||||
'from', 'UnicodeError', 'zip', 'hex', 'long', 'IndentationError',
|
'Exception', 'continue', 'tuple', 'reduce', 'reversed', 'else', 'assert',
|
||||||
'int', 'chr', '__import__', 'type', 'Exception', 'continue',
|
'UnicodeEncodeError', 'input', 'with', 'hasattr', 'delattr', 'setattr',
|
||||||
'tuple', 'reduce', 'reversed', 'else', 'assert',
|
'raw_input', 'PendingDeprecationWarning', 'compile', 'ArithmeticError',
|
||||||
'UnicodeEncodeError', 'input', 'with', 'hasattr', 'delattr',
|
'while', 'del', 'str', 'property', 'def', 'and', 'GeneratorExit',
|
||||||
'setattr', 'raw_input', 'PendingDeprecationWarning', 'compile',
|
'ImportError', 'xrange', 'is', 'EnvironmentError', 'KeyError', 'coerce',
|
||||||
'ArithmeticError', 'while', 'del', 'str', 'property', 'def', 'and',
|
'SyntaxWarning', 'file', 'in', 'unichr', 'ascii', 'any', 'as', 'if',
|
||||||
'GeneratorExit', 'ImportError', 'xrange', 'is', 'EnvironmentError',
|
'OSError', 'DeprecationWarning', 'min', 'UnicodeWarning', 'execfile', 'id',
|
||||||
'KeyError', 'coerce', 'SyntaxWarning', 'file', 'in', 'unichr',
|
'complex', 'bool', 'ValueError', 'NotImplemented', 'map', 'exec', 'buffer',
|
||||||
'ascii', 'any', 'as', 'if', 'OSError', 'DeprecationWarning', 'min',
|
'max', 'class', 'object', 'repr', 'callable', 'ZeroDivisionError', 'eval',
|
||||||
'UnicodeWarning', 'execfile', 'id', 'complex', 'bool', 'ValueError',
|
'__debug__', 'ReferenceError', 'AssertionError', 'classmethod',
|
||||||
'NotImplemented', 'map', 'exec', 'buffer', 'max', 'class', 'object',
|
'UnboundLocalError', 'NotImplementedError', 'lambda', 'AttributeError',
|
||||||
'repr', 'callable', 'ZeroDivisionError', 'eval', '__debug__',
|
'OverflowError', 'WindowsError' )
|
||||||
'ReferenceError', 'AssertionError', 'classmethod',
|
|
||||||
'UnboundLocalError', 'NotImplementedError', 'lambda',
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput(
|
||||||
'AttributeError', 'OverflowError', 'WindowsError'] ),
|
ContentsOfTestFile( 'python_syntax' ) ),
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput(
|
contains_inanyorder( *expected_keywords ) )
|
||||||
ContentsOfTestFile( 'python_syntax' ) ) )
|
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_CppSyntax_test():
|
def KeywordsFromSyntaxListOutput_CppSyntax_test():
|
||||||
eq_( set(['int_fast32_t', 'FILE', 'size_t', 'bitor', 'typedef', 'const',
|
expected_keywords = (
|
||||||
'struct', 'uint8_t', 'fpos_t', 'thread_local', 'unsigned',
|
'int_fast32_t', 'FILE', 'size_t', 'bitor', 'typedef', 'const', 'struct',
|
||||||
'uint_least16_t', 'match', 'do', 'intptr_t', 'uint_least64_t',
|
'uint8_t', 'fpos_t', 'thread_local', 'unsigned', 'uint_least16_t', 'match',
|
||||||
'return', 'auto', 'void', '_Complex', 'break', '_Alignof', 'not',
|
'do', 'intptr_t', 'uint_least64_t', 'return', 'auto', 'void', '_Complex',
|
||||||
'using', '_Static_assert', '_Thread_local', 'public',
|
'break', '_Alignof', 'not', 'using', '_Static_assert', '_Thread_local',
|
||||||
'uint_fast16_t', 'this', 'continue', 'char32_t', 'int16_t',
|
'public', 'uint_fast16_t', 'this', 'continue', 'char32_t', 'int16_t',
|
||||||
'intmax_t', 'static', 'clock_t', 'sizeof', 'int_fast64_t',
|
'intmax_t', 'static', 'clock_t', 'sizeof', 'int_fast64_t', 'mbstate_t',
|
||||||
'mbstate_t', 'try', 'xor', 'uint_fast32_t', 'int_least8_t', 'div_t',
|
'try', 'xor', 'uint_fast32_t', 'int_least8_t', 'div_t', 'volatile',
|
||||||
'volatile', 'template', 'char16_t', 'new', 'ldiv_t',
|
'template', 'char16_t', 'new', 'ldiv_t', 'int_least16_t', 'va_list',
|
||||||
'int_least16_t', 'va_list', 'uint_least8_t', 'goto', 'noreturn',
|
'uint_least8_t', 'goto', 'noreturn', 'enum', 'static_assert', 'bitand',
|
||||||
'enum', 'static_assert', 'bitand', 'compl', 'imaginary', 'jmp_buf',
|
'compl', 'imaginary', 'jmp_buf', 'throw', 'asm', 'ptrdiff_t', 'uint16_t',
|
||||||
'throw', 'asm', 'ptrdiff_t', 'uint16_t', 'or', 'uint_fast8_t',
|
'or', 'uint_fast8_t', '_Bool', 'int32_t', 'float', 'private', 'restrict',
|
||||||
'_Bool', 'int32_t', 'float', 'private', 'restrict', 'wint_t',
|
'wint_t', 'operator', 'not_eq', '_Imaginary', 'alignas', 'union', 'long',
|
||||||
'operator', 'not_eq', '_Imaginary', 'alignas', 'union', 'long',
|
'uint_least32_t', 'int_least64_t', 'friend', 'uintptr_t', 'int8_t', 'else',
|
||||||
'uint_least32_t', 'int_least64_t', 'friend', 'uintptr_t', 'int8_t',
|
'export', 'int_fast8_t', 'catch', 'true', 'case', 'default', 'double',
|
||||||
'else', 'export', 'int_fast8_t', 'catch', 'true', 'case', 'default',
|
'_Noreturn', 'signed', 'typename', 'while', 'protected', 'wchar_t',
|
||||||
'double', '_Noreturn', 'signed', 'typename', 'while', 'protected',
|
'wctrans_t', 'uint64_t', 'delete', 'and', 'register', 'false', 'int',
|
||||||
'wchar_t', 'wctrans_t', 'uint64_t', 'delete', 'and', 'register',
|
'uintmax_t', 'off_t', 'char', 'int64_t', 'int_fast16_t', 'DIR', '_Atomic',
|
||||||
'false', 'int', 'uintmax_t', 'off_t', 'char', 'int64_t',
|
'time_t', 'xor_eq', 'namespace', 'virtual', 'complex', 'bool', 'mutable',
|
||||||
'int_fast16_t', 'DIR', '_Atomic', 'time_t', 'xor_eq', 'namespace',
|
'if', 'int_least32_t', 'sig_atomic_t', 'and_eq', 'ssize_t', 'alignof',
|
||||||
'virtual', 'complex', 'bool', 'mutable', 'if', 'int_least32_t',
|
'_Alignas', '_Generic', 'extern', 'class', 'typeid', 'short', 'for',
|
||||||
'sig_atomic_t', 'and_eq', 'ssize_t', 'alignof', '_Alignas',
|
'uint_fast64_t', 'wctype_t', 'explicit', 'or_eq', 'switch', 'uint32_t',
|
||||||
'_Generic', 'extern', 'class', 'typeid', 'short', 'for',
|
'inline' )
|
||||||
'uint_fast64_t', 'wctype_t', 'explicit', 'or_eq', 'switch',
|
|
||||||
'uint32_t', 'inline']),
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput(
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput(
|
ContentsOfTestFile( 'cpp_syntax' ) ),
|
||||||
ContentsOfTestFile( 'cpp_syntax' ) ) )
|
contains_inanyorder( *expected_keywords ) )
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_JavaSyntax_test():
|
def KeywordsFromSyntaxListOutput_JavaSyntax_test():
|
||||||
eq_( set(['code', 'text', 'cols', 'datetime', 'disabled', 'shape', 'codetype',
|
expected_keywords = (
|
||||||
'alt', 'compact', 'style', 'valuetype', 'short', 'finally',
|
'code', 'text', 'cols', 'datetime', 'disabled', 'shape', 'codetype', 'alt',
|
||||||
'continue', 'extends', 'valign', 'match', 'bordercolor', 'do',
|
'compact', 'style', 'valuetype', 'short', 'finally', 'continue', 'extends',
|
||||||
'return', 'rel', 'rules', 'void', 'nohref', 'abbr', 'background',
|
'valign', 'match', 'bordercolor', 'do', 'return', 'rel', 'rules', 'void',
|
||||||
'scrolling', 'instanceof', 'name', 'summary', 'try', 'default',
|
'nohref', 'abbr', 'background', 'scrolling', 'instanceof', 'name',
|
||||||
'noshade', 'coords', 'dir', 'frame', 'usemap', 'ismap', 'static',
|
'summary', 'try', 'default', 'noshade', 'coords', 'dir', 'frame', 'usemap',
|
||||||
'hspace', 'vlink', 'for', 'selected', 'rev', 'vspace', 'content',
|
'ismap', 'static', 'hspace', 'vlink', 'for', 'selected', 'rev', 'vspace',
|
||||||
'method', 'version', 'volatile', 'above', 'new', 'charoff', 'public',
|
'content', 'method', 'version', 'volatile', 'above', 'new', 'charoff',
|
||||||
'alink', 'enum', 'codebase', 'if', 'noresize', 'interface',
|
'public', 'alink', 'enum', 'codebase', 'if', 'noresize', 'interface',
|
||||||
'checked', 'byte', 'super', 'throw', 'src', 'language', 'package',
|
'checked', 'byte', 'super', 'throw', 'src', 'language', 'package',
|
||||||
'standby', 'script', 'longdesc', 'maxlength', 'cellpadding',
|
'standby', 'script', 'longdesc', 'maxlength', 'cellpadding', 'throws',
|
||||||
'throws', 'tabindex', 'color', 'colspan', 'accesskey', 'float',
|
'tabindex', 'color', 'colspan', 'accesskey', 'float', 'while', 'private',
|
||||||
'while', 'private', 'height', 'boolean', 'wrap', 'prompt', 'nowrap',
|
'height', 'boolean', 'wrap', 'prompt', 'nowrap', 'size', 'rows', 'span',
|
||||||
'size', 'rows', 'span', 'clip', 'bgcolor', 'top', 'long', 'start',
|
'clip', 'bgcolor', 'top', 'long', 'start', 'scope', 'scheme', 'type',
|
||||||
'scope', 'scheme', 'type', 'final', 'lang', 'visibility', 'else',
|
'final', 'lang', 'visibility', 'else', 'assert', 'transient', 'link',
|
||||||
'assert', 'transient', 'link', 'catch', 'true', 'serializable',
|
'catch', 'true', 'serializable', 'target', 'lowsrc', 'this', 'double',
|
||||||
'target', 'lowsrc', 'this', 'double', 'align', 'value', 'cite',
|
'align', 'value', 'cite', 'headers', 'below', 'protected', 'declare',
|
||||||
'headers', 'below', 'protected', 'declare', 'classid', 'defer',
|
'classid', 'defer', 'false', 'synchronized', 'int', 'abstract', 'accept',
|
||||||
'false', 'synchronized', 'int', 'abstract', 'accept', 'hreflang',
|
'hreflang', 'char', 'border', 'id', 'native', 'rowspan', 'charset',
|
||||||
'char', 'border', 'id', 'native', 'rowspan', 'charset', 'archive',
|
'archive', 'strictfp', 'readonly', 'axis', 'cellspacing', 'profile',
|
||||||
'strictfp', 'readonly', 'axis', 'cellspacing', 'profile', 'multiple',
|
'multiple', 'object', 'action', 'pagex', 'pagey', 'marginheight', 'data',
|
||||||
'object', 'action', 'pagex', 'pagey', 'marginheight', 'data',
|
'class', 'frameborder', 'enctype', 'implements', 'break', 'gutter', 'url',
|
||||||
'class', 'frameborder', 'enctype', 'implements', 'break', 'gutter',
|
'clear', 'face', 'switch', 'marginwidth', 'width', 'left' )
|
||||||
'url', 'clear', 'face', 'switch', 'marginwidth', 'width', 'left']),
|
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput(
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput(
|
||||||
ContentsOfTestFile( 'java_syntax' ) ) )
|
ContentsOfTestFile( 'java_syntax' ) ),
|
||||||
|
contains_inanyorder( *expected_keywords ) )
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_PhpSyntax_ContainsFunctions_test():
|
def KeywordsFromSyntaxListOutput_PhpSyntax_ContainsFunctions_test():
|
||||||
@ -143,19 +141,19 @@ def KeywordsFromSyntaxListOutput_PhpSyntax_ContainsFunctions_test():
|
|||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_Basic_test():
|
def KeywordsFromSyntaxListOutput_Basic_test():
|
||||||
eq_( set([ 'foo', 'bar', 'zoo', 'goo' ]),
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput( """
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput( """
|
|
||||||
foogroup xxx foo bar
|
foogroup xxx foo bar
|
||||||
zoo goo
|
zoo goo
|
||||||
links to Statement""" ) )
|
links to Statement""" ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_Function_test():
|
def KeywordsFromSyntaxListOutput_Function_test():
|
||||||
eq_( set([ 'foo', 'bar', 'zoo', 'goo' ]),
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput( """
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput( """
|
|
||||||
foogroup xxx foo bar
|
foogroup xxx foo bar
|
||||||
zoo goo
|
zoo goo
|
||||||
links to Function""" ) )
|
links to Function""" ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_ContainedArgAllowed_test():
|
def KeywordsFromSyntaxListOutput_ContainedArgAllowed_test():
|
||||||
@ -167,59 +165,58 @@ phpFunctions xxx contained gzclose yaz_syntax html_entity_decode fbsql_read_bl
|
|||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_JunkIgnored_test():
|
def KeywordsFromSyntaxListOutput_JunkIgnored_test():
|
||||||
eq_( set([ 'foo', 'bar', 'zoo', 'goo' ]),
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput( """
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput( """
|
|
||||||
--- Syntax items ---
|
--- Syntax items ---
|
||||||
foogroup xxx foo bar
|
foogroup xxx foo bar
|
||||||
zoo goo
|
zoo goo
|
||||||
links to Statement
|
links to Statement
|
||||||
Spell cluster=NONE
|
Spell cluster=NONE
|
||||||
NoSpell cluster=NONE""" ) )
|
NoSpell cluster=NONE""" ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_MultipleStatementGroups_test():
|
def KeywordsFromSyntaxListOutput_MultipleStatementGroups_test():
|
||||||
eq_( set([ 'foo', 'bar', 'zoo', 'goo' ]),
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput( """
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput( """
|
|
||||||
foogroup xxx foo bar
|
foogroup xxx foo bar
|
||||||
links to Statement
|
links to Statement
|
||||||
bargroup xxx zoo goo
|
bargroup xxx zoo goo
|
||||||
links to Statement""" ) )
|
links to Statement""" ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_StatementAndTypeGroups_test():
|
def KeywordsFromSyntaxListOutput_StatementAndTypeGroups_test():
|
||||||
eq_( set([ 'foo', 'bar', 'zoo', 'goo' ]),
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput( """
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput( """
|
|
||||||
foogroup xxx foo bar
|
foogroup xxx foo bar
|
||||||
links to Statement
|
links to Statement
|
||||||
bargroup xxx zoo goo
|
bargroup xxx zoo goo
|
||||||
links to Type""" ) )
|
links to Type""" ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_StatementHierarchy_test():
|
def KeywordsFromSyntaxListOutput_StatementHierarchy_test():
|
||||||
eq_( set([ 'foo', 'bar', 'zoo', 'goo', 'qux', 'moo' ]),
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput( """
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput( """
|
|
||||||
baa xxx foo bar
|
baa xxx foo bar
|
||||||
links to Foo
|
links to Foo
|
||||||
Foo xxx zoo goo
|
Foo xxx zoo goo
|
||||||
links to Bar
|
links to Bar
|
||||||
Bar xxx qux moo
|
Bar xxx qux moo
|
||||||
links to Statement""" ) )
|
links to Statement""" ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo', 'qux', 'moo' ) )
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_TypeHierarchy_test():
|
def KeywordsFromSyntaxListOutput_TypeHierarchy_test():
|
||||||
eq_( set([ 'foo', 'bar', 'zoo', 'goo', 'qux', 'moo' ]),
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput( """
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput( """
|
|
||||||
baa xxx foo bar
|
baa xxx foo bar
|
||||||
links to Foo
|
links to Foo
|
||||||
Foo xxx zoo goo
|
Foo xxx zoo goo
|
||||||
links to Bar
|
links to Bar
|
||||||
Bar xxx qux moo
|
Bar xxx qux moo
|
||||||
links to Type""" ) )
|
links to Type""" ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo', 'qux', 'moo' ) )
|
||||||
|
|
||||||
|
|
||||||
def KeywordsFromSyntaxListOutput_StatementAndTypeHierarchy_test():
|
def KeywordsFromSyntaxListOutput_StatementAndTypeHierarchy_test():
|
||||||
eq_( set([ 'foo', 'bar', 'zoo', 'goo', 'qux', 'moo', 'na', 'nb', 'nc' ]),
|
assert_that( syntax_parse._KeywordsFromSyntaxListOutput( """
|
||||||
syntax_parse._KeywordsFromSyntaxListOutput( """
|
|
||||||
tBaa xxx foo bar
|
tBaa xxx foo bar
|
||||||
links to tFoo
|
links to tFoo
|
||||||
tFoo xxx zoo goo
|
tFoo xxx zoo goo
|
||||||
@ -231,80 +228,89 @@ sBaa xxx na bar
|
|||||||
sFoo xxx zoo nb
|
sFoo xxx zoo nb
|
||||||
links to sBar
|
links to sBar
|
||||||
sBar xxx qux nc
|
sBar xxx qux nc
|
||||||
links to Statement""" ) )
|
links to Statement""" ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo', 'qux', 'moo',
|
||||||
|
'na', 'nb', 'nc' ) )
|
||||||
|
|
||||||
|
|
||||||
def SyntaxGroupsFromOutput_Basic_test():
|
def SyntaxGroupsFromOutput_Basic_test():
|
||||||
groups = syntax_parse._SyntaxGroupsFromOutput(
|
assert_that( syntax_parse._SyntaxGroupsFromOutput( """
|
||||||
"""foogroup xxx foo bar
|
foogroup xxx foo bar
|
||||||
zoo goo
|
zoo goo
|
||||||
links to Statement""" )
|
links to Statement""" ),
|
||||||
|
has_item( 'foogroup' ) )
|
||||||
assert 'foogroup' in groups
|
|
||||||
|
|
||||||
|
|
||||||
def ExtractKeywordsFromGroup_Basic_test():
|
def ExtractKeywordsFromGroup_Basic_test():
|
||||||
eq_( ['foo', 'bar', 'zoo', 'goo' ],
|
assert_that( syntax_parse._ExtractKeywordsFromGroup(
|
||||||
syntax_parse._ExtractKeywordsFromGroup( syntax_parse.SyntaxGroup('', [
|
syntax_parse.SyntaxGroup( '', [
|
||||||
'foo bar',
|
'foo bar',
|
||||||
'zoo goo',
|
'zoo goo',
|
||||||
] ) ) )
|
] ) ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def ExtractKeywordsFromGroup_Commas_test():
|
def ExtractKeywordsFromGroup_Commas_test():
|
||||||
eq_( ['foo', 'bar', 'zoo', 'goo' ],
|
assert_that( syntax_parse._ExtractKeywordsFromGroup(
|
||||||
syntax_parse._ExtractKeywordsFromGroup( syntax_parse.SyntaxGroup('', [
|
syntax_parse.SyntaxGroup( '', [
|
||||||
'foo, bar,',
|
'foo, bar,',
|
||||||
'zoo goo',
|
'zoo goo',
|
||||||
] ) ) )
|
] ) ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def ExtractKeywordsFromGroup_WithLinksTo_test():
|
def ExtractKeywordsFromGroup_WithLinksTo_test():
|
||||||
eq_( ['foo', 'bar', 'zoo', 'goo' ],
|
assert_that( syntax_parse._ExtractKeywordsFromGroup(
|
||||||
syntax_parse._ExtractKeywordsFromGroup( syntax_parse.SyntaxGroup('', [
|
syntax_parse.SyntaxGroup( '', [
|
||||||
'foo bar',
|
'foo bar',
|
||||||
'zoo goo',
|
'zoo goo',
|
||||||
'links to Statement'
|
'links to Statement'
|
||||||
] ) ) )
|
] ) ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def ExtractKeywordsFromGroup_KeywordStarts_test():
|
def ExtractKeywordsFromGroup_KeywordStarts_test():
|
||||||
eq_( ['foo', 'bar', 'zoo', 'goo' ],
|
assert_that( syntax_parse._ExtractKeywordsFromGroup(
|
||||||
syntax_parse._ExtractKeywordsFromGroup( syntax_parse.SyntaxGroup('', [
|
syntax_parse.SyntaxGroup( '', [
|
||||||
'foo bar',
|
'foo bar',
|
||||||
'transparent boo baa',
|
'transparent boo baa',
|
||||||
'zoo goo',
|
'zoo goo',
|
||||||
] ) ) )
|
] ) ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def ExtractKeywordsFromGroup_KeywordMiddle_test():
|
def ExtractKeywordsFromGroup_KeywordMiddle_test():
|
||||||
eq_( ['foo', 'bar', 'zoo', 'goo' ],
|
assert_that( syntax_parse._ExtractKeywordsFromGroup(
|
||||||
syntax_parse._ExtractKeywordsFromGroup( syntax_parse.SyntaxGroup('', [
|
syntax_parse.SyntaxGroup( '', [
|
||||||
'foo oneline bar',
|
'foo oneline bar',
|
||||||
'zoo goo',
|
'zoo goo'
|
||||||
] ) ) )
|
] ) ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def ExtractKeywordsFromGroup_KeywordAssign_test():
|
def ExtractKeywordsFromGroup_KeywordAssign_test():
|
||||||
eq_( ['foo', 'bar', 'zoo', 'goo' ],
|
assert_that( syntax_parse._ExtractKeywordsFromGroup(
|
||||||
syntax_parse._ExtractKeywordsFromGroup( syntax_parse.SyntaxGroup('', [
|
syntax_parse.SyntaxGroup( '', [
|
||||||
'foo end=zoo((^^//)) bar',
|
'foo end=zoo((^^//)) bar',
|
||||||
'zoo goo',
|
'zoo goo',
|
||||||
] ) ) )
|
] ) ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def ExtractKeywordsFromGroup_KeywordAssignAndMiddle_test():
|
def ExtractKeywordsFromGroup_KeywordAssignAndMiddle_test():
|
||||||
eq_( ['foo', 'bar', 'zoo', 'goo' ],
|
assert_that( syntax_parse._ExtractKeywordsFromGroup(
|
||||||
syntax_parse._ExtractKeywordsFromGroup( syntax_parse.SyntaxGroup('', [
|
syntax_parse.SyntaxGroup( '', [
|
||||||
'foo end=zoo((^^//)) transparent bar',
|
'foo end=zoo((^^//)) transparent bar',
|
||||||
'zoo goo',
|
'zoo goo',
|
||||||
] ) ) )
|
] ) ),
|
||||||
|
contains_inanyorder( 'foo', 'bar', 'zoo', 'goo' ) )
|
||||||
|
|
||||||
|
|
||||||
def ExtractKeywordsFromGroup_ContainedSyntaxArgAllowed_test():
|
def ExtractKeywordsFromGroup_ContainedSyntaxArgAllowed_test():
|
||||||
eq_( ['foo', 'zoq', 'bar', 'goo', 'far' ],
|
assert_that( syntax_parse._ExtractKeywordsFromGroup(
|
||||||
syntax_parse._ExtractKeywordsFromGroup( syntax_parse.SyntaxGroup('', [
|
syntax_parse.SyntaxGroup( '', [
|
||||||
'contained foo zoq',
|
'contained foo zoq',
|
||||||
'contained bar goo',
|
'contained bar goo',
|
||||||
'far',
|
'far'
|
||||||
] ) ) )
|
] ) ),
|
||||||
|
contains_inanyorder( 'foo', 'zoq', 'bar', 'goo', 'far' ) )
|
||||||
|
Loading…
Reference in New Issue
Block a user