Exemple #1
0
    def test_compile_and_run_factorial(self):
        program = '''
def factorial(n):
    return 1 if n == 1 else n * factorial(n-1)

        '''
        output, program_module = program_tester.compile_and_run(program)
        self.assertEquals(output, "")
        self.assertIsNotNone(program_module)
Exemple #2
0
 def get(self):
   program = self.getValueInQuery('program')
   self.response.headers['Content-Type'] = 'text/plain'
   output, module = program_tester.compile_and_run(program)
   output = output + "\n === END OF OUTPUT === "
   self.response.write(output)
Exemple #3
0
 def test_compile_and_run_compile_error(self):
     """test compile_and_run "pass"."""
     program = 'error!'
     output, program_module = program_tester.compile_and_run(program)
     self.assertIsNone(program_module)
     self.assertTrue('Compile error' in output)
Exemple #4
0
 def test_compile_and_run_pass(self):
     """test compile_and_run "pass"."""
     program = 'pass'
     output, program_module = program_tester.compile_and_run(program)
     self.assertEquals(output, "")
     self.assertIsNotNone(program_module)