コード例 #1
0
ファイル: cs_tests.py プロジェクト: mwilliamson/nope
    def lambda_without_arguments_has_body_serialized(self):
        node = cs.lambda_([], [cs.ret(cs.ref("x"))])
        expected = """(() =>
{
    return x;
})"""
        assert_equal(expected, cs.dumps(node))
コード例 #2
0
ファイル: cs_tests.py プロジェクト: mwilliamson/nope
    def method_has_body(self):
        node = cs.method("f", [], [cs.ret(cs.ref("x"))])
        expected = """internal dynamic f() {
    return x;
}
"""
        assert_equal(expected, cs.dumps(node))
コード例 #3
0
ファイル: cs_tests.py プロジェクト: mwilliamson/nope
    def test_serialize_try_with_filtered_catch_with_name(self):
        node = cs.try_(
            [cs.ret(cs.ref("x"))],
            handlers=[cs.catch(cs.ref("Exception"), "exception", [cs.expression_statement(cs.ref("y"))])],
        )
        expected = """try {
    return x;
} catch (Exception exception) {
    y;
}
"""
        assert_equal(expected, cs.dumps(node))
コード例 #4
0
ファイル: cs_tests.py プロジェクト: mwilliamson/nope
    def test_serialize_try_with_unfiltered_catch(self):
        node = cs.try_(
            [cs.ret(cs.ref("x"))],
            handlers=[cs.catch(None, None, [cs.expression_statement(cs.ref("y"))])],
        )
        expected = """try {
    return x;
} catch {
    y;
}
"""
        assert_equal(expected, cs.dumps(node))
コード例 #5
0
ファイル: cs_tests.py プロジェクト: mwilliamson/nope
    def test_serialize_try_with_finally_body(self):
        node = cs.try_(
            [cs.ret(cs.ref("x"))],
            finally_body=[cs.expression_statement(cs.ref("y"))],
        )
        expected = """try {
    return x;
} finally {
    y;
}
"""
        assert_equal(expected, cs.dumps(node))