fUnit 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/{LICENSE → COPYING} +21 -21
  2. data/README +26 -2
  3. data/Rakefile +97 -0
  4. data/docs/html/classes/Funit.html +390 -0
  5. data/docs/html/classes/Funit/Assertions.html +285 -0
  6. data/docs/html/classes/Funit/Compiler.html +160 -0
  7. data/docs/html/classes/Funit/Depend.html +441 -0
  8. data/docs/html/classes/Funit/TestSuite.html +417 -0
  9. data/docs/html/created.rid +1 -0
  10. data/docs/html/files/COPYING.html +563 -0
  11. data/docs/html/files/README.html +151 -0
  12. data/docs/html/files/lib/funit/assertions_rb.html +101 -0
  13. data/docs/html/files/lib/funit/fortran_deps_rb.html +107 -0
  14. data/docs/html/files/lib/funit/functions_rb.html +101 -0
  15. data/docs/html/files/lib/funit/test_suite_rb.html +101 -0
  16. data/docs/html/files/lib/funit_rb.html +111 -0
  17. data/docs/html/fr_class_index.html +31 -0
  18. data/docs/html/fr_file_index.html +33 -0
  19. data/docs/html/fr_method_index.html +59 -0
  20. data/docs/html/index.html +24 -0
  21. data/docs/html/rdoc-style.css +208 -0
  22. data/examples/CFD/FluxFunctions.f90 +35 -0
  23. data/examples/CFD/FluxFunctionsMT.f90 +336 -0
  24. data/examples/CFD/FluxFunctionsMT.ftk +49 -0
  25. data/examples/CFD/Gammas.f90 +8 -0
  26. data/examples/CFD/GasModel.f90 +17 -0
  27. data/examples/CFD/GasModelMT.f90 +173 -0
  28. data/examples/CFD/GasModelMT.ftk +22 -0
  29. data/examples/CFD/TestRunner +0 -0
  30. data/examples/CFD/TestRunner.f90 +23 -0
  31. data/examples/CFD/fluxfunctions.mod +45 -0
  32. data/examples/CFD/gammas.mod +20 -0
  33. data/examples/CFD/gasmodel.mod +30 -0
  34. data/examples/CFD/gasmodelmt.mod +27 -0
  35. data/examples/StopWatch/StopWatch.f90 +50 -0
  36. data/examples/StopWatch/StopWatchMT.f90 +343 -0
  37. data/examples/StopWatch/StopWatchMT.ftk +73 -0
  38. data/examples/StopWatch/TestRunner +0 -0
  39. data/examples/StopWatch/TestRunner.f90 +23 -0
  40. data/examples/StopWatch/stopwatch.mod +34 -0
  41. data/examples/StopWatch/stopwatchmt.mod +27 -0
  42. data/lib/funit.rb +1 -6
  43. data/lib/funit/fortran_deps.rb +112 -0
  44. data/lib/funit/functions.rb +2 -5
  45. data/tests/tc_fortran_deps.rb +2 -2
  46. metadata +73 -22
  47. data/INSTALL +0 -19
  48. data/lib/fortran_deps.rb +0 -109
@@ -0,0 +1,173 @@
1
+ ! GasModelMT.f90 - a Fortran mobility test suite for GasModel.f90
2
+ !
3
+ ! [dynamically generated from GasModelMT.ftk
4
+ ! by funit Ruby script Sun Apr 09 01:08:39 EDT 2006]
5
+
6
+ module GasModelMT
7
+
8
+ use GasModel
9
+
10
+ implicit none
11
+
12
+ private
13
+
14
+ public :: MTGasModel
15
+
16
+ logical :: noAssertFailed
17
+
18
+ integer :: numTests = 0
19
+ integer :: numAsserts = 0
20
+ integer :: numAssertsTested = 0
21
+ integer :: numFailures = 0
22
+
23
+ ! $Id: GasModelTS.ftk 91 2001-11-13 20:46:28Z cvs4bk $
24
+
25
+ real :: Pressure, Density, Energy
26
+
27
+ contains
28
+
29
+ subroutine TestPerfectPZeroed
30
+
31
+ real, parameter :: zero = 0
32
+ call PerfectP (zero, zero, Pressure)
33
+
34
+ ! IsRealEqual assertion
35
+ numAsserts = numAsserts + 1
36
+ if (noAssertFailed) then
37
+ if (.not.(Pressure+2*spacing(real(Pressure)).ge. 0 &
38
+ .and.Pressure-2*spacing(real(Pressure)).le. 0 )) then
39
+ print *, " *IsRealEqual failed* in test PerfectPZeroed &
40
+ &[GasModelMT.ftk:8]"
41
+ print *, " ", " 0 (", 0 ,") is not",Pressure,"within",2*spacing(real(Pressure))
42
+ print *, ""
43
+ noAssertFailed = .false.
44
+ numFailures = numFailures + 1
45
+ else
46
+ numAssertsTested = numAssertsTested + 1
47
+ endif
48
+ endif
49
+
50
+ ! IsEqualWithin assertion
51
+ numAsserts = numAsserts + 1
52
+ if (noAssertFailed) then
53
+ if (.not.( 0+ 0.0000000001 .ge. Pressure &
54
+ .and. 0- 0.0000000001 .le. Pressure)) then
55
+ print *, " *IsEqualWithin failed* in test PerfectPZeroed &
56
+ &[GasModelMT.ftk:9]"
57
+ print *, " ", " Pressure (", Pressure,") is not", 0,"within", 0.0000000001
58
+ print *, ""
59
+ noAssertFailed = .false.
60
+ numFailures = numFailures + 1
61
+ else
62
+ numAssertsTested = numAssertsTested + 1
63
+ endif
64
+ endif
65
+
66
+ numTests = numTests + 1
67
+
68
+ end subroutine TestPerfectPZeroed
69
+
70
+
71
+ subroutine TestWarbler
72
+
73
+
74
+ numTests = numTests + 1
75
+
76
+ end subroutine TestWarbler
77
+
78
+
79
+ subroutine TestPerfectPKnown
80
+
81
+ real :: Density = 1
82
+ Energy = 1
83
+ call PerfectP( Density, Energy, Pressure )
84
+
85
+ ! IsRealEqual assertion
86
+ numAsserts = numAsserts + 1
87
+ if (noAssertFailed) then
88
+ if (.not.( Pressure+2*spacing(real( Pressure)).ge. 0.4 &
89
+ .and. Pressure-2*spacing(real( Pressure)).le. 0.4 )) then
90
+ print *, " *IsRealEqual failed* in test PerfectPKnown &
91
+ &[GasModelMT.ftk:19]"
92
+ print *, " ", " 0.4 (", 0.4 ,") is not", Pressure,"within",2*spacing(real( Pressure))
93
+ print *, ""
94
+ noAssertFailed = .false.
95
+ numFailures = numFailures + 1
96
+ else
97
+ numAssertsTested = numAssertsTested + 1
98
+ endif
99
+ endif
100
+
101
+ ! IsTrue assertion
102
+ numAsserts = numAsserts + 1
103
+ if (noAssertFailed) then
104
+ if (.not.( Pressure .gt. 0 )) then
105
+ print *, " *IsTrue failed* in test PerfectPKnown &
106
+ &[GasModelMT.ftk:20]"
107
+ print *, " ", " Pressure .gt. 0 is not true"
108
+ print *, ""
109
+ noAssertFailed = .false.
110
+ numFailures = numFailures + 1
111
+ else
112
+ numAssertsTested = numAssertsTested + 1
113
+ endif
114
+ endif
115
+
116
+ ! IsFalse assertion
117
+ numAsserts = numAsserts + 1
118
+ if (noAssertFailed) then
119
+ if ( Pressure .lt. 0 ) then
120
+ print *, " *IsFalse failed* in test PerfectPKnown &
121
+ &[GasModelMT.ftk:21]"
122
+ print *, " ", " Pressure .lt. 0 is not false"
123
+ print *, ""
124
+ noAssertFailed = .false.
125
+ numFailures = numFailures + 1
126
+ else
127
+ numAssertsTested = numAssertsTested + 1
128
+ endif
129
+ endif
130
+
131
+ numTests = numTests + 1
132
+
133
+ end subroutine TestPerfectPKnown
134
+
135
+
136
+ subroutine Setup
137
+ noAssertFailed = .true.
138
+ end subroutine Setup
139
+
140
+
141
+ subroutine Teardown
142
+ end subroutine Teardown
143
+
144
+
145
+ subroutine MTGasModel( nTests, nAsserts, nAssertsTested, nFailures )
146
+
147
+ integer :: nTests
148
+ integer :: nAsserts
149
+ integer :: nAssertsTested
150
+ integer :: nFailures
151
+
152
+ continue
153
+
154
+ call Setup
155
+ call TestPerfectPZeroed
156
+ call Teardown
157
+
158
+ call Setup
159
+ call TestWarbler
160
+ call Teardown
161
+
162
+ call Setup
163
+ call TestPerfectPKnown
164
+ call Teardown
165
+
166
+ nTests = numTests
167
+ nAsserts = numAsserts
168
+ nAssertsTested = numAssertsTested
169
+ nFailures = numFailures
170
+
171
+ end subroutine MTGasModel
172
+
173
+ end module GasModelMT
@@ -0,0 +1,22 @@
1
+ ! $Id: GasModelTS.ftk 91 2001-11-13 20:46:28Z cvs4bk $
2
+
3
+ real :: Pressure, Density, Energy
4
+
5
+ beginTest PerfectPZeroed
6
+ real, parameter :: zero = 0
7
+ call PerfectP (zero, zero, Pressure)
8
+ isRealEqual (Pressure, 0 )
9
+ IsEqualwithin ( Pressure, 0, 0.0000000001 )
10
+ endTest
11
+
12
+ begintest Warbler
13
+ endtest
14
+
15
+ beginTest PerfectPKnown
16
+ real :: Density = 1
17
+ Energy = 1
18
+ call PerfectP( Density, Energy, Pressure )
19
+ IsRealEqual( Pressure, 0.4 )
20
+ IsTrue ( Pressure .gt. 0 )
21
+ IsFalse( Pressure .lt. 0 )
22
+ endTest
Binary file
@@ -0,0 +1,23 @@
1
+ ! TestRunner.f90 - runs Fortran mobility test suites
2
+ !
3
+ ! [Dynamically generated by funit Ruby script Sun Apr 09 01:08:39 EDT 2006.]
4
+
5
+ program TestRunner
6
+
7
+ use GasModelMT
8
+
9
+ implicit none
10
+
11
+ integer :: numTests, numAsserts, numAssertsTested, numFailures
12
+
13
+ print *, ""
14
+ print *, "GasModel test suite:"
15
+ call MTGasModel( numTests, &
16
+ numAsserts, numAssertsTested, numFailures )
17
+ print *, "Passed", numAssertsTested, "of", numAsserts, &
18
+ "possible asserts comprising", &
19
+ numTests-numFailures, "of", numTests, "tests."
20
+
21
+ print *, ""
22
+
23
+ end program TestRunner
@@ -0,0 +1,45 @@
1
+ G95 module created on Sun Apr 9 01:07:49 2006 from ./FluxFunctions.f90
2
+ If you edit this, you'll get what you deserve.
3
+
4
+ (() () () () () () () () () () () () () () () () () () () () ())
5
+
6
+ ()
7
+
8
+ ()
9
+
10
+ ()
11
+
12
+ ()
13
+
14
+ (2 'centralflux' 'fluxfunctions' 1 ((PROCEDURE UNKNOWN MODULE-PROC DECL
15
+ SUBROUTINE) (PROCEDURE 0 ()) 0 0 (3 NONE 4 NONE 5 NONE) () '' () ())
16
+ 6 'roeavg' 'fluxfunctions' 1 ((PROCEDURE UNKNOWN MODULE-PROC DECL
17
+ FUNCTION) (REAL 4 ()) 0 0 (7 NONE 8 NONE) () '' () ())
18
+ 9 'fluxfunctions' 'fluxfunctions' 1 ((MODULE UNKNOWN UNKNOWN UNKNOWN) (
19
+ UNKNOWN 0 ()) 0 0 () () '' () ())
20
+ 10 'roeflux' 'fluxfunctions' 1 ((PROCEDURE UNKNOWN MODULE-PROC DECL
21
+ SUBROUTINE) (PROCEDURE 0 ()) 0 0 (11 NONE 12 NONE 13 NONE) () '' () ())
22
+ 14 'flux' 'fluxfunctions' 1 ((PROCEDURE UNKNOWN MODULE-PROC DECL
23
+ FUNCTION) (REAL 4 ()) 0 0 (15 NONE) () '' () ())
24
+ 4 'rightstate' '' 16 ((VARIABLE IN UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0
25
+ 0 () () '' () ())
26
+ 11 'leftstate' '' 17 ((VARIABLE IN UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0
27
+ 0 () () '' () ())
28
+ 12 'rightstate' '' 17 ((VARIABLE IN UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0
29
+ 0 () () '' () ())
30
+ 5 'interfaceflux' '' 16 ((VARIABLE OUT UNKNOWN UNKNOWN DUMMY) (REAL 4 ())
31
+ 0 0 () () '' () ())
32
+ 13 'interfaceflux' '' 17 ((VARIABLE OUT UNKNOWN UNKNOWN DUMMY) (REAL 4 ())
33
+ 0 0 () () '' () ())
34
+ 15 'state' '' 18 ((VARIABLE IN UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0 0 ()
35
+ () '' () ())
36
+ 7 'leftstate' '' 19 ((VARIABLE IN UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0 0
37
+ () () '' () ())
38
+ 8 'rightstate' '' 19 ((VARIABLE IN UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0
39
+ 0 () () '' () ())
40
+ 3 'leftstate' '' 16 ((VARIABLE IN UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0 0
41
+ () () '' () ())
42
+ )
43
+
44
+ ('flux' 0 14 'centralflux' 0 2 'roeflux' 0 10 'fluxfunctions' 0 9 'roeavg'
45
+ 0 6)
@@ -0,0 +1,20 @@
1
+ G95 module created on Sun Apr 9 01:07:49 2006 from ./Gammas.f90
2
+ If you edit this, you'll get what you deserve.
3
+
4
+ (() () () () () () () () () () () () () () () () () () () () ())
5
+
6
+ ()
7
+
8
+ ()
9
+
10
+ ()
11
+
12
+ ()
13
+
14
+ (2 'gamma' 'gammas' 1 ((PARAMETER UNKNOWN UNKNOWN UNKNOWN) (REAL 4 ()) 0
15
+ 0 () (CONSTANT (REAL 4 ()) 0 '11744051' 0 127) () '' () ())
16
+ 3 'gammas' 'gammas' 1 ((MODULE UNKNOWN UNKNOWN UNKNOWN) (UNKNOWN 0 ()) 0
17
+ 0 () () '' () ())
18
+ )
19
+
20
+ ('gammas' 0 3 'gamma' 0 2)
@@ -0,0 +1,30 @@
1
+ G95 module created on Sun Apr 9 01:07:49 2006 from ./GasModel.f90
2
+ If you edit this, you'll get what you deserve.
3
+
4
+ (() () () () () () () () () () () () () () () () () () () () ())
5
+
6
+ ()
7
+
8
+ ()
9
+
10
+ ()
11
+
12
+ ()
13
+
14
+ (2 'gamma' 'gammas' 1 ((PARAMETER UNKNOWN UNKNOWN UNKNOWN) (REAL 4 ()) 0
15
+ 0 () (CONSTANT (REAL 4 ()) 0 '11744051' 0 127) () '' () ())
16
+ 3 'gammas' 'gammas' 1 ((MODULE UNKNOWN UNKNOWN UNKNOWN) (UNKNOWN 0 ()) 0
17
+ 0 () () '' () ())
18
+ 4 'perfectp' 'gasmodel' 1 ((PROCEDURE UNKNOWN MODULE-PROC DECL
19
+ SUBROUTINE) (PROCEDURE 0 ()) 0 0 (5 NONE 6 NONE 7 NONE) () '' () ())
20
+ 8 'gasmodel' 'gasmodel' 1 ((MODULE UNKNOWN UNKNOWN UNKNOWN) (UNKNOWN 0 ())
21
+ 0 0 () () '' () ())
22
+ 5 'density' '' 9 ((VARIABLE IN UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0 0 ()
23
+ () '' () ())
24
+ 7 'pressure' '' 9 ((VARIABLE OUT UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0 0
25
+ () () '' () ())
26
+ 6 'energy' '' 9 ((VARIABLE IN UNKNOWN UNKNOWN DUMMY) (REAL 4 ()) 0 0 ()
27
+ () '' () ())
28
+ )
29
+
30
+ ('gasmodel' 0 8 'gammas' 0 3 'gamma' 0 2 'perfectp' 0 4)
@@ -0,0 +1,27 @@
1
+ G95 module created on Sun Apr 9 01:07:49 2006 from ./GasModelMT.f90
2
+ If you edit this, you'll get what you deserve.
3
+
4
+ (() () () () () () () () () () () () () () () () () () () () ())
5
+
6
+ ()
7
+
8
+ ()
9
+
10
+ ()
11
+
12
+ ()
13
+
14
+ (2 'mtgasmodel' 'gasmodelmt' 1 ((PROCEDURE UNKNOWN MODULE-PROC DECL
15
+ SUBROUTINE) (PROCEDURE 0 ()) 0 0 (3 NONE 4 NONE 5 NONE 6 NONE) () '' ()
16
+ ())
17
+ 3 'ntests' '' 7 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN DUMMY) (INTEGER 4 ())
18
+ 0 0 () () '' () ())
19
+ 4 'nasserts' '' 7 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN DUMMY) (INTEGER 4 ())
20
+ 0 0 () () '' () ())
21
+ 6 'nfailures' '' 7 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN DUMMY) (INTEGER 4
22
+ ()) 0 0 () () '' () ())
23
+ 5 'nassertstested' '' 7 ((VARIABLE UNKNOWN UNKNOWN UNKNOWN DUMMY) (
24
+ INTEGER 4 ()) 0 0 () () '' () ())
25
+ )
26
+
27
+ ('mtgasmodel' 0 2)
@@ -0,0 +1,50 @@
1
+ module StopWatch
2
+
3
+ implicit none
4
+
5
+ public
6
+
7
+ logical :: notInitialized = .TRUE.
8
+
9
+ integer, dimension(8) :: last
10
+
11
+ contains
12
+
13
+ real function SecBetween(beginDnT, endDnT)
14
+ integer, dimension(8), intent(in) :: beginDnT, endDnT
15
+ real :: days, hours, minutes, seconds
16
+ integer, parameter :: yr=1, mo=2, day=3, utc=4, hr=5, mn=6, s=7, ms=8
17
+
18
+ continue
19
+
20
+ if ( endDnT(day) == beginDnT(day) ) then
21
+ days = 0
22
+ else
23
+ days = 1 ! note: assuming one day
24
+ endif
25
+
26
+ hours = endDnT(hr) - beginDnT(hr) + 24*days
27
+ minutes = endDnT(mn) - beginDnT(mn) + 60*hours
28
+ seconds = endDnT(s) - beginDnT(s) + 60*minutes
29
+
30
+ SecBetween = seconds + ( endDnT(ms) - beginDnT(ms) ) / 1000.
31
+
32
+ end function SecBetween
33
+
34
+ real function secSinceLast()
35
+
36
+ integer, dimension(8) :: now
37
+
38
+ if (notInitialized) then
39
+ notInitialized = .FALSE.
40
+ secSinceLast = 0.0
41
+ call date_and_time(values=last)
42
+ else
43
+ call date_and_time(values=now)
44
+ secSinceLast = secBetween(last, now)
45
+ last = now
46
+ endif
47
+
48
+ end function secSinceLast
49
+
50
+ end module StopWatch
@@ -0,0 +1,343 @@
1
+ ! StopWatchMT.f90 - a Fortran mobility test suite for StopWatch.f90
2
+ !
3
+ ! [dynamically generated from StopWatchMT.ftk
4
+ ! by funit Ruby script Sun Apr 09 01:07:09 EDT 2006]
5
+
6
+ module StopWatchMT
7
+
8
+ use StopWatch
9
+
10
+ implicit none
11
+
12
+ private
13
+
14
+ public :: MTStopWatch
15
+
16
+ logical :: noAssertFailed
17
+
18
+ integer :: numTests = 0
19
+ integer :: numAsserts = 0
20
+ integer :: numAssertsTested = 0
21
+ integer :: numFailures = 0
22
+
23
+ integer, dimension(8) :: dateAndTime1, dateAndTime2
24
+ real :: seconds
25
+
26
+ contains
27
+
28
+
29
+ subroutine TestSystemDateAndTimeWorks
30
+
31
+ call date_and_time(values=dateAndTime1)
32
+
33
+ ! IsTrue assertion
34
+ numAsserts = numAsserts + 1
35
+ if (noAssertFailed) then
36
+ if (.not.( dateAndTime1(1) /= -huge(0) )) then
37
+ print *, " *IsTrue failed* in test SystemDateAndTimeWorks &
38
+ &[StopWatchMT.ftk:12]"
39
+ print *, " ", " dateAndTime1(1) /= -huge(0) is not true"
40
+ print *, ""
41
+ noAssertFailed = .false.
42
+ numFailures = numFailures + 1
43
+ else
44
+ numAssertsTested = numAssertsTested + 1
45
+ endif
46
+ endif
47
+
48
+ ! IsTrue assertion
49
+ numAsserts = numAsserts + 1
50
+ if (noAssertFailed) then
51
+ if (.not.( size(dateAndTime1,1) == 8 )) then
52
+ print *, " *IsTrue failed* in test SystemDateAndTimeWorks &
53
+ &[StopWatchMT.ftk:13]"
54
+ print *, " ", " size(dateAndTime1,1) == 8 is not true"
55
+ print *, ""
56
+ noAssertFailed = .false.
57
+ numFailures = numFailures + 1
58
+ else
59
+ numAssertsTested = numAssertsTested + 1
60
+ endif
61
+ endif
62
+
63
+ numTests = numTests + 1
64
+
65
+ end subroutine TestSystemDateAndTimeWorks
66
+
67
+
68
+ ! test secBetween
69
+ subroutine TestOneMSecDifference
70
+
71
+ dateAndTime1 = (/ 2000, 1, 1, 0, 0, 0, 0, 0 /)
72
+ dateAndTime2 = (/ 2000, 1, 1, 0, 0, 0, 0, 1 /)
73
+ seconds = SecBetween(dateAndTime1, dateAndTime2)
74
+
75
+ ! IsRealEqual assertion
76
+ numAsserts = numAsserts + 1
77
+ if (noAssertFailed) then
78
+ if (.not.(seconds+2*spacing(real(seconds)).ge. 0.001 &
79
+ .and.seconds-2*spacing(real(seconds)).le. 0.001)) then
80
+ print *, " *IsRealEqual failed* in test OneMSecDifference &
81
+ &[StopWatchMT.ftk:21]"
82
+ print *, " ", " 0.001 (", 0.001,") is not",seconds,"within",2*spacing(real(seconds))
83
+ print *, ""
84
+ noAssertFailed = .false.
85
+ numFailures = numFailures + 1
86
+ else
87
+ numAssertsTested = numAssertsTested + 1
88
+ endif
89
+ endif
90
+
91
+ numTests = numTests + 1
92
+
93
+ end subroutine TestOneMSecDifference
94
+
95
+
96
+ subroutine TestMinuteRollover
97
+
98
+ dateAndTime1 = (/ 2000, 1, 1, 0, 0, 0,59, 0 /)
99
+ dateAndTime2 = (/ 2000, 1, 1, 0, 0, 1, 0, 0 /)
100
+ seconds = SecBetween(dateAndTime1, dateAndTime2)
101
+
102
+ ! IsRealEqual assertion
103
+ numAsserts = numAsserts + 1
104
+ if (noAssertFailed) then
105
+ if (.not.(seconds+2*spacing(real(seconds)).ge. 1.0 &
106
+ .and.seconds-2*spacing(real(seconds)).le. 1.0)) then
107
+ print *, " *IsRealEqual failed* in test MinuteRollover &
108
+ &[StopWatchMT.ftk:28]"
109
+ print *, " ", " 1.0 (", 1.0,") is not",seconds,"within",2*spacing(real(seconds))
110
+ print *, ""
111
+ noAssertFailed = .false.
112
+ numFailures = numFailures + 1
113
+ else
114
+ numAssertsTested = numAssertsTested + 1
115
+ endif
116
+ endif
117
+
118
+ numTests = numTests + 1
119
+
120
+ end subroutine TestMinuteRollover
121
+
122
+
123
+ ! test secSinceLast
124
+ subroutine TestInitializationState
125
+
126
+
127
+ ! IsTrue assertion
128
+ numAsserts = numAsserts + 1
129
+ if (noAssertFailed) then
130
+ if (.not.(notInitialized)) then
131
+ print *, " *IsTrue failed* in test InitializationState &
132
+ &[StopWatchMT.ftk:33]"
133
+ print *, " ", "notInitialized is not true"
134
+ print *, ""
135
+ noAssertFailed = .false.
136
+ numFailures = numFailures + 1
137
+ else
138
+ numAssertsTested = numAssertsTested + 1
139
+ endif
140
+ endif
141
+ seconds = secSinceLast()
142
+
143
+ ! IsFalse assertion
144
+ numAsserts = numAsserts + 1
145
+ if (noAssertFailed) then
146
+ if (notInitialized) then
147
+ print *, " *IsFalse failed* in test InitializationState &
148
+ &[StopWatchMT.ftk:35]"
149
+ print *, " ", "notInitialized is not false"
150
+ print *, ""
151
+ noAssertFailed = .false.
152
+ numFailures = numFailures + 1
153
+ else
154
+ numAssertsTested = numAssertsTested + 1
155
+ endif
156
+ endif
157
+ seconds = secSinceLast()
158
+
159
+ ! IsFalse assertion
160
+ numAsserts = numAsserts + 1
161
+ if (noAssertFailed) then
162
+ if (notInitialized) then
163
+ print *, " *IsFalse failed* in test InitializationState &
164
+ &[StopWatchMT.ftk:37]"
165
+ print *, " ", "notInitialized is not false"
166
+ print *, ""
167
+ noAssertFailed = .false.
168
+ numFailures = numFailures + 1
169
+ else
170
+ numAssertsTested = numAssertsTested + 1
171
+ endif
172
+ endif
173
+
174
+ numTests = numTests + 1
175
+
176
+ end subroutine TestInitializationState
177
+
178
+
179
+ subroutine TestInitiallyReturnsZero
180
+
181
+ seconds = secSinceLast()
182
+
183
+ ! IsRealEqual assertion
184
+ numAsserts = numAsserts + 1
185
+ if (noAssertFailed) then
186
+ if (.not.(seconds+2*spacing(real(seconds)).ge. 0.0 &
187
+ .and.seconds-2*spacing(real(seconds)).le. 0.0)) then
188
+ print *, " *IsRealEqual failed* in test InitiallyReturnsZero &
189
+ &[StopWatchMT.ftk:42]"
190
+ print *, " ", " 0.0 (", 0.0,") is not",seconds,"within",2*spacing(real(seconds))
191
+ print *, ""
192
+ noAssertFailed = .false.
193
+ numFailures = numFailures + 1
194
+ else
195
+ numAssertsTested = numAssertsTested + 1
196
+ endif
197
+ endif
198
+ call timeDelay(seconds)
199
+ seconds = secSinceLast()
200
+
201
+ ! IsTrue assertion
202
+ numAsserts = numAsserts + 1
203
+ if (noAssertFailed) then
204
+ if (.not.( seconds /= 0.0 )) then
205
+ print *, " *IsTrue failed* in test InitiallyReturnsZero &
206
+ &[StopWatchMT.ftk:45]"
207
+ print *, " ", " seconds /= 0.0 is not true"
208
+ print *, ""
209
+ noAssertFailed = .false.
210
+ numFailures = numFailures + 1
211
+ else
212
+ numAssertsTested = numAssertsTested + 1
213
+ endif
214
+ endif
215
+
216
+ numTests = numTests + 1
217
+
218
+ end subroutine TestInitiallyReturnsZero
219
+
220
+
221
+ subroutine timeDelay (sum)
222
+ integer :: i
223
+ real :: sum
224
+ do i = 1, 1000000
225
+ sum = sum + i
226
+ enddo
227
+ end subroutine timeDelay
228
+
229
+ subroutine TestComputesSeconds
230
+
231
+ seconds = secSinceLast()
232
+ call timeDelay (seconds)
233
+ seconds = secSinceLast()
234
+
235
+ ! IsTrue assertion
236
+ numAsserts = numAsserts + 1
237
+ if (noAssertFailed) then
238
+ if (.not.( seconds > 0.0 )) then
239
+ print *, " *IsTrue failed* in test ComputesSeconds &
240
+ &[StopWatchMT.ftk:60]"
241
+ print *, " ", " seconds > 0.0 is not true"
242
+ print *, ""
243
+ noAssertFailed = .false.
244
+ numFailures = numFailures + 1
245
+ else
246
+ numAssertsTested = numAssertsTested + 1
247
+ endif
248
+ endif
249
+
250
+ numTests = numTests + 1
251
+
252
+ end subroutine TestComputesSeconds
253
+
254
+
255
+ subroutine TestComputesSecondsSpecial
256
+
257
+ real :: expectedSeconds
258
+
259
+ seconds = secSinceLast()
260
+ dateAndTime1 = last
261
+ call timeDelay (seconds)
262
+ seconds = secSinceLast()
263
+ dateAndTime2 = last
264
+ expectedSeconds = secBetween(dateAndTime1,dateAndTime2)
265
+
266
+ ! IsRealEqual assertion
267
+ numAsserts = numAsserts + 1
268
+ if (noAssertFailed) then
269
+ if (.not.(seconds+2*spacing(real(seconds)).ge. expectedSeconds &
270
+ .and.seconds-2*spacing(real(seconds)).le. expectedSeconds)) then
271
+ print *, " *IsRealEqual failed* in test ComputesSecondsSpecial &
272
+ &[StopWatchMT.ftk:72]"
273
+ print *, " ", " expectedSeconds (", expectedSeconds,") is not",seconds,"within",2*spacing(real(seconds))
274
+ print *, ""
275
+ noAssertFailed = .false.
276
+ numFailures = numFailures + 1
277
+ else
278
+ numAssertsTested = numAssertsTested + 1
279
+ endif
280
+ endif
281
+
282
+ numTests = numTests + 1
283
+
284
+ end subroutine TestComputesSecondsSpecial
285
+
286
+
287
+ subroutine Setup
288
+ NotInitialized = .TRUE.
289
+ last = 0
290
+ seconds = HUGE(0.0)
291
+ noAssertFailed = .true.
292
+ end subroutine Setup
293
+
294
+
295
+ subroutine Teardown
296
+ end subroutine Teardown
297
+
298
+
299
+ subroutine MTStopWatch( nTests, nAsserts, nAssertsTested, nFailures )
300
+
301
+ integer :: nTests
302
+ integer :: nAsserts
303
+ integer :: nAssertsTested
304
+ integer :: nFailures
305
+
306
+ continue
307
+
308
+ call Setup
309
+ call TestSystemDateAndTimeWorks
310
+ call Teardown
311
+
312
+ call Setup
313
+ call TestOneMSecDifference
314
+ call Teardown
315
+
316
+ call Setup
317
+ call TestMinuteRollover
318
+ call Teardown
319
+
320
+ call Setup
321
+ call TestInitializationState
322
+ call Teardown
323
+
324
+ call Setup
325
+ call TestInitiallyReturnsZero
326
+ call Teardown
327
+
328
+ call Setup
329
+ call TestComputesSeconds
330
+ call Teardown
331
+
332
+ call Setup
333
+ call TestComputesSecondsSpecial
334
+ call Teardown
335
+
336
+ nTests = numTests
337
+ nAsserts = numAsserts
338
+ nAssertsTested = numAssertsTested
339
+ nFailures = numFailures
340
+
341
+ end subroutine MTStopWatch
342
+
343
+ end module StopWatchMT