diff options
-rw-r--r-- | dimension/tokenize.c | 8 | ||||
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/dimension/Makefile.am | 25 | ||||
-rw-r--r-- | tests/dimension/braces.pov | 8 | ||||
-rwxr-xr-x | tests/dimension/tokenizer.sh | 10 |
5 files changed, 48 insertions, 5 deletions
diff --git a/dimension/tokenize.c b/dimension/tokenize.c index efa7fce..fc715b8 100644 --- a/dimension/tokenize.c +++ b/dimension/tokenize.c @@ -53,7 +53,7 @@ dmnsn_tokenize(FILE *file) break; case '}': - token.type = DMNSN_LBRACE; + token.type = DMNSN_RBRACE; token.value = NULL; dmnsn_array_push(tokens, &token); break; @@ -123,12 +123,12 @@ dmnsn_token_name(dmnsn_token_type token_type) { switch (token_type) { case DMNSN_LBRACE: - return "DMNSN_LBRACE"; + return "{"; case DMNSN_RBRACE: - return "DMNSN_RBRACE"; + return "}"; default: - return "UNRECOGNIZED-TOKEN"; + return "unrecognized-token"; } } diff --git a/tests/Makefile.am b/tests/Makefile.am index 12b7a41..61a0277 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,4 +17,4 @@ ## along with this program. If not, see <http://www.gnu.org/licenses/>. ## ########################################################################### -SUBDIRS = libdimension +SUBDIRS = libdimension dimension diff --git a/tests/dimension/Makefile.am b/tests/dimension/Makefile.am new file mode 100644 index 0000000..89c228e --- /dev/null +++ b/tests/dimension/Makefile.am @@ -0,0 +1,25 @@ +########################################################################### +## Copyright (C) 2009 Tavian Barnes <tavianator@gmail.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 = tokenizer.sh +TESTS_ENVIRONMENT = TOP_BUILDDIR=$(top_builddir) + +EXTRA_DIST = braces.pov diff --git a/tests/dimension/braces.pov b/tests/dimension/braces.pov new file mode 100644 index 0000000..295a69a --- /dev/null +++ b/tests/dimension/braces.pov @@ -0,0 +1,8 @@ +{ + { + } +} +} + } + { +{ diff --git a/tests/dimension/tokenizer.sh b/tests/dimension/tokenizer.sh new file mode 100755 index 0000000..35bcf65 --- /dev/null +++ b/tests/dimension/tokenizer.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +braces=$(${TOP_BUILDDIR}/dimension/dimension --tokenize braces.pov) +braces_exp='({ { } } } } { {)' + +if [ "$braces" != "$braces_exp" ]; then + echo "braces.pov tokenized as \"$braces\"" >&2 + echo " -- expected \"$braces_exp\"" >&2 + exit 1; +fi |