コード例 #1
0
    def test_simple_expression_application(self):
        inputData = "9"
        expected = ast.Expr(ast.Num(9))
        result = transpile(inputData)
        print(result)

        self.assertTrue(compare_ast(result, expected))
コード例 #2
0
    def test_range_with_first_and_last(self):
        inputData = "[1..10]"
        expected = ast.Expr(
            ast.Call(ast.Name("range", None),
                     [ast.Num(1), ast.Num(11)], None))
        result = transpile(inputData)

        self.assertTrue(compare_ast(result, expected))
コード例 #3
0
    def test_simple_enumerated_list(self):
        inputData = "[1, 2, 3]"
        expected = ast.Expr(
            ast.List(
                [ast.Num(1), ast.Num(2), ast.Num(3)], None))
        result = transpile(inputData)

        self.assertTrue(compare_ast(result, expected))
コード例 #4
0
    def test_simple_function_call(self):
        inputData = "f 1 2 3"
        expected = ast.Expr(
            ast.Call(
                ast.Name("f", None),
                [ast.Num(1), ast.Num(2), ast.Num(3)], []))
        result = transpile(inputData)

        self.assertTrue(compare_ast(result, expected))
コード例 #5
0
    def test_infinite_range_with_step(self):
        inputData = "[1, 3..]"
        expected = ast.Expr(
            ast.Call(ast.Attribute(ast.Name("itertools", None), "count", None),
                     [], [
                         ast.keyword("start", ast.Num(1)),
                         ast.keyword("step", ast.Num(2))
                     ]))
        result = transpile(inputData)

        self.assertTrue(compare_ast(result, expected))
コード例 #6
0
    def test_empty_list(self):
        inputData = "[]"
        expected = ast.Expr(ast.List([], None))
        result = transpile(inputData)

        self.assertTrue(compare_ast(result, expected))