Example #1
0
    def test_codeforces_haskell(self):
        languages = languages_codeforces
        filename = 'Main.hs'
        code = 'main = return ()\n'
        expected = ['12']

        language_dict = {language.id: language.name
                         for language in languages
                         }  # type: Dict[LanguageId, str]
        self.assertEqual(
            submit.guess_lang_ids_of_file(filename=pathlib.Path(filename),
                                          code=code.encode(),
                                          language_dict=language_dict),
            expected)
Example #2
0
    def test_atcoder_4_fsharp(self):
        languages = languages_atcoder_4
        filename = 'Main.fs'
        code = 'open System\nprintfn "Hello, world!"\n'
        expected = ['4022', '4023']

        language_dict = {language.id: language.name
                         for language in languages
                         }  # type: Dict[LanguageId, str]
        self.assertEqual(
            submit.guess_lang_ids_of_file(filename=pathlib.Path(filename),
                                          code=code.encode(),
                                          language_dict=language_dict),
            expected)
Example #3
0
    def test_atcoder_3_rust(self):
        languages = languages_atcoder_3
        filename = 'main.rs'
        code = 'fn main() { println!("Hello, world!"); }\n'
        expected = ['3504']

        language_dict = {language.id: language.name
                         for language in languages
                         }  # type: Dict[LanguageId, str]
        self.assertEqual(
            submit.guess_lang_ids_of_file(filename=pathlib.Path(filename),
                                          code=code.encode(),
                                          language_dict=language_dict),
            expected)
Example #4
0
    def test_codeforces_clang(self):
        languages = languages_codeforces
        filename = 'main.cpp'
        code = 'int main() {}\n'
        cxx_latest = True
        cxx_compiler = 'clang'
        expected = ['52']

        language_dict = {language.id: language.name
                         for language in languages
                         }  # type: Dict[LanguageId, str]
        self.assertEqual(
            submit.guess_lang_ids_of_file(filename=pathlib.Path(filename),
                                          code=code.encode(),
                                          language_dict=language_dict,
                                          cxx_latest=cxx_latest,
                                          cxx_compiler=cxx_compiler), expected)
Example #5
0
    def test_codeforces_pypy_3(self):
        languages = languages_codeforces
        filename = 'main.py'
        code = 'print("hello")\n'
        python_version = 'auto'
        python_interpreter = 'pypy'
        expected = ['41']

        language_dict = {language.id: language.name
                         for language in languages
                         }  # type: Dict[LanguageId, str]
        self.assertEqual(
            submit.guess_lang_ids_of_file(
                filename=pathlib.Path(filename),
                code=code.encode(),
                language_dict=language_dict,
                python_version=python_version,
                python_interpreter=python_interpreter), expected)
Example #6
0
    def test_codeforces_python_2(self):
        languages = languages_codeforces
        filename = 'main.py'
        code = textwrap.dedent("""\
            #!/usr/bin/env python2
            print("hello")
            """)
        python_version = 'auto'
        python_interpreter = 'cpython'
        expected = ['7']

        language_dict = {language.id: language.name
                         for language in languages
                         }  # type: Dict[LanguageId, str]
        self.assertEqual(
            submit.guess_lang_ids_of_file(
                filename=pathlib.Path(filename),
                code=code.encode(),
                language_dict=language_dict,
                python_version=python_version,
                python_interpreter=python_interpreter), expected)