def loop_start(self, verb, ingredient_name, following_instructions, lineno=None): '''The loop executes as follows: The value of ingredient is checked. If it is non-zero, the body of the loop executes until it reaches the "until" statement. The value of ingredient is rechecked. If it is non-zero, the loop executes again. If at any check the value of ingredient is zero, the loop exits and execution continues at the statement after the "until". Loops may be nested. ''' body = [] import pprint pprint.pprint(following_instructions) for instr in following_instructions: body.append(instr) if instr['command'] == 'loop_end' and verbs_match(verb, instr['verb']): break else: # no matching loop end raise MissingLoopEndError(verb, lineno) #print 'body: %r' % body while True: for instruction in body: eval_instruction(instruction, following_instructions, self) ingredient = self.get_ingredient_by_name(ingredient_name, lineno) if ingredient.properties.value == 0: break
def test_special_case(self): # 'added' has a double consonant, but its present form ends with a # double consonant as well. assert verbs_match('Add', 'added')
def test_double_consonant(self): assert verbs_match('Stop', 'stopped') assert verbs_match('Scan', 'scanned')
def test_without_trailing_e(self): assert verbs_match('Join', 'joined')
def test_with_trailing_e(self): assert verbs_match('Examine', 'examined') assert verbs_match('Analyze', 'analyzed')