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())
Example #2
0
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())
Example #3
0
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())
Example #4
0
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() )
Example #5
0
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())
Example #6
0
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() )
Example #7
0
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() )
Example #8
0
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() )
Example #9
0
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() )
Example #10
0
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() )
Example #11
0
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() )
Example #12
0
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() )
Example #13
0
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())
Example #15
0
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() )
Example #16
0
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() )
Example #17
0
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() )
Example #18
0
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() )
Example #19
0
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() )
Example #20
0
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() )
Example #21
0
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() )
Example #22
0
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() )
Example #23
0
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())
Example #24
0
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() )
Example #25
0
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())
Example #26
0
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() )
Example #27
0
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())
Example #28
0
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() )
Example #29
0
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())