File: test_ord.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 (22 lines) | stat: -rw-r--r-- 478 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
! Testing Python's ord intrinsic
! -- Example --
! i: i32
! s = "x"
! i = ord(s) # Equivalent in LFortran is `lfortran_ord()`

program test_ord
    implicit none

    if (_lfortran_ord("H") /= 72) error stop
    if (_lfortran_ord("c") /= 99) error stop
    if (_lfortran_ord("1") /= 49) error stop

    character(len=:), allocatable :: x 
    x = "Hello,World"


    if (_lfortran_ord(x(1)) /= 72) error stop
    if (_lfortran_ord(x(6)) /= 44) error stop

end program test_ord