summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--src/testing/01_variable_testing.ft91
-rw-r--r--src/testing/02_conditional_loop_testing.ft96
3 files changed, 192 insertions, 1 deletions
diff --git a/README.md b/README.md
index ef91990..e5235a1 100644
--- a/README.md
+++ b/README.md
@@ -56,5 +56,9 @@ Extra stuff:
- [x] String stuff
- [x] Add strings
- [ ] Grab screenshots, and make point the software is cross-platform
-
+- [x] IDE reload from file
+- [ ] IDE line numbers
+- [ ] IDE icon (https://icon-icons.com/icon/Idea-bulb-light/120562)
+- [ ] IDE comment line using CTRL + /
+- [ ] Add CTRL + Backspace shortcut to remove text
diff --git a/src/testing/01_variable_testing.ft b/src/testing/01_variable_testing.ft
new file mode 100644
index 0000000..eeb886d
--- /dev/null
+++ b/src/testing/01_variable_testing.ft
@@ -0,0 +1,91 @@
+program variabletesting
+! fortran variable testing harness
+
+print*,"Testing variable logic and storage\n"
+
+! Integer testing (initialisation, addition, division etc)
+! a =7 - 4 + 2
+! a =(5+4)*(10/2)+5**2
+! print*,a
+
+print*,"Integer logic testing"
+int::x
+int::y
+int::result
+x = 5
+y = 5
+
+result = x + y
+print*,"Addition test: ",result," (should be 10)"
+result = x - y
+print*,"Subtraction test: ",result," (should be 0)"
+result = x * y
+print*,"Multiplication test: ",result," (should be 25)"
+result = x / y
+print*,"Division test: ",result," (should be 1)"
+
+
+! Real number testing
+print*,"\n\nReal number logic testing"
+real::xreal
+real::yreal
+real::resultreal
+xreal = 5
+yreal = 5
+
+resultreal = xreal + yreal
+print*,"Addition test: ",resultreal," (should be 10)"
+resultreal = xreal - yreal
+print*,"Subtraction test: ",resultreal," (should be 0)"
+resultreal = xreal * yreal
+print*,"Multiplication test: ",resultreal," (should be 25)"
+resultreal = xreal / yreal
+print*,"Division test: ",resultreal," (should be 1)"
+
+xreal = 7
+yreal = 2
+resultreal = xreal / yreal
+print*,"Division test two: ",resultreal," (should be 3.5)"
+
+resultreal = (5+4)*(10/2)+5*2
+print*,"Order of significance test: ",resultreal," (should be 55)"
+
+
+! Testing Strings handling here
+print*,"\n\nTesting string handling"
+character(len=15)::helloworld
+helloworld="Hello World!"
+print*,"Printed string: ",helloworld
+
+
+!Testing array storage
+print*,"\n\nTesting arrays"
+print*,"Storing integers and printing to console:"
+int dimension(10)::intArray
+int::i
+
+do i=0,9
+intArray(i)=i
+end do
+
+do i=0,9
+print*,intArray(i)
+end do
+
+
+print*,"\nStoring real numbers and printing to console:"
+real dimension(10)::realArray
+real::j
+j = 0.0
+
+do i=0,9
+j = j + 1
+realArray(i)=j j
+end do
+
+do i=0,9
+print*,realArray(i)
+end do
+
+
+end program variabletesting \ No newline at end of file
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