Exemple #1
0
def All_examples_evaluate():
    from pycell.run import run
    for example in all_examples():
        with StringIO() as stdin, StringIO() as stdout:
            run(example, stdin, stdout, stdout)
            with open(example[:-5] + ".output.txt") as outputfile:
                assert_that(stdout.getvalue(), equals(outputfile.read()))
Exemple #2
0
def All_examples_evaluate():
    from pycell.run import run
    for example in all_examples():
        try:
            with StringIO() as stdin, StringIO() as stdout:
                run(example, stdin, stdout, stdout)
                with open(example[:-5] + ".output.txt") as outputfile:
                    assert_that(stdout.getvalue(), equals(outputfile.read()))
        except Exception as e:
            raise Exception("%s: %s" % (example, str(e)))
Exemple #3
0
def All_examples_work_in_js():
    import os
    from subprocess import check_output
    from pycell.chars_in_file import chars_in_file
    from pycell.compile_ import compile_list
    for example in all_examples():
        compile_("compiled.js", example)
        with open(example[:-5] + ".output.txt") as outputfile:
            expected = outputfile.read()

        stdout = check_output(["node", "compiled.js"], universal_newlines=True)
        assert_that(stdout, equals(expected))
        os.remove("compiled.js")
Exemple #4
0
def All_examples_work_in_js():
    import os
    from subprocess import check_output
    from pycell.chars_in_file import chars_in_file
    from pycell.compile_ import compile_list
    for example in all_examples():
        compile_("compiled.js", example)
        with open(example[:-5] + ".output.txt") as outputfile:
            expected = outputfile.read()

        stdout = check_output(
            ["node", "compiled.js"], universal_newlines=True )
        assert_that(stdout, equals(expected))
        os.remove("compiled.js")
Exemple #5
0
def All_examples_lex():
    from pycell.chars_in_file import chars_in_file
    for example in all_examples():
        with open(example, encoding="ascii") as f:
            lexed(chars_in_file(f))
Exemple #6
0
def All_examples_parse():
    from pycell.chars_in_file import chars_in_file
    for example in all_examples():
        with open(example, encoding="ascii") as f:
            parsed(chars_in_file(f))