summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-09-18 02:26:21 -0400
committerOri Bernstein <ori@eigenstate.org>2014-09-18 02:26:21 -0400
commit37e8b94b73dde2743b74e642b8d7cba7e2775622 (patch)
tree085d7f6341651d09c28e078e232c5d33cd5a8d00
parent1457588b491615b8f1634a39419db9e7404c398f (diff)
downloadmc-37e8b94b73dde2743b74e642b8d7cba7e2775622.tar.gz
Add a mandelbrot test.
-rw-r--r--test/data/mandelbrot-expected79
-rw-r--r--test/mandelbrot.myr53
-rw-r--r--test/tests1
3 files changed, 133 insertions, 0 deletions
diff --git a/test/data/mandelbrot-expected b/test/data/mandelbrot-expected
new file mode 100644
index 0000000..1689d5a
--- /dev/null
+++ b/test/data/mandelbrot-expected
@@ -0,0 +1,79 @@
+ *
+ *
+ *
+ *
+ *
+ ***
+ *****
+ *****
+ ***
+ *
+ *********
+ *************
+ ***************
+ *********************
+ *********************
+ *******************
+ *******************
+ *******************
+ *******************
+ ***********************
+ *******************
+ *******************
+ *********************
+ *******************
+ *******************
+ *****************
+ ***************
+ *************
+ *********
+ *
+ ***************
+ ***********************
+ * ************************* *
+ *****************************
+ * ******************************* *
+ *********************************
+ ***********************************
+ ***************************************
+ *** ***************************************** ***
+ *************************************************
+ ***********************************************
+ *********************************************
+ *********************************************
+ ***********************************************
+ ***********************************************
+ ***************************************************
+ *************************************************
+ *************************************************
+ ***************************************************
+ ***************************************************
+ * *************************************************** *
+ ***** *************************************************** *****
+ ****** *************************************************** ******
+ ******* *************************************************** *******
+ ***********************************************************************
+ ********* *************************************************** *********
+ ****** *************************************************** ******
+ ***** *************************************************** *****
+ ***************************************************
+ ***************************************************
+ ***************************************************
+ ***************************************************
+ *************************************************
+ *************************************************
+ ***************************************************
+ ***********************************************
+ ***********************************************
+ *******************************************
+ *****************************************
+ *********************************************
+ **** ****************** ****************** ****
+ *** **************** **************** ***
+ * ************** ************** *
+ *********** ***********
+ ** ***** ***** **
+ * * * *
+
+
+
diff --git a/test/mandelbrot.myr b/test/mandelbrot.myr
new file mode 100644
index 0000000..d948544
--- /dev/null
+++ b/test/mandelbrot.myr
@@ -0,0 +1,53 @@
+use std
+use bio
+
+const Bailout : flt64 = 16.0
+const Maxiter = 1000
+
+const mandelbrot = {x, y
+ var cr, ci, zr, zi
+ var tmp, zr2, zi2
+ var i : int
+
+ cr = y - 0.5
+ ci = x
+ zr = 0.0
+ zi = 0.0
+
+ i = 0
+
+ while true
+ i++
+ tmp = zr * zi
+ zr2 = zr * zr
+ zi2 = zi * zi
+ zr = zr2 - zi2 + cr
+ zi = tmp + tmp + ci
+ if zi2 + zr2 > Bailout
+ -> i
+ ;;
+ if i > Maxiter
+ -> 0
+ ;;
+ ;;
+}
+
+const main = {args : byte[:][:]
+ var x : flt64, y : flt64, i
+ var f
+
+ f = bio.mkfile(1, bio.Wr)
+ for y = -39.0; y < 39.0; y = y + 1.0
+ for x = -39.0; x < 39.0; x = x + 1.0
+ i = mandelbrot(x/40.0, y/40.0)
+ if i == 0
+ bio.write(f, "*")
+ else
+ bio.write(f, " ")
+ ;;
+ ;;
+ bio.write(f, "\n")
+ ;;
+ bio.write(f, "\n")
+ bio.close(f)
+}
diff --git a/test/tests b/test/tests
index eb5faf8..8a0ef69 100644
--- a/test/tests
+++ b/test/tests
@@ -71,6 +71,7 @@ B overlappingif E 2
B fib E 21
B basicfloat E 84
B sqrt E 4
+B mandelbrot C
B log-and E 0
B log-or E 1
B str E 102