2020-06-10 09:34:07 +08:00
|
|
|
# RUN: %PYTHON %s | npcomp-opt -split-input-file | FileCheck %s --dump-input=fail
|
|
|
|
|
2020-06-29 07:52:25 +08:00
|
|
|
from npcomp.compiler import test_config
|
2020-06-10 09:34:07 +08:00
|
|
|
|
2020-06-29 07:52:25 +08:00
|
|
|
import_global = test_config.create_import_dump_decorator()
|
2020-06-10 09:34:07 +08:00
|
|
|
|
2020-06-14 05:53:54 +08:00
|
|
|
|
2020-06-11 10:17:29 +08:00
|
|
|
# CHECK-LABEL: func @positional_args
|
|
|
|
# CHECK-SAME: (%arg0: !basicpy.UnknownType, %arg1: !basicpy.UnknownType) -> !basicpy.UnknownType
|
|
|
|
@import_global
|
|
|
|
def positional_args(a, b):
|
|
|
|
# CHECK: basicpy.binary_expr %arg0 "Add" %arg1
|
|
|
|
return a + b
|
|
|
|
|
2020-06-14 05:53:54 +08:00
|
|
|
|
2020-06-10 09:34:07 +08:00
|
|
|
# CHECK-LABEL: func @pass_no_return
|
|
|
|
@import_global
|
|
|
|
def pass_no_return():
|
|
|
|
# CHECK: %[[NONE:.*]] = basicpy.singleton : !basicpy.NoneType
|
|
|
|
# CHECK: %[[NONE_CAST:.*]] = basicpy.unknown_cast %[[NONE]] : !basicpy.NoneType -> !basicpy.UnknownType
|
|
|
|
# CHECK: return %[[NONE_CAST]]
|
|
|
|
# CHECK-NOT: return
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# CHECK-LABEL: func @expr_statement
|
|
|
|
@import_global
|
|
|
|
def expr_statement():
|
|
|
|
# CHECK: basicpy.exec {
|
|
|
|
# CHECK: %[[V:.*]] = basicpy.binary_expr
|
|
|
|
# CHECK: basicpy.exec_discard %[[V]]
|
|
|
|
# CHECK: }
|
|
|
|
# CHECK: return
|
|
|
|
a = 1
|
|
|
|
a + 2
|