summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/testing/01_variable_testing.ft91
1 files changed, 91 insertions, 0 deletions
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