function test_programming_language($request) { Authenticator::assert_manager($request->cookies['authToken']); $msg = new Messages($GLOBALS['locale']); try { $raw_input = $request->getBody(); $content_type = explode(';', $request->type)[0]; if ($content_type !== 'application/json') { Util::output_errors_and_die('', 415); } $input_data = json_decode($raw_input, true); if (empty($input_data)) { Util::output_errors_and_die('', 400); } LanguageTest::test($input_data['file_name'], $input_data['extension'], $input_data['source_code'], $input_data['compiler_flags'], $input_data['check_command'], $input_data['compile_command'], $input_data['run_command'], $input_data['arguments'], $input_data['stdin']); } catch (Exception $e) { Util::output_errors_and_die($e->getMessage(), 400); } }
// the child token should also have 1 child, which should be its actual // text, i.e. a string with the contents 'text' assert($top['children'][0]['token_name'] === 'child'); assert(count($top['children'][0]['children']) === 1); assert($top['children'][0]['children'][0] === 'text'); // now let's pop, and we should be back to the initial state $this->popState(); $top = $this->getTopToken(); assert($top['token_name'] === 'initial'); // now let's test that we can't pop the initial state $exception = false; try { $this->popState(); } catch (Exception $e) { $exception = true; } assert($exception); $top = $this->getTopToken(); // now record some text into the initial state's child array $c = count($top['children']); $this->record('some text'); $top = $this->getTopToken(); $c1 = count($top['children']); assert($c + 1 === $c1); assert($top['children'][$c1 - 1] === 'some text'); } } $t = new LanguageTest(); $t->test(); $t = new ApiTest(); $t->test();