Пример #1
0
	def test_execute_program_java(self):
		source = self.JAVA_SOURCE
		language = languages.JAVA
		stdin = ""
		expectedOutputs = [self.HELLO_WORLD, "!!"]
		expectedResults = [status.ANSWER_CORRECT, status.WRONG_ANSWER]
		
		for i in range(len(expectedOutputs)):
			result = judge.executeProgram(source, language, stdin, expectedOutputs[i])
			self.assertEqual(result, expectedResults[i])

		wrongSource = source + "!;"
		result = judge.executeProgram(wrongSource, language, stdin, "")
		self.assertEqual(result, status.COMPILE_ERROR)

		wrongSource = self.JAVA_SOURCE_RUNTIME_ERROR
		result = judge.executeProgram(wrongSource, language, stdin, "Foo")
		self.assertEqual(result, status.RUNTIME_ERROR)
Пример #2
0
	def test_execute_program_python(self):
		source = self.PYTHON_SOURCE
		language = languages.PYTHON
		stdin = ""
		expectedOutputs = [self.HELLO_WORLD, "!!"]
		expectedResults = [status.ANSWER_CORRECT, status.WRONG_ANSWER]

		for i in range(len(expectedOutputs)):
			result = judge.executeProgram(source, language, stdin, expectedOutputs[i])
			self.assertEqual(result, expectedResults[i])

		wrongSource = "foo"
		result = judge.executeProgram(wrongSource, language, stdin, "")
		self.assertEqual(result, status.RUNTIME_ERROR)

		infiniteSource = "while True: pass"
		result = judge.executeProgram(infiniteSource, language, stdin, "")
		self.assertEqual(result, status.TIME_LIMIT_EXCEEDED)