File: test_check_math.pro

package info (click to toggle)
gnudatalanguage 0.9.5-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 15,228 kB
  • ctags: 11,455
  • sloc: cpp: 143,352; makefile: 426; sh: 103; ansic: 44; awk: 18; python: 6
file content (75 lines) | stat: -rw-r--r-- 1,434 bytes parent folder | download | duplicates (8)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
; Alain Coulais
; 6 octobre 2009 a Sapporo, Hokkaido
; Under GNU GPL V2 or later
;
; Since CHECK_MATH() does contains undocumented features,
; we need a clear check of its behavior
;
;
pro DO_ERROR, type
if type EQ 0 then DO_ERROR_INT
if type EQ 1 then DO_ERROR_FLT
if type EQ 2 then DO_ERROR_ZERO
end
pro DO_ERROR_INT
a=1/0
end
pro DO_ERROR_FLT
a=1./0.
end
pro DO_ERROR_ZERO
a=0./0.
end
;
pro TEST_CHECK_MATH, type=type
;
if N_ELEMENTS(type) EQ 0 then type=1
type=ROUND(type)
if ((type LT 0) OR (type GT 2)) then begin
   print, 'TYPE is in {0,1,2}'
   return
endif
;
print, 'init:          ', check_math()
DO_ERROR, type
print, 'check_math()   ', check_math()
DO_ERROR, type
print, 'check_math(0,0)', check_math(0,0)
DO_ERROR, type
print, 'check_math(1,0)', check_math(1,0)
DO_ERROR, type
print, 'check_math(0,1)', check_math(0,1)
DO_ERROR, type
print, 'check_math(1,1)', check_math(1,1)
;

end
;
pro TEST_CHECK_MATH_CUMUL
;
; cleaning the memory
a=check_math(noclear=0)
;
a=1/0  & print,'(expected   1)', check_math(/pri,/noc)
a=1/0. & print,'(expected  17)', check_math(/pri,/noc)
a=0/0. & print,'(expected 145)', check_math(/pri,/noc)
a=check_math()
a=0/0. & print,'(expected 128)', check_math(/pri,/noc)
a=0
print,'(expected 128)', check_math()
a=0
print,'(expected   0)', check_math()
end

pro MINI_PRO
print, 'mini_pro'
a=0./0.
print, check_math()
end

print, 'program'
a=check_math()
a=0./0.
print, check_math()
MINI_PRO
end