diff options
author | chris.sutcliffe <ctd.sutcliffe@gmail.com> | 2021-12-14 23:57:04 +0000 |
---|---|---|
committer | chris.sutcliffe <ctd.sutcliffe@gmail.com> | 2021-12-14 23:57:04 +0000 |
commit | f0e7aff793c457f830713b5b052a430997453916 (patch) | |
tree | a4c401fb7e9ef75fd609dc92237d943ff6d2f0bc /src | |
parent | e0f3fd6bd01722c72db4105f0faa13fdb2cfc412 (diff) | |
download | esotericFORTRAN-f0e7aff793c457f830713b5b052a430997453916.tar.gz esotericFORTRAN-f0e7aff793c457f830713b5b052a430997453916.zip |
add loop and conditional tests
Diffstat (limited to 'src')
-rw-r--r-- | src/testing/02_conditional_loop_testing.ft | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/testing/02_conditional_loop_testing.ft b/src/testing/02_conditional_loop_testing.ft new file mode 100644 index 0000000..b4d7c01 --- /dev/null +++ b/src/testing/02_conditional_loop_testing.ft @@ -0,0 +1,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
\ No newline at end of file |