Coverage for tests/test_real_literal_has_correct_kind.py: 100%

1# pylint: disable=W0621,C0116,C0114

2 import pytest

3

4 from castep_linter import tests

5 from castep_linter.fortran.parser import get_fortran_parser

6 from castep_linter.scan_files import run_tests_on_code

7

8

9@pytest.fixture

10 def test_list():

11 return {"number_literal": [tests.test_number_literal]}

12

13

14@pytest.fixture

15 def parser():

16 return get_fortran_parser()

17

18

19 def test_real_literal_with_dp(parser, test_list):

20 code = b"z = 1.0_dp"

21 error_log = run_tests_on_code(parser, code, test_list, "filename")

22 assert len(error_log.errors) == 0

23

24

25 def test_real_literal_with_other_kind(parser, test_list):

26 code = b"z = 1.0_sp"

27 error_log = run_tests_on_code(parser, code, test_list, "filename")

28 assert len(error_log.errors) == 1

29

30

31 def test_real_literal_missing_dp(parser, test_list):

32 code = b"z = 1.0"

33 error_log = run_tests_on_code(parser, code, test_list, "filename")

34 assert len(error_log.errors) == 1

35

36

37 def test_real_literal_missing_dp_scientific(parser, test_list):

38 code = b"z = 1.0e5"

39 error_log = run_tests_on_code(parser, code, test_list, "filename")

40 assert len(error_log.errors) == 1

41

42

43 def test_real_literal_d0(parser, test_list):

44 code = b"z = 1.0d5"

45 error_log = run_tests_on_code(parser, code, test_list, "filename")

46 assert len(error_log.errors) == 0