summaryrefslogtreecommitdiffstats
path: root/dimension
diff options
context:
space:
mode:
Diffstat (limited to 'dimension')
-rw-r--r--dimension/Makefile.am8
-rw-r--r--dimension/bench/Makefile.am35
-rw-r--r--dimension/bench/bench.pov118
-rwxr-xr-xdimension/bench/parse.sh59
-rwxr-xr-xdimension/bench/render.sh25
-rwxr-xr-xdimension/bench/tokenize.sh24
-rw-r--r--dimension/tests/Makefile.am55
-rw-r--r--dimension/tests/arithexp.pov218
-rwxr-xr-xdimension/tests/arithexp.sh35
-rw-r--r--dimension/tests/csg.pov65
-rwxr-xr-xdimension/tests/csg.sh94
-rw-r--r--dimension/tests/demo.pov150
-rwxr-xr-xdimension/tests/demo.sh220
-rw-r--r--dimension/tests/directives.inc21
-rw-r--r--dimension/tests/directives.pov92
-rwxr-xr-xdimension/tests/directives.sh124
-rw-r--r--dimension/tests/integer-overflow.pov25
-rwxr-xr-xdimension/tests/integer-overflow.sh35
-rw-r--r--dimension/tests/invalid-macro.pov26
-rwxr-xr-xdimension/tests/invalid-macro.sh23
-rw-r--r--dimension/tests/labels.pov31
-rwxr-xr-xdimension/tests/labels.sh29
-rw-r--r--dimension/tests/numeric.pov30
-rwxr-xr-xdimension/tests/numeric.sh43
-rw-r--r--dimension/tests/punctuation.pov24
-rwxr-xr-xdimension/tests/punctuation.sh29
-rw-r--r--dimension/tests/strings.pov21
-rwxr-xr-xdimension/tests/strings.sh29
-rw-r--r--dimension/tests/tbuffer-overlap.pov22
-rwxr-xr-xdimension/tests/tbuffer-overlap.sh23
-rw-r--r--dimension/tests/transformations.pov39
-rwxr-xr-xdimension/tests/transformations.sh64
32 files changed, 1836 insertions, 0 deletions
diff --git a/dimension/Makefile.am b/dimension/Makefile.am
index 4eaf64a..72aaad9 100644
--- a/dimension/Makefile.am
+++ b/dimension/Makefile.am
@@ -17,6 +17,9 @@
## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
###########################################################################
+SUBDIRS = bench \
+ tests
+
# Make dmnsn_error() backtraces useful
AM_LDFLAGS = -rdynamic
@@ -78,3 +81,8 @@ dimension_SOURCES = directives.y \
y.tab.h
dimension_LDADD = $(top_builddir)/libdimension/libdimension.la
dimension_LDFLAGS = $(AM_LDFLAGS)
+
+bench: all-recursive
+ cd bench && $(MAKE) $(AM_MAKEFLAGS) bench
+
+.PHONY: bench
diff --git a/dimension/bench/Makefile.am b/dimension/bench/Makefile.am
new file mode 100644
index 0000000..e7fe03f
--- /dev/null
+++ b/dimension/bench/Makefile.am
@@ -0,0 +1,35 @@
+###########################################################################
+## Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> ##
+## ##
+## This file is part of The Dimension Build Suite. ##
+## ##
+## The Dimension Build Suite is free software; you can redistribute it ##
+## and/or modify it under the terms of the GNU General Public License as ##
+## published by the Free Software Foundation; either version 3 of the ##
+## License, or (at your option) any later version. ##
+## ##
+## The Dimension Build Suite is distributed in the hope that it will be ##
+## useful, but WITHOUT ANY WARRANTY; without even the implied warranty ##
+## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ##
+## General Public License for more details. ##
+## ##
+## You should have received a copy of the GNU General Public License ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
+###########################################################################
+
+ENVIRONMENT = top_builddir=$(top_builddir)
+
+bench: tokenize.sh parse.sh render.sh
+ $(ENVIRONMENT) ./tokenize.sh
+ $(ENVIRONMENT) ./parse.sh
+ $(ENVIRONMENT) ./render.sh
+
+.sh:
+ cp $(srcdir)/$@ .
+
+clean-local:
+ rm -f *.png
+
+EXTRA_DIST = bench.pov
+
+.PHONY: bench
diff --git a/dimension/bench/bench.pov b/dimension/bench/bench.pov
new file mode 100644
index 0000000..a4f632f
--- /dev/null
+++ b/dimension/bench/bench.pov
@@ -0,0 +1,118 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Benchmark Suite. *
+ * *
+ * The Dimension Benchmark Suite is free software; you can redistribute *
+ * it and/or modify it under the terms of the GNU General Public License *
+ * as published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Benchmark Suite is distributed in the hope that it will *
+ * be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See *
+ * the GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+camera {
+ location <3.0, 6.0, -11.0>
+ right x*image_width/image_height
+ look_at 0
+}
+
+background {
+ color rgb 1
+}
+
+// inside center sphere
+light_source {
+ 0,
+ color rgb 1
+}
+
+light_source {
+ 2*y,
+ color rgb 1
+}
+
+/* plane {
+ y,
+ -1
+ // *** hollow on
+ pigment {
+ rgb <0.73, 0.90, 0.97>
+ }
+ finish {
+ diffuse 0.35
+ ambient .5
+ }
+} */
+
+#macro sph(center)
+ sphere {
+ center,
+ 1
+ texture {
+ // *** crackle
+ scale 0.5
+
+ /* *** texture_map {
+ [ 0.03
+ pigment {
+ color rgb 1
+ }
+ finish {
+ ambient 1
+ }
+ normal {
+ facets size 0.1
+ }
+ ]
+ [ 0.04
+ pigment {
+ color rgbf <1, 1, 1, 0.9>
+ }
+ finish {
+ reflection { 0.2 }
+ specular 0.1
+ roughness 0.02
+ conserve_energy
+ }
+ normal {
+ facets size 0.1
+ }
+ ]
+ } *** */
+ }
+ interior {
+ ior 1.3
+ }
+ }
+#end
+
+union {
+ #declare Size = 4;
+ #declare I = -Size;
+ #while (I <= Size)
+ #declare J = -Size;
+
+ #while (J <= Size)
+ #declare K = -Size;
+
+ #while (K <= Size)
+ object {
+ sph(<2.5*I, 2.5*K, 2.5*J>)
+ }
+
+ #declare K = K + 1;
+ #end
+
+ #declare J = J + 1;
+ #end
+
+ #declare I = I + 1;
+ #end
+}
diff --git a/dimension/bench/parse.sh b/dimension/bench/parse.sh
new file mode 100755
index 0000000..b7db055
--- /dev/null
+++ b/dimension/bench/parse.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+#########################################################################
+# Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Benchmark Suite. #
+# #
+# The Dimension Benchmark Suite is free software; you can redistribute #
+# it and/or modify it under the terms of the GNU General Public License #
+# as published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Benchmark Suite is distributed in the hope that it will #
+# be useful, but WITHOUT ANY WARRANTY; without even the implied #
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See #
+# the GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+for i in {1..10000}; do
+ echo '
+difference {
+ box {
+ <-1, -1, -1>, <1, 1, 1>
+
+ rotate 45*x
+
+ texture {
+ pigment {
+ color rgbft <0, 0, 1, 0.25, 0.5>
+ }
+ finish {
+ reflection { 0.5 }
+ }
+ }
+
+ interior {
+ ior 1.1
+ }
+ }
+
+ sphere {
+ <0, 0, 0>, 1.25
+
+ texture {
+ pigment {
+ color rgb <0, 1, 0>
+ }
+ finish {
+ phong 0.2
+ phong_size 40.0
+ }
+ }
+ }
+}
+'
+done | (time ${top_builddir}/dimension/dimension --parse /dev/stdin >/dev/null)
diff --git a/dimension/bench/render.sh b/dimension/bench/render.sh
new file mode 100755
index 0000000..b661e53
--- /dev/null
+++ b/dimension/bench/render.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Benchmark Suite. #
+# #
+# The Dimension Benchmark Suite is free software; you can redistribute #
+# it and/or modify it under the terms of the GNU General Public License #
+# as published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Benchmark Suite is distributed in the hope that it will #
+# be useful, but WITHOUT ANY WARRANTY; without even the implied #
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See #
+# the GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+echo -e "Single-threaded"
+time ${top_builddir}/dimension/dimension -w1920 -h1080 --quality=1 --threads=1 bench.pov
+echo -e "\nMulti-threaded"
+time ${top_builddir}/dimension/dimension -w1920 -h1080 --quality=1 bench.pov
diff --git a/dimension/bench/tokenize.sh b/dimension/bench/tokenize.sh
new file mode 100755
index 0000000..1d833d5
--- /dev/null
+++ b/dimension/bench/tokenize.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+#########################################################################
+# Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Benchmark Suite. #
+# #
+# The Dimension Benchmark Suite is free software; you can redistribute #
+# it and/or modify it under the terms of the GNU General Public License #
+# as published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Benchmark Suite is distributed in the hope that it will #
+# be useful, but WITHOUT ANY WARRANTY; without even the implied #
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See #
+# the GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+for i in {1..10000}; do
+ echo '{}()[]+-*/,;?:&.|=<>!<= >= != "This is a string with escape sequences: \a\b\f\n\r\t\u2123\v\\\"" 1 123456789 01234567 0x123456789 -0x01 .1 0.1 1.0 0.123456789 -0.123456789 <1, 2.2, -3.03> Undefined'
+done | (time ${top_builddir}/dimension/dimension --tokenize /dev/stdin >/dev/null)
diff --git a/dimension/tests/Makefile.am b/dimension/tests/Makefile.am
new file mode 100644
index 0000000..c54bcd4
--- /dev/null
+++ b/dimension/tests/Makefile.am
@@ -0,0 +1,55 @@
+###########################################################################
+## Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> ##
+## ##
+## This file is part of The Dimension Build Suite. ##
+## ##
+## The Dimension Build Suite is free software; you can redistribute it ##
+## and/or modify it under the terms of the GNU General Public License as ##
+## published by the Free Software Foundation; either version 3 of the ##
+## License, or (at your option) any later version. ##
+## ##
+## The Dimension Build Suite is distributed in the hope that it will be ##
+## useful, but WITHOUT ANY WARRANTY; without even the implied warranty ##
+## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ##
+## General Public License for more details. ##
+## ##
+## You should have received a copy of the GNU General Public License ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
+###########################################################################
+
+INCLUDES = -I$(top_srcdir)/libdimension
+
+TESTS = punctuation.sh \
+ numeric.sh \
+ strings.sh \
+ labels.sh \
+ directives.sh \
+ arithexp.sh \
+ transformations.sh \
+ invalid-macro.sh \
+ tbuffer-overlap.sh \
+ integer-overflow.sh \
+ csg.sh \
+ demo.sh
+TESTS_ENVIRONMENT = top_builddir=$(top_builddir) dimension_flags=--strict
+
+.sh:
+ cp $(srcdir)/$@ .
+
+EXTRA_DIST = $(TESTS) \
+ punctuation.pov \
+ numeric.pov \
+ strings.pov \
+ labels.pov \
+ directives.inc \
+ directives.pov \
+ arithexp.pov \
+ transformations.pov \
+ invalid-macro.pov \
+ tbuffer-overlap.pov \
+ integer-overflow.pov \
+ csg.pov \
+ demo.pov
+
+clean-local:
+ rm -f *.png
diff --git a/dimension/tests/arithexp.pov b/dimension/tests/arithexp.pov
new file mode 100644
index 0000000..d38b13a
--- /dev/null
+++ b/dimension/tests/arithexp.pov
@@ -0,0 +1,218 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Test arithmetic expression handling
+
+sphere {
+ 2*<<2.0 - 1.0, 3.0, 4.0>.x, (1.0 + 2)*2 - 5, 1.0 + 2*2 - 4> - -<0, 0, 1>,
+ exp(1) - (0 >= 1 ? 0 : 1*2)
+}
+
+/* Float functions */
+
+#if (abs(-1) != 1)
+ #error "abs"
+#end
+
+#if (acos(0) != 1.570796326794897)
+ #error "acos"
+#end
+
+#if (acosh(2) != 1.316957896924817)
+ #error "acosh"
+#end
+
+#if (asc("ABC") != 65)
+ #error "asc"
+#end
+
+#if (asin(1) != 1.570796326794897)
+ #error "asin"
+#end
+
+#if (asinh(2) != 1.44363547517881)
+ #error "asinh"
+#end
+
+#if (atan(1) != 0.7853981633974483)
+ #error "atan"
+#end
+
+#if (atan2(-1, -1) != -2.35619449019234)
+ #error "atan2"
+#end
+
+#if (atanh(0.5) != 0.5493061443340548)
+ #error "atanh"
+#end
+
+#if (ceil(-1.5) != -1)
+ #error "ceil"
+#end
+
+#if (cos(1.570796326794897) != 0)
+ #error "cos"
+#end
+
+#if (cosh(1.316957896924817) != 2)
+ #error "cosh"
+#end
+
+#if (degrees(1.570796326794897) != 90)
+ #error "degrees"
+#end
+
+#if (div(3,2) != 1)
+ #error "div"
+#end
+
+#if (exp(1) != 2.718281828459045)
+ #error "exp"
+#end
+
+#if (floor(-1.5) != -2)
+ #error "floor"
+#end
+
+#if (int(-1.9) != -1)
+ #error "int"
+#end
+
+#if (ln(2.718281828459045) != 1)
+ #error "ln"
+#end
+
+#if (log(1000) != 3)
+ #error "log"
+#end
+
+#if (max(-1.5, 0, 1) != 1)
+ #error "max"
+#end
+
+#if (min(-1.5, 0, 1) != -1.5)
+ #error "min"
+#end
+
+#if (mod(3.5, 2) != 1.5)
+ #error "mod"
+#end
+
+#if (pow(2, 3) != 8)
+ #error "pow"
+#end
+
+#if (radians(90) != 1.570796326794897)
+ #error "radians"
+#end
+
+#if (sin(1.570796326794897) != 1)
+ #error "sin"
+#end
+
+#if (sinh(1.44363547517881) != 2)
+ #error "sinh"
+#end
+
+#if (strcmp("asdfjkl;", "jkl;asdf") >= 0)
+ #error "strcmp"
+#end
+
+#if (strlen("asdfjkl;") != 8)
+ #error "strlen"
+#end
+
+#if (sqrt(2) != 1.414213562373095)
+ #error "sqrt"
+#end
+
+#if (tan(0.7853981633974483) != 1)
+ #error "tan"
+#end
+
+#if (tanh(0.5493061443340548) != 0.5)
+ #error "tanh"
+#end
+
+#if (val("123.45") != 123.45)
+ #error "val"
+#end
+
+#if (vaxis_rotate(<1, 0, 0>, <1, 0, 1>, 180) != <0, 0, 1>)
+ #error "vaxis_rotate"
+#end
+
+#if (vaxis_rotate(1, 1, 180) != <1, 1, 1>)
+ #error "vaxis_rotate"
+#end
+
+#if (vcross(<1, 2, 3>, <3, 2, 1>) != <-4, 8, -4>)
+ #error "vcross"
+#end
+
+#if (vcross(1, 2) != 0)
+ #error "vcross"
+#end
+
+#if (vdot(<1, 2, 3>, 2) != 12)
+ #error "vdot"
+#end
+
+#if (vdot(2, 2) != 12)
+ #error "vdot"
+#end
+
+#if (vlength(<1, 1, 1>) != 1.732050807568877)
+ #error "vlength"
+#end
+
+#if (vlength(1) != 1.732050807568877)
+ #error "vlength"
+#end
+
+#if (vnormalize(<1, 1, 1>)
+ != <0.5773502691896258, 0.5773502691896258, 0.5773502691896258>)
+ #error "vnormalize"
+#end
+
+#if (vnormalize(1) != 0.4472135954999579) // Vector promoted comparison
+ #error "vnormalize"
+#end
+
+#if (vrotate(<1, 0, 0>, <0, -90, 0>) != <0, 0, 1>)
+ #error "vrotate"
+#end
+
+#if (vrotate(1, 2) != <1, 1, 1>)
+ #error "vrotate"
+#end
+
+/* Float built-in IDs */
+
+#if (pi != 3.141592653589793)
+ #error "pi"
+#end
+
+#if (!true | !yes | !on)
+ #error "true"
+#end
+
+#if (false | no | off)
+ #error "false"
+#end
diff --git a/dimension/tests/arithexp.sh b/dimension/tests/arithexp.sh
new file mode 100755
index 0000000..e46ab04
--- /dev/null
+++ b/dimension/tests/arithexp.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+arithexp=$(${top_builddir}/dimension/dimension ${dimension_flags} --parse ${srcdir}/arithexp.pov)
+arithexp_exp="$(echo -n \
+'((object
+ (sphere
+ (vector (float 2) (float 2) (float 3) (integer 0) (integer 0))
+ (float 0.718282))
+ object-modifiers))' \
+| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')"
+
+if [ "$arithexp" != "$arithexp_exp" ]; then
+ echo "arithexp.pov parsed as \"$arithexp\"" >&2
+ echo " -- expected \"$arithexp_exp\"" >&2
+ exit 1
+fi
diff --git a/dimension/tests/csg.pov b/dimension/tests/csg.pov
new file mode 100644
index 0000000..357fd7b
--- /dev/null
+++ b/dimension/tests/csg.pov
@@ -0,0 +1,65 @@
+/*************************************************************************
+ * Copyright (C) 2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Test constructive solid geometry
+
+camera {
+ perspective
+ location -4*z
+ right x*image_width/image_height
+ look_at 0
+}
+
+background {
+ color rgbf <0, 0.1, 0.2, 0.1>
+}
+
+/* One-object unions */
+
+union {
+ sphere {
+ -1.5*x, 1
+ pigment { color red 1 }
+ }
+}
+
+union {
+ light_source {
+ 20*y, color rgb 0.5
+ }
+}
+
+/* CSG with lights */
+difference {
+ light_source {
+ -15*x, color rgb 0.5
+ }
+ sphere {
+ 1.5*x - 20*y, 1
+ pigment { color green 1 }
+ }
+ light_source {
+ 15*x, color rgb 0.5
+ }
+ box {
+ <0.7, -20.8, -0.8>, <2.3, -19.2, 0.8>
+ pigment { color blue 1 }
+ }
+ translate 20*y
+}
diff --git a/dimension/tests/csg.sh b/dimension/tests/csg.sh
new file mode 100755
index 0000000..b57389d
--- /dev/null
+++ b/dimension/tests/csg.sh
@@ -0,0 +1,94 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+csg=$(${top_builddir}/dimension/dimension ${dimension_flags} -w768 -h480 --parse ${srcdir}/csg.pov)
+csg_exp="$(echo -n \
+'((camera
+ perspective
+ (location (vector (integer 0) (integer 0) (integer -4)
+ (integer 0) (integer 0)))
+ (right (vector (float 1.6) (integer 0) (integer 0) (integer 0) (integer 0)))
+ (look_at (vector (integer 0) (integer 0) (integer 0)
+ (integer 0) (integer 0))))
+ (background
+ (vector (integer 0) (float 0.1) (float 0.2) (float 0.1) (integer 0)))
+ (object
+ (union
+ (object
+ (sphere
+ (vector (float -1.5) (float 0) (float 0) (float 0) (float 0))
+ (integer 1))
+ (object-modifiers
+ (pigment
+ (vector (integer 1) (integer 0) (integer 0)
+ (integer 0) (integer 0))
+ pigment-modifiers))))
+ object-modifiers)
+ (object
+ (union
+ (light_source
+ (vector (integer 0) (integer 20) (integer 0) (integer 0) (integer 0))
+ (vector (float 0.5) (float 0.5) (float 0.5) (integer 0) (integer 0))
+ object-modifiers))
+ object-modifiers)
+ (object
+ (difference
+ (light_source
+ (vector (integer -15) (integer 0) (integer 0) (integer 0) (integer 0))
+ (vector (float 0.5) (float 0.5) (float 0.5) (integer 0) (integer 0))
+ object-modifiers)
+ (object
+ (sphere
+ (vector (float 1.5) (float -20) (float 0) (float 0) (float 0))
+ (integer 1))
+ (object-modifiers
+ (pigment
+ (vector (integer 0) (integer 1) (integer 0)
+ (integer 0) (integer 0))
+ pigment-modifiers)))
+ (light_source
+ (vector (integer 15) (integer 0) (integer 0) (integer 0) (integer 0))
+ (vector (float 0.5) (float 0.5) (float 0.5) (integer 0) (integer 0))
+ object-modifiers)
+ (object
+ (box
+ (vector (float 0.7) (float -20.8) (float -0.8)
+ (integer 0) (integer 0))
+ (vector (float 2.3) (float -19.2) (float 0.8)
+ (integer 0) (integer 0)))
+ (object-modifiers
+ (pigment
+ (vector (integer 0) (integer 0) (integer 1)
+ (integer 0) (integer 0))
+ pigment-modifiers))))
+ (object-modifiers
+ (transformation
+ (translation (vector (integer 0) (integer 20) (integer 0)
+ (integer 0) (integer 0)))))))' \
+| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')"
+
+if [ "$csg" != "$csg_exp" ]; then
+ echo "csg.pov parsed as \"$csg\"" >&2
+ echo " -- expected \"$csg_exp\"" >&2
+ exit 1
+fi
+
+${top_builddir}/dimension/dimension ${dimension_flags} -w768 -h480 -o csg.png ${srcdir}/csg.pov
diff --git a/dimension/tests/demo.pov b/dimension/tests/demo.pov
new file mode 100644
index 0000000..91be9d2
--- /dev/null
+++ b/dimension/tests/demo.pov
@@ -0,0 +1,150 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Render demo scene
+
+global_settings {
+ max_trace_level 5
+ adc_bailout 1/255
+}
+
+camera {
+ perspective
+ location <0, 0.25, -4>
+ right x*image_width/image_height
+ look_at <0, 0, 0>
+
+ rotate 53*y
+}
+
+background {
+ color transmit 1
+}
+
+sky_sphere {
+ pigment {
+ gradient y
+ color_map {
+ [0.0 color rgb <1, 0.5, 0>]
+ [0.35 color rgbf <0, 0.1, 0.2, 0.1>]
+ }
+ }
+}
+
+light_source {
+ <-15, 20, 10>, color rgb <1, 1, 1>
+}
+
+difference {
+ box {
+ <-1, -1, -1>, <1, 1, 1>
+
+ rotate 45*x
+
+ texture {
+ pigment {
+ color rgbft <0, 0, 1, 0.25, 0.5>
+ }
+ finish {
+ reflection { 0.5 }
+ }
+ }
+
+ interior {
+ ior 1.1
+ }
+ }
+
+ sphere {
+ <0, 0, 0>, 1.25
+
+ texture {
+ pigment {
+ color rgb <0, 1, 0>
+ }
+ finish {
+ phong 0.2
+ phong_size 40.0
+ }
+ }
+ }
+}
+
+union {
+ cylinder {
+ -1.25*y, 1.25*y, 0.1
+ }
+ cone {
+ 1.25*y, 0.1, 1.5*y, 0
+ open
+ }
+
+ pigment {
+ gradient y
+ color_map {
+ [0 color rgb <1, 0, 0>]
+ [1/6 color rgb <1, 0.5, 0>]
+ [2/6 color rgb <1, 1, 0>]
+ [3/6 color rgb <0, 1, 0>]
+ [4/6 color rgb <0, 0, 1>]
+ [5/6 color rgb <1, 0, 1>]
+ [1 color rgb <1, 0, 0>]
+ }
+ scale <1, 2.75, 1>
+ translate -1.25*y
+ }
+ rotate -45*x
+}
+
+union {
+ torus {
+ 0.15, 0.05
+ translate -y
+ }
+ torus {
+ 0.15, 0.05
+ }
+ torus {
+ 0.15, 0.05
+ translate y
+ }
+
+ pigment {
+ color rgb <0, 0, 1>
+ }
+ finish {
+ ambient 1
+ }
+ rotate -45*x
+}
+
+plane {
+ y, -2
+ pigment {
+ checker
+ pigment {
+ color rgb 1
+ }
+ pigment {
+ checker color rgb 0, color rgb 1
+ scale 1/3
+ }
+ quick_color rgb <1, 0.5, 0.75>
+ }
+}
diff --git a/dimension/tests/demo.sh b/dimension/tests/demo.sh
new file mode 100755
index 0000000..233b880
--- /dev/null
+++ b/dimension/tests/demo.sh
@@ -0,0 +1,220 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+demo=$(${top_builddir}/dimension/dimension ${dimension_flags} -w768 -h480 --parse ${srcdir}/demo.pov)
+demo_exp=$(echo -n \
+'((global_settings
+ (max_trace_level (integer 5))
+ (adc_bailout (float 0.00392157)))
+ (camera
+ perspective
+ (location (vector (integer 0) (float 0.25) (integer -4)
+ (integer 0) (integer 0)))
+ (right (vector (float 1.6) (integer 0) (integer 0) (integer 0) (integer 0)))
+ (look_at (vector (integer 0) (integer 0) (integer 0)
+ (integer 0) (integer 0)))
+ (transformation
+ (rotation (vector (integer 0) (integer 53) (integer 0)
+ (integer 0) (integer 0)))))
+ (background
+ (vector (integer 0) (integer 0) (integer 0) (integer 0) (integer 1)))
+ (sky_sphere
+ (pigment
+ (pattern
+ (gradient (vector (integer 0) (integer 1)
+ (integer 0) (integer 0) (integer 0))))
+ (pigment-modifiers
+ (color_map
+ (color_map-entry
+ (float 0)
+ (vector (integer 1) (float 0.5) (integer 0)
+ (integer 0) (integer 0)))
+ (color_map-entry
+ (float 0.35)
+ (vector (integer 0) (float 0.1) (float 0.2)
+ (float 0.1) (integer 0)))))))
+ (light_source
+ (vector (integer -15) (integer 20) (integer 10) (integer 0) (integer 0))
+ (vector (integer 1) (integer 1) (integer 1) (integer 0) (integer 0))
+ object-modifiers)
+ (object
+ (difference
+ (object
+ (box
+ (vector (integer -1) (integer -1) (integer -1)
+ (integer 0) (integer 0))
+ (vector (integer 1) (integer 1) (integer 1) (integer 0) (integer 0)))
+ (object-modifiers
+ (transformation
+ (rotation (vector (integer 45) (integer 0) (integer 0)
+ (integer 0) (integer 0))))
+ (texture
+ (pigment
+ (vector (integer 0) (integer 0) (integer 1)
+ (float 0.25) (float 0.5))
+ pigment-modifiers)
+ (finish
+ (reflection
+ (vector (float 0.5) (float 0.5) (float 0.5)
+ (float 0.5) (float 0.5))
+ (vector (float 0.5) (float 0.5) (float 0.5)
+ (float 0.5) (float 0.5))
+ reflection-items)))
+ (interior
+ (ior (float 1.1)))))
+ (object
+ (sphere
+ (vector (integer 0) (integer 0) (integer 0) (integer 0) (integer 0))
+ (float 1.25))
+ (object-modifiers
+ (texture
+ (pigment
+ (vector (integer 0) (integer 1) (integer 0)
+ (integer 0) (integer 0))
+ pigment-modifiers)
+ (finish
+ (phong (float 0.2))
+ (phong_size (float 40)))))))
+ object-modifiers)
+ (object
+ (union
+ (object
+ (cylinder
+ (vector (float 0) (float -1.25) (float 0) (float 0) (float 0))
+ (vector (float 0) (float 1.25) (float 0) (float 0) (float 0))
+ (float 0.1)
+ (integer 0))
+ object-modifiers)
+ (object
+ (cone
+ (vector (float 0) (float 1.25) (float 0) (float 0) (float 0))
+ (float 0.1)
+ (vector (float 0) (float 1.5) (float 0) (float 0) (float 0))
+ (integer 0)
+ (integer 1))
+ object-modifiers))
+ (object-modifiers
+ (pigment
+ (pattern (gradient (vector (integer 0) (integer 1) (integer 0)
+ (integer 0) (integer 0))))
+ (pigment-modifiers
+ (color_map
+ (color_map-entry
+ (integer 0)
+ (vector (integer 1) (integer 0) (integer 0)
+ (integer 0) (integer 0)))
+ (color_map-entry
+ (float 0.166667)
+ (vector (integer 1) (float 0.5) (integer 0)
+ (integer 0) (integer 0)))
+ (color_map-entry
+ (float 0.333333)
+ (vector (integer 1) (integer 1) (integer 0)
+ (integer 0) (integer 0)))
+ (color_map-entry
+ (float 0.5)
+ (vector (integer 0) (integer 1) (integer 0)
+ (integer 0) (integer 0)))
+ (color_map-entry
+ (float 0.666667)
+ (vector (integer 0) (integer 0) (integer 1)
+ (integer 0) (integer 0)))
+ (color_map-entry
+ (float 0.833333)
+ (vector (integer 1) (integer 0) (integer 1)
+ (integer 0) (integer 0)))
+ (color_map-entry
+ (integer 1)
+ (vector (integer 1) (integer 0) (integer 0)
+ (integer 0) (integer 0))))
+ (transformation
+ (scale (vector (integer 1) (float 2.75) (integer 1)
+ (integer 0) (integer 0))))
+ (transformation
+ (translation (vector (float 0) (float -1.25) (float 0)
+ (float 0) (float 0))))))
+ (transformation
+ (rotation (vector (integer -45) (integer 0) (integer 0)
+ (integer 0) (integer 0))))))
+ (object
+ (union
+ (object
+ (torus (float 0.15) (float 0.05))
+ (object-modifiers
+ (transformation
+ (translation (vector (integer 0) (integer -1) (integer 0)
+ (integer 0) (integer 0))))))
+ (object
+ (torus (float 0.15) (float 0.05))
+ object-modifiers)
+ (object
+ (torus (float 0.15) (float 0.05))
+ (object-modifiers
+ (transformation
+ (translation (vector (integer 0) (integer 1) (integer 0)
+ (integer 0) (integer 0)))))))
+ (object-modifiers
+ (pigment
+ (vector (integer 0) (integer 0) (integer 1) (integer 0) (integer 0))
+ pigment-modifiers)
+ (finish
+ (ambient
+ (vector (integer 1) (integer 1) (integer 1) (integer 1) (integer 1))))
+ (transformation
+ (rotation (vector (integer -45) (integer 0) (integer 0)
+ (integer 0) (integer 0))))))
+ (object
+ (plane
+ (vector (integer 0) (integer 1) (integer 0) (integer 0) (integer 0))
+ (integer -2))
+ (object-modifiers
+ (pigment
+ (pattern checker)
+ (pigment-modifiers
+ (quick_color
+ (vector (integer 1) (float 0.5) (float 0.75)
+ (integer 0) (integer 0)))
+ (pigment-list
+ (pigment
+ (vector (integer 1) (integer 1) (integer 1)
+ (integer 0) (integer 0))
+ pigment-modifiers)
+ (pigment
+ (pattern checker)
+ (pigment-modifiers
+ (transformation
+ (scale (vector (float 0.333333) (float 0.333333)
+ (float 0.333333) (float 0.333333)
+ (float 0.333333))))
+ (color-list
+ (vector (integer 0) (integer 0) (integer 0)
+ (integer 0) (integer 0))
+ (vector (integer 1) (integer 1) (integer 1)
+ (integer 0) (integer 0)))))))))))' \
+| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')
+
+if [ "$demo" != "$demo_exp" ]; then
+ echo "demo.pov parsed as \"$demo\"" >&2
+ echo " -- expected \"$demo_exp\"" >&2
+ exit 1
+fi
+
+${top_builddir}/dimension/dimension ${dimension_flags} -w768 -h480 -o demo.png ${srcdir}/demo.pov
diff --git a/dimension/tests/directives.inc b/dimension/tests/directives.inc
new file mode 100644
index 0000000..a3dadb3
--- /dev/null
+++ b/dimension/tests/directives.inc
@@ -0,0 +1,21 @@
+/*************************************************************************
+ * Copyright (C) 2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+#declare Center = 0;
+#local Local = -1;
diff --git a/dimension/tests/directives.pov b/dimension/tests/directives.pov
new file mode 100644
index 0000000..5c3cfa3
--- /dev/null
+++ b/dimension/tests/directives.pov
@@ -0,0 +1,92 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Test the language directives
+
+#version 3.6;
+
+#debug "debug"
+#warning "warning"
+
+#include "directives.inc"
+
+#declare R = 1;
+#local Color = rgb <1, 0, 1>;
+
+#declare Unused = -1;
+#undef Unused
+
+#ifdef (Local)
+ #error "Local escaped from include file"
+#end
+
+#ifdef (Unused)
+ #error "#undef failed"
+#end
+
+#macro Make_Sphere(n)
+ sphere {
+ Center + <0, n, 0>, R
+ pigment {
+ color Color green 1
+ }
+ }
+#end
+
+#macro Inc(n)
+ #declare n = n + 1;
+#end
+
+#declare Counter = 0;
+#while (Counter < 2)
+ #if (#if (1 = 1) 0 #end = 0 & !1)
+ #error "Nested #if parsing failed"
+ #else
+ Make_Sphere(Counter)
+ #end
+
+ Inc(Counter)
+#end
+
+// Test macro parameters with the same name as existing variables
+#declare Test1 = 0;
+#declare Test2 = 1;
+#declare Test3 = 2;
+#macro ScopeTest(Test1, Test2, Test3)
+ #declare Test1 = Test2 - Test3;
+#end
+ScopeTest(Test1, Test3, Test2)
+sphere {
+ 0, Test1
+}
+
+#declare Box =
+ box {
+ <-1, -1, -1>, <1, 1, 1>
+ pigment {
+ color rgb <1, 1, 1>
+ }
+ }
+
+object {
+ Box
+ finish {
+ phong 0.2
+ }
+}
diff --git a/dimension/tests/directives.sh b/dimension/tests/directives.sh
new file mode 100755
index 0000000..9e3974a
--- /dev/null
+++ b/dimension/tests/directives.sh
@@ -0,0 +1,124 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+directives=$(${top_builddir}/dimension/dimension ${dimension_flags} --tokenize --parse ${srcdir}/directives.pov)
+directives_exp="$(echo -n \
+'(#version (float "3.6") ;
+ #debug (string "debug")
+ #warning (string "warning")
+ #include (string "directives.inc")
+ #declare (identifier "R") = (integer "1") ;
+ #local (identifier "Color") = rgb < (integer "1") , (integer "0") , (integer "1") > ;
+ #declare (identifier "Unused") = - (integer "1") ;
+ #undef (identifier "Unused")
+ #ifdef \( (identifier "Local") \)
+ #error (string "Local escaped from include file")
+ #end
+ #ifdef \( (identifier "Unused") \)
+ #error (string "#undef failed")
+ #end
+ #macro (identifier "Make_Sphere") \( (identifier "n") \)
+ sphere {
+ (identifier "Center") + < (integer "0") , (identifier "n") , (integer "0") > , (identifier "R")
+ pigment {
+ color (identifier "Color") green (integer "1")
+ }
+ }
+ #end
+ #macro (identifier "Inc") \( (identifier "n") \)
+ #declare (identifier "n") = (identifier "n") + (integer "1") ;
+ #end
+ #declare (identifier "Counter") = (integer "0") ;
+ #while \( (identifier "Counter") < (integer "2") \)
+ #if \( #if \( (integer "1") = (integer "1") \) (integer "0") #end = (integer "0") & ! (integer "1") \)
+ #error (string "Nested #if parsing failed")
+ #else
+ (identifier "Make_Sphere") \( (identifier "Counter") \)
+ #end
+ (identifier "Inc") \( (identifier "Counter") \)
+ #end
+
+ #declare (identifier "Test1") = (integer "0") ;
+ #declare (identifier "Test2") = (integer "1") ;
+ #declare (identifier "Test3") = (integer "2") ;
+ #macro (identifier "ScopeTest") \( (identifier "Test1") , (identifier "Test2") , (identifier "Test3") \)
+ #declare (identifier "Test1") = (identifier "Test2") - (identifier "Test3") ;
+ #end
+ (identifier "ScopeTest") \( (identifier "Test1") , (identifier "Test3") , (identifier "Test2") \)
+ sphere {
+ (integer "0") , (identifier "Test1")
+ }
+
+ #declare (identifier "Box") =
+ box {
+ < - (integer "1") , - (integer "1") , - (integer "1") > ,
+ < (integer "1") , (integer "1") , (integer "1") >
+ pigment {
+ color rgb < (integer "1") , (integer "1") , (integer "1") >
+ }
+ }
+
+ object {
+ (identifier "Box")
+ finish {
+ phong (float "0.2")
+ }
+ })' \
+| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')
+$(echo -n \
+'((object
+ (sphere
+ (vector (integer 0) (integer 0) (integer 0) (integer 0) (integer 0))
+ (integer 1))
+ (object-modifiers
+ (pigment
+ (vector (integer 1) (integer 1) (integer 1) (integer 0) (integer 0))
+ pigment-modifiers)))
+ (object
+ (sphere
+ (vector (integer 0) (integer 1) (integer 0) (integer 0) (integer 0))
+ (integer 1))
+ (object-modifiers
+ (pigment
+ (vector (integer 1) (integer 1) (integer 1) (integer 0) (integer 0))
+ pigment-modifiers)))
+ (object
+ (sphere
+ (vector (integer 0) (integer 0) (integer 0) (integer 0) (integer 0))
+ (integer 1))
+ object-modifiers)
+ (object
+ (box
+ (vector (integer -1) (integer -1) (integer -1) (integer 0) (integer 0))
+ (vector (integer 1) (integer 1) (integer 1) (integer 0) (integer 0)))
+ (object-modifiers
+ (pigment
+ (vector (integer 1) (integer 1) (integer 1) (integer 0) (integer 0))
+ pigment-modifiers)
+ (finish
+ (phong (float 0.2))))))' \
+| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')"
+
+if [ "$directives" != "$directives_exp" ]; then
+ echo "directives.pov parsed as \"$directives\"" >&2
+ echo " -- expected \"$directives_exp\"" >&2
+ exit 1
+fi
diff --git a/dimension/tests/integer-overflow.pov b/dimension/tests/integer-overflow.pov
new file mode 100644
index 0000000..a063fab
--- /dev/null
+++ b/dimension/tests/integer-overflow.pov
@@ -0,0 +1,25 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Test integer overflow handling -- overflows should convert to floats
+
+torus {
+ 10000000000000000000,
+ abs(-2147483647 - 1)*abs(-9223372036854775807 - 1)*((-2147483647 - 2)*(2147483647 + 1))*((-9223372036854775807.0 - 2)*(9223372036854775807.0 + 1))*(65536*65536)*(4294967296*4294967296.0)
+}
diff --git a/dimension/tests/integer-overflow.sh b/dimension/tests/integer-overflow.sh
new file mode 100755
index 0000000..0e1f03e
--- /dev/null
+++ b/dimension/tests/integer-overflow.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+integer_overflow=$(${top_builddir}/dimension/dimension ${dimension_flags} --parse ${srcdir}/integer-overflow.pov)
+integer_overflow_exp="$(echo -n \
+'((object
+ (torus
+ (float 1e+19)
+ (float 6.15656e+113))
+ object-modifiers))' \
+| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')"
+
+if [ "$integer_overflow" != "$integer_overflow_exp" ]; then
+ echo "integer-overflow.pov parsed as \"$integer_overflow\"" >&2
+ echo " -- expected \"$integer_overflow_exp\"" >&2
+ exit 1
+fi
diff --git a/dimension/tests/invalid-macro.pov b/dimension/tests/invalid-macro.pov
new file mode 100644
index 0000000..9906da4
--- /dev/null
+++ b/dimension/tests/invalid-macro.pov
@@ -0,0 +1,26 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Regression test for commit 11d364ec365c46c21271012b566966d342a90a8b
+
+#macro Macro()
+ { }
+#end
+
+Macro()
diff --git a/dimension/tests/invalid-macro.sh b/dimension/tests/invalid-macro.sh
new file mode 100755
index 0000000..cf6f353
--- /dev/null
+++ b/dimension/tests/invalid-macro.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+${top_builddir}/dimension/dimension ${dimension_flags} --parse ${srcdir}/invalid-macro.pov
+[ $? -lt 128 -a $? -gt 0 ]
diff --git a/dimension/tests/labels.pov b/dimension/tests/labels.pov
new file mode 100644
index 0000000..369e1fd
--- /dev/null
+++ b/dimension/tests/labels.pov
@@ -0,0 +1,31 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Test that we correctly tokenize identifiers and keywords
+
+camera {
+}
+
+sphere {
+ color new_identifier
+}
+
+box {
+ colour new_identifier
+}
diff --git a/dimension/tests/labels.sh b/dimension/tests/labels.sh
new file mode 100755
index 0000000..47365bd
--- /dev/null
+++ b/dimension/tests/labels.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+labels=$(${top_builddir}/dimension/dimension ${dimension_flags} --tokenize ${srcdir}/labels.pov)
+labels_exp='(camera { } sphere { color (identifier "new_identifier") } box { color (identifier "new_identifier") })';
+
+if [ "$labels" != "$labels_exp" ]; then
+ echo "labels.pov tokenized as \"$labels\"" >&2
+ echo " -- expected \"$labels_exp\"" >&2
+ exit 1
+fi
diff --git a/dimension/tests/numeric.pov b/dimension/tests/numeric.pov
new file mode 100644
index 0000000..dbf3c19
--- /dev/null
+++ b/dimension/tests/numeric.pov
@@ -0,0 +1,30 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Test that we correctly tokenize numeric values. Note that the `-' in `-1',
+// for example, is a separate token and not part of the number.
+
+// Integers:
+1 123456789 01234567 0x123456789 -0x01
+
+// Floats:
+.1 0.1 1.0 0.123456789 -0.123456789
+
+// A vector:
+<1, 2.2, -3.03>
diff --git a/dimension/tests/numeric.sh b/dimension/tests/numeric.sh
new file mode 100755
index 0000000..c5e7c93
--- /dev/null
+++ b/dimension/tests/numeric.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+numeric=$(${top_builddir}/dimension/dimension ${dimension_flags} --tokenize ${srcdir}/numeric.pov)
+numeric_exp=$(echo -n \
+'((integer "1")
+ (integer "123456789")
+ (integer "01234567")
+ (integer "0x123456789")
+ - (integer "0x01")
+
+ (float ".1")
+ (float "0.1")
+ (float "1.0")
+ (float "0.123456789")
+ - (float "0.123456789")
+
+ < (integer "1") , (float "2.2") , - (float "3.03") >)' \
+| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')
+
+if [ "$numeric" != "$numeric_exp" ]; then
+ echo "numeric.pov tokenized as \"$numeric\"" >&2
+ echo " -- expected \"$numeric_exp\"" >&2
+ exit 1
+fi
diff --git a/dimension/tests/punctuation.pov b/dimension/tests/punctuation.pov
new file mode 100644
index 0000000..d61db25
--- /dev/null
+++ b/dimension/tests/punctuation.pov
@@ -0,0 +1,24 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+/* Test that we correctly tokenize all simple punctuation marks
+ * // Also make sure we handle nested /* comments */ properly
+ */
+
+{}()[]+-*/,;?:&.|=<>!<= >= !=
diff --git a/dimension/tests/punctuation.sh b/dimension/tests/punctuation.sh
new file mode 100755
index 0000000..6990657
--- /dev/null
+++ b/dimension/tests/punctuation.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+punctuation=$(${top_builddir}/dimension/dimension ${dimension_flags} --tokenize ${srcdir}/punctuation.pov)
+punctuation_exp='({ } \( \) [ ] + - * / , ; ? : & . | = < > ! <= >= !=)'
+
+if [ "$punctuation" != "$punctuation_exp" ]; then
+ echo "punctuation.pov tokenized as \"$punctuation\"" >&2
+ echo " -- expected \"$punctuation_exp\"" >&2
+ exit 1
+fi
diff --git a/dimension/tests/strings.pov b/dimension/tests/strings.pov
new file mode 100644
index 0000000..eafe1ba
--- /dev/null
+++ b/dimension/tests/strings.pov
@@ -0,0 +1,21 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Test string handling, including escape sequences
+"This is a string with escape sequences: \a\b\f\n\r\t\u2123\v\\\'\""
diff --git a/dimension/tests/strings.sh b/dimension/tests/strings.sh
new file mode 100755
index 0000000..1f5f4f9
--- /dev/null
+++ b/dimension/tests/strings.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+strings=$(${top_builddir}/dimension/dimension ${dimension_flags} --tokenize ${srcdir}/strings.pov)
+strings_exp=$(/bin/echo -e "((string \"This is a string with escape sequences: \a\b\f\n\r\t!#\v\\\'\"\"))")
+
+if [ "$strings" != "$strings_exp" ]; then
+ echo "strings.pov tokenized as \"$strings\"" >&2
+ echo " -- expected \"$strings_exp\"" >&2
+ exit 1
+fi
diff --git a/dimension/tests/tbuffer-overlap.pov b/dimension/tests/tbuffer-overlap.pov
new file mode 100644
index 0000000..872b124
--- /dev/null
+++ b/dimension/tests/tbuffer-overlap.pov
@@ -0,0 +1,22 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Regression test for commit 72be096ff528306b1af6b41d5cacd1157b096d72
+
+#if (1=1) #declare foo = #end;
diff --git a/dimension/tests/tbuffer-overlap.sh b/dimension/tests/tbuffer-overlap.sh
new file mode 100755
index 0000000..bc3126d
--- /dev/null
+++ b/dimension/tests/tbuffer-overlap.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+${top_builddir}/dimension/dimension ${dimension_flags} --parse ${srcdir}/tbuffer-overlap.pov
+[ $? -lt 128 -a $? -gt 0 ]
diff --git a/dimension/tests/transformations.pov b/dimension/tests/transformations.pov
new file mode 100644
index 0000000..312445d
--- /dev/null
+++ b/dimension/tests/transformations.pov
@@ -0,0 +1,39 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Test transformations
+
+#declare Trans = transform { translate 1*z }
+
+sphere {
+ 0, 1
+ translate -1*x
+ rotate 90*y
+ scale 2
+ transform Trans
+ matrix <1, 1, 0,
+ 0, 1, 0,
+ 0, 0, 1,
+ 0, 0, 0>
+ transform {
+ Trans
+ rotate 45*z
+ inverse
+ }
+}
diff --git a/dimension/tests/transformations.sh b/dimension/tests/transformations.sh
new file mode 100755
index 0000000..727bf3b
--- /dev/null
+++ b/dimension/tests/transformations.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+#########################################################################
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> #
+# #
+# This file is part of The Dimension Test Suite. #
+# #
+# The Dimension Test Suite is free software; you can redistribute it #
+# and/or modify it under the terms of the GNU General Public License as #
+# published by the Free Software Foundation; either version 3 of the #
+# License, or (at your option) any later version. #
+# #
+# The Dimension Test Suite is distributed in the hope that it will be #
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
+# General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+transformations=$(${top_builddir}/dimension/dimension ${dimension_flags} --parse ${srcdir}/transformations.pov)
+transformations_exp="$(echo -n \
+'((object
+ (sphere
+ (vector (integer 0) (integer 0) (integer 0) (integer 0) (integer 0))
+ (integer 1))
+ (object-modifiers
+ (transformation
+ (translation
+ (vector (integer -1) (integer 0) (integer 0)
+ (integer 0) (integer 0))))
+ (transformation
+ (rotation
+ (vector (integer 0) (integer 90) (integer 0)
+ (integer 0) (integer 0))))
+ (transformation
+ (scale
+ (vector (integer 2) (integer 2) (integer 2) (integer 2) (integer 2))))
+ (transformation
+ (translation
+ (vector (integer 0) (integer 0) (integer 1) (integer 0) (integer 0))))
+ (transformation
+ (matrix
+ (integer 1) (integer 1) (integer 0)
+ (integer 0) (integer 1) (integer 0)
+ (integer 0) (integer 0) (integer 1)
+ (integer 0) (integer 0) (integer 0)))
+ (transformation
+ (translation
+ (vector (integer 0) (integer 0) (integer 1) (integer 0) (integer 0)))
+ (rotation
+ (vector (integer 0) (integer 0) (integer 45)
+ (integer 0) (integer 0)))
+ inverse))))' \
+| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')"
+
+if [ "$transformations" != "$transformations_exp" ]; then
+ echo "transformations.pov parsed as \"$transformations\"" >&2
+ echo " -- expected \"$transformations_exp\"" >&2
+ exit 1
+fi
+
+${top_builddir}/dimension/dimension ${dimension_flags} -w1 -h1 -o /dev/null ${srcdir}/transformations.pov