def test_L1_call_sext_num_args(do_test): class A(Component): def construct(s): @s.update def upblk(): x = sext(s) with expected_failure(PyMTLSyntaxError, "exactly two arguments"): do_test(A())
def test_L1_multi_assign(do_test): class A(Component): def construct(s): @s.update def upblk(): u = v = x = y with expected_failure(PyMTLSyntaxError, "multiple targets"): do_test(A())
def test_L1_tmpvar(do_test): class A(Component): def construct(s): @s.update def upblk(): u = 42 with expected_failure(PyMTLSyntaxError, "Temporary variable"): do_test(A())
def test_Global( do_test ): class A( Component ): def construct( s ): u = 42 @s.update def upblk(): global u with expected_failure( PyMTLSyntaxError, "invalid operation: global" ): do_test( A() )
def test_ExtSlice(do_test): class A(Component): def construct(s): @s.update def upblk(): 42 [1:2:3, 2:4:6] with expected_failure(PyMTLSyntaxError, "invalid operation: extslice"): do_test(A())
def test_Str( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = '42' with expected_failure( PyMTLSyntaxError, "invalid operation: str" ): do_test( A() )
def test_ImportFrom( do_test ): class A( Component ): def construct( s ): x = 42 @s.update def upblk(): from x import x with expected_failure( PyMTLSyntaxError, "invalid operation: import-from" ): do_test( A() )
def test_L1_index_base_component( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = s[ 1 ] with expected_failure( PyMTLTypeError, "base of an index must be an array or signal" ): do_test( A() )
def test_L1_slice_component( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = s[ 0:4 ] with expected_failure( PyMTLTypeError, "base of a slice must be a signal" ): do_test( A() )
def test_L1_sext_component( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = sext( s, 1 ) with expected_failure( PyMTLTypeError, "only applies to signals" ): do_test( A() )
def test_L1_size_cast_component( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = Bits32( s ) with expected_failure( PyMTLTypeError, "size casting only applies to signals/consts" ): do_test( A() )
def test_L1_assign_rhs_component( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = s with expected_failure( PyMTLTypeError, "signal or const" ): do_test( A() )
def test_L1_assign_lhs_const( do_test ): class A( Component ): def construct( s ): u, s.v = 42, 42 @s.update def upblk(): s.v = u with expected_failure( PyMTLTypeError, "must be a signal" ): do_test( A() )
def test_Expr(do_test): class A(Component): def construct(s): @s.update def upblk(): 42 with expected_failure(PyMTLSyntaxError, "Stand-alone expression"): do_test(A())
def test_DictComp( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = { 1:42 for _ in range(1) } with expected_failure( PyMTLSyntaxError, "invalid operation: dict comprehension" ): do_test( A() )
def test_L1_slice_step( do_test ): class A( Component ): def construct( s ): v = 42 @s.update def upblk(): u = v[ 0:16:4 ] with expected_failure( PyMTLSyntaxError, "Slice with steps" ): do_test( A() )
def test_GeneratorExp( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = ( 42 for _ in range(1) ) with expected_failure( PyMTLSyntaxError, "invalid operation: generator expression" ): do_test( A() )
def test_L1_illegal_subscript( do_test ): class A( Component ): def construct( s ): v = 42 @s.update def upblk(): u = v[ 0:8, 16:24 ] with expected_failure( PyMTLSyntaxError, "Illegal subscript" ): do_test( A() )
def test_TryFinally( do_test ): class A( Component ): def construct( s ): @s.update def upblk(): try: 42 finally: 42 with expected_failure( PyMTLSyntaxError, "invalid operation: try-finally" ): do_test( A() )
def test_L1_call_keyword_arg( do_test ): class A( Component ): def construct( s ): xx = 42 @s.update def upblk(): x = x(x=x) with expected_failure( PyMTLSyntaxError, "keyword argument" ): do_test( A() )
def test_Exec( do_test ): class A( Component ): def construct( s ): @s.update def upblk(): # Python 2 only: exec 42 exec(42) with expected_failure( PyMTLSyntaxError, "invalid operation: exec" ): do_test( A() )
def test_L1_call_unrecognized( do_test ): class A( Component ): def construct( s ): def foo(): pass @s.update def upblk(): x = foo() with expected_failure( PyMTLSyntaxError, "Unrecognized method" ): do_test( A() )
def test_Pass(do_test): class A(Component): def construct(s): @s.update def upblk(): pass with expected_failure(PyMTLSyntaxError, "invalid operation: pass"): do_test(A())
def test_Lambda( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = lambda: 42 with expected_failure( PyMTLSyntaxError, "invalid operation: lambda function" ): do_test( A() )
def test_L1_upblk_arg(do_test): class A(Component): def construct(s): @s.update def upblk(number): u = number with expected_failure(PyMTLSyntaxError, "not have arguments"): do_test(A())
def test_List( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = [ 42 ] with expected_failure( PyMTLSyntaxError, "invalid type: list" ): do_test( A() )
def test_L1_deepcopy_arg(do_test): class A(Component): def construct(s): @s.update def upblk(): u = deepcopy(42, 10) with expected_failure(PyMTLSyntaxError, "takes exactly 1 argument"): do_test(A())
def test_Tuple( do_test ): class A( Component ): def construct( s ): s.out = OutPort( Bits32 ) @s.update def upblk(): s.out = ( 42, ) with expected_failure( PyMTLSyntaxError, "invalid type: tuple" ): do_test( A() )
def test_L1_call_star_arg(do_test): class A(Component): def construct(s): @s.update def upblk(): x = x(*x) with expected_failure(PyMTLSyntaxError, "star argument"): do_test(A())
def test_L1_call_concat_args(do_test): class A(Component): def construct(s): @s.update def upblk(): x = concat() with expected_failure(PyMTLSyntaxError, "at least one argument"): do_test(A())