summaryrefslogtreecommitdiffstats
path: root/src/testing/02_conditional_loop_testing.ft
blob: b4d7c012ef2b6408829d920afa863771ec2cf119 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
program conditionalLoopTesting
! fortran conditionals and loop testing harness
! All tests should pass

print*,"Testing variable logic and storage\n"

! Testing conditional statements if and if else 
print*,"Testing conditionals (8 tests should be displayed)"

if (5==5) then
print*,"Conditional test one: passed"
end if

if (5/=6) then
print*,"Conditional test two: passed"
end if

if(5.5==5.5) then
print*,"Conditional test three: passed"
end if

if(5.5/=6.6) then
print*,"Conditional test four: passed"
end if

if (5==6) then
print*,"Conditional test five: failed"
else
print*,"Conditional test five: passed"
end if

if (5/=5) then
print*,"Conditional six: failed"
else
print*,"Conditional six: passed"
end if

if(5.5==6.6) then
print*,"Conditional test seven: failed"
else
print*,"Conditional seven: passed"
end if

if(5.5/=5.5) then
print*,"Conditional test eight: failed"
else
print*,"Conditional test eight: passed"
end if


! These tests output as expected, so we can simplify further logical tests

print*,"\n\nTesting logic: (five tests should pass)"
if(6==6 .and. 5==5) then
print*,"Logical test one: passed"
end if

if(6==5 .and. 5==5) then
print*,"Logical test two: failed"
else
print*,"Logical test two: passed"
end if

if(6==6 .and. 5==6) then
print*,"Logical test three: failed"
else
print*,"Logical test three: passed"
end if


if(6==5 .or. 5==5) then
print*,"Logical test four: passed"
end if

if(6==5 .or. 5==6) then
print*,"Logical test five: failed"
else
print*,"Logical test five: passed"
end if


print*,"\n\nTesting looping (2 loops 1 to 10 should display)"
print*,"Looping from 1 to 10 using do statement (for loop equivalent)"
int::i
do i=0,10
print*,i
end do

print*,"\nLooping from 1 to 10 using do while statement (while loop equivalent)"
i=0
do while(i<=10)
print*,i
i=i+1
end do

end program conditionalLoopTesting