コード例 #1
0
ファイル: test_lexer.py プロジェクト: kyokley/krill
 def test_simple_AND(self):
     test_str = 'python is fun && python is simple'
     expected = [('python is fun', FILTER),
                 ('&&', AND),
                 ('python is simple', FILTER),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #2
0
ファイル: test_lexer.py プロジェクト: kyokley/krill
 def test_simple_OR(self):
     test_str = 'python is fun || python is the best'
     expected = [('python is fun', FILTER),
                 ('||', OR),
                 ('python is the best', FILTER),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #3
0
 def test_simple_OR(self):
     test_str = 'python is fun || python is the best'
     expected = [
         ('python is fun', FILTER),
         ('||', OR),
         ('python is the best', FILTER),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #4
0
 def test_simple_AND(self):
     test_str = 'python is fun && python is simple'
     expected = [
         ('python is fun', FILTER),
         ('&&', AND),
         ('python is simple', FILTER),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #5
0
ファイル: test_lexer.py プロジェクト: kyokley/krill
 def test_mixed_AND_and_OR(self):
     test_str = 'python is fun && python is simple || python is the best'
     expected = [('python is fun', FILTER),
                 ('&&', AND),
                 ('python is simple', FILTER),
                 ('||', OR),
                 ('python is the best', FILTER),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #6
0
 def test_mixed_AND_and_OR(self):
     test_str = 'python is fun && python is simple || python is the best'
     expected = [
         ('python is fun', FILTER),
         ('&&', AND),
         ('python is simple', FILTER),
         ('||', OR),
         ('python is the best', FILTER),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #7
0
ファイル: test_lexer.py プロジェクト: kyokley/krill
 def test_mixed_grouping(self):
     test_str = 'python is fun && (python is simple || python is the best)'
     expected = [('python is fun', FILTER),
                 ('&&', AND),
                 ('(', LPAREN),
                 ('python is simple', FILTER),
                 ('||', OR),
                 ('python is the best', FILTER),
                 (')', RPAREN),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #8
0
 def test_mixed_grouping(self):
     test_str = 'python is fun && (python is simple || python is the best)'
     expected = [
         ('python is fun', FILTER),
         ('&&', AND),
         ('(', LPAREN),
         ('python is simple', FILTER),
         ('||', OR),
         ('python is the best', FILTER),
         (')', RPAREN),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #9
0
ファイル: test_lexer.py プロジェクト: kyokley/krill
 def test_multi_tier(self):
     test_str = 'a && (b || (c && d))'
     expected = [('a', FILTER),
                 ('&&', AND),
                 ('(', LPAREN),
                 ('b', FILTER),
                 ('||', OR),
                 ('(', LPAREN),
                 ('c', FILTER),
                 ('&&', AND),
                 ('d', FILTER),
                 (')', RPAREN),
                 (')', RPAREN),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #10
0
 def test_multi_tier(self):
     test_str = 'a && (b || (c && d))'
     expected = [
         ('a', FILTER),
         ('&&', AND),
         ('(', LPAREN),
         ('b', FILTER),
         ('||', OR),
         ('(', LPAREN),
         ('c', FILTER),
         ('&&', AND),
         ('d', FILTER),
         (')', RPAREN),
         (')', RPAREN),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #11
0
ファイル: test_lexer.py プロジェクト: kyokley/krill
 def test_quoted_filter(self):
     test_str = "a && (b || (c && d)) || '(e)'"
     expected = [('a', FILTER),
                 ('&&', AND),
                 ('(', LPAREN),
                 ('b', FILTER),
                 ('||', OR),
                 ('(', LPAREN),
                 ('c', FILTER),
                 ('&&', AND),
                 ('d', FILTER),
                 (')', RPAREN),
                 (')', RPAREN),
                 ('||', OR),
                 ("'(e)'", QUOTED_FILTER),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #12
0
 def test_quoted_filter(self):
     test_str = "a && (b || (c && d)) || '(e)'"
     expected = [
         ('a', FILTER),
         ('&&', AND),
         ('(', LPAREN),
         ('b', FILTER),
         ('||', OR),
         ('(', LPAREN),
         ('c', FILTER),
         ('&&', AND),
         ('d', FILTER),
         (')', RPAREN),
         (')', RPAREN),
         ('||', OR),
         ("'(e)'", QUOTED_FILTER),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #13
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_simple_AND(self):
     test_str = 'python is fun && python is simple'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(FilterExpr(python is fun), FilterExpr(python is simple))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #14
0
 def test_simple_with_spaces(self):
     test_str = 'python is the best'
     expected = [('python is the best', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #15
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_quoted_filter(self):
     test_str = "a && (b || (c && d)) || '(e)'"
     tokens = filter_lex(test_str)
     expected = 'OrExpr(AndExpr(FilterExpr(a), OrExpr(FilterExpr(b), AndExpr(FilterExpr(c), FilterExpr(d)))), QuotedFilterExpr((e)))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #16
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_multi_tier(self):
     test_str = 'a && (b || (c && d))'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(FilterExpr(a), OrExpr(FilterExpr(b), AndExpr(FilterExpr(c), FilterExpr(d))))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #17
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_mixed_grouping_not(self):
     test_str = '!python is not fun && (python is simple || python is the best)'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(NotExpr(FilterExpr(python is not fun)), OrExpr(FilterExpr(python is simple), FilterExpr(python is the best)))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #18
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_simple(self):
     test_str = 'python'
     tokens = filter_lex(test_str)
     expected = 'FilterExpr(python)'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #19
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_mixed_AND_and_OR(self):
     test_str = 'python is fun && python is simple || python is the best'
     tokens = filter_lex(test_str)
     expected = 'OrExpr(AndExpr(FilterExpr(python is fun), FilterExpr(python is simple)), FilterExpr(python is the best))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #20
0
ファイル: test_lexer.py プロジェクト: kyokley/krill
 def test_simple(self):
     test_str = 'python'
     expected = [('python', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #21
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_simple_OR(self):
     test_str = 'python is fun || python is the best'
     tokens = filter_lex(test_str)
     expected = 'OrExpr(FilterExpr(python is fun), FilterExpr(python is the best))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #22
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_simple(self):
     test_str = 'python'
     tokens = filter_lex(test_str)
     expected = 'FilterExpr(python)'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #23
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_mixed_AND_and_OR(self):
     test_str = 'python is fun && python is simple || python is the best'
     tokens = filter_lex(test_str)
     expected = 'OrExpr(AndExpr(FilterExpr(python is fun), FilterExpr(python is simple)), FilterExpr(python is the best))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #24
0
 def test_simple(self):
     test_str = 'python'
     expected = [('python', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #25
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_mixed_grouping_not(self):
     test_str = '!python is not fun && (python is simple || python is the best)'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(NotExpr(FilterExpr(python is not fun)), OrExpr(FilterExpr(python is simple), FilterExpr(python is the best)))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #26
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_multi_tier(self):
     test_str = 'a && (b || (c && d))'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(FilterExpr(a), OrExpr(FilterExpr(b), AndExpr(FilterExpr(c), FilterExpr(d))))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #27
0
ファイル: test_lexer.py プロジェクト: kyokley/krill
 def test_simple_with_spaces(self):
     test_str = 'python is the best'
     expected = [('python is the best', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
コード例 #28
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_simple_AND(self):
     test_str = 'python is fun && python is simple'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(FilterExpr(python is fun), FilterExpr(python is simple))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #29
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_simple_OR(self):
     test_str = 'python is fun || python is the best'
     tokens = filter_lex(test_str)
     expected = 'OrExpr(FilterExpr(python is fun), FilterExpr(python is the best))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #30
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_quoted_filter(self):
     test_str = "a && (b || (c && d)) || '(e)'"
     tokens = filter_lex(test_str)
     expected = 'OrExpr(AndExpr(FilterExpr(a), OrExpr(FilterExpr(b), AndExpr(FilterExpr(c), FilterExpr(d)))), QuotedFilterExpr((e)))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #31
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_simple_with_spaces(self):
     test_str = 'python is the best'
     tokens = filter_lex(test_str)
     expected = 'FilterExpr(python is the best)'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
コード例 #32
0
ファイル: test_parser.py プロジェクト: kyokley/krill
 def test_simple_with_spaces(self):
     test_str = 'python is the best'
     tokens = filter_lex(test_str)
     expected = 'FilterExpr(python is the best)'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)