File: character_13.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (32 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module character_13_mod
    integer, parameter :: tfc = selected_char_kind('DEFAULT')
    character(kind=tfc, len=1) :: backslash = tfc_'\'
    character(kind=tfc, len=5) :: hello = tfc_"Hello"
end module

program character_13
    use character_13_mod
    ! Test character kind parameter with string literals
    type :: toml_char
        character(1, tfc) :: hash = tfc_"#"
        character(1, tfc) :: lbracket = tfc_"["
        character(1, tfc) :: rbracket = tfc_"]"
    end type
    
    type(toml_char) :: char_kind
    
    ! Test default initialization
    if (char_kind%hash /= "#") error stop
    if (char_kind%lbracket /= "[") error stop
    if (char_kind%rbracket /= "]") error stop
    
    ! Test explicit initialization
    char_kind = toml_char(tfc_"@", tfc_"(", tfc_")")
    if (char_kind%hash /= "@") error stop
    if (char_kind%lbracket /= "(") error stop
    if (char_kind%rbracket /= ")") error stop

    ! Test module level character variables
    if (backslash /= "\") error stop
    if (hello /= "Hello") error stop
end program character_13