| Home | Trees | Indices | Help |
|---|
|
|
1 2 # The contents of this file are subject to the Mozilla Public License 3 # (MPL) Version 1.1 (the "License"); you may not use this file except 4 # in compliance with the License. You may obtain a copy of the License 5 # at http://www.mozilla.org/MPL/ 6 # 7 # Software distributed under the License is distributed on an "AS IS" 8 # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 9 # the License for the specific language governing rights and 10 # limitations under the License. 11 # 12 # The Original Code is LEPL (http://www.acooke.org/lepl) 13 # The Initial Developer of the Original Code is Andrew Cooke. 14 # Portions created by the Initial Developer are Copyright (C) 2009-2010 15 # Andrew Cooke (andrew@acooke.org). All Rights Reserved. 16 # 17 # Alternatively, the contents of this file may be used under the terms 18 # of the LGPL license (the GNU Lesser General Public License, 19 # http://www.gnu.org/licenses/lgpl.html), in which case the provisions 20 # of the LGPL License are applicable instead of those above. 21 # 22 # If you wish to allow use of your version of this file only under the 23 # terms of the LGPL License and not to allow others to use your version 24 # of this file under the MPL, indicate your decision by deleting the 25 # provisions above and replace them with the notice and other provisions 26 # required by the LGPL License. If you do not delete the provisions 27 # above, a recipient may use your version of this file under either the 28 # MPL or the LGPL License. 29 30 ''' 31 Tests related to a now-forgotten bug. 32 ''' 33 34 from logging import basicConfig, DEBUG 35 from unittest import TestCase 36 37 from lepl import * 38 39419443 empty = ~Line(Empty(), indent=False) 44 word = Token(Word()) 45 comment = ~Line(Token('#.*'), indent=False) 46 CLine = ContinuedLineFactory(Token(r'\\')) 47 token = word[1:] 48 block = Delayed() 49 line = ((CLine(token) | block) > list) | empty | comment 50 block += CLine((token)) & Block(line[:]) 51 program = (line[:] & Eos()) 52 program.config.lines(block_policy=explicit) 53 self.run_test(program.get_parse(), False)5456 #basicConfig(level=DEBUG) 57 empty = ~Line(Empty(), indent=False) 58 word = Token(Word()) 59 text = word[1:] 60 block = Delayed() 61 line = Line(text) | block | empty 62 block += empty | (Block(line[1:]) > list) 63 program = Trace(block[:] & Eos()) 64 program.config.lines(block_policy=to_right, block_start=-1) 65 self.run_test(program.get_parse(), True)6668 try: 69 result = parser(""" 70 a1 71 a2 72 b2 73 c2 74 b2 75 76 b2 77 c2 78 79 d2 80 e2 81 b2 82 a3 83 b3 84 a4 85 """) 86 if ok: 87 assert result == [['a1', 'a2', ['b2', ['c2'], 'b2', 'b2', ['c2', ['d2', ['e2']]], 'b2'], 'a3', ['b3'], 'a4']], result 88 except: 89 if ok: 90 raise 91 ok = True 92 if not ok: 93 assert False, 'expected error'
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Sat Jun 9 21:51:03 2012 | http://epydoc.sourceforge.net |