summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt13
-rw-r--r--tests/cgalcachetest.cc8
-rw-r--r--tests/cgalpngtest.cc8
-rw-r--r--tests/cgalstlsanitytest.cc8
-rw-r--r--tests/cgaltest.cc8
-rw-r--r--tests/csgtermtest.cc8
-rw-r--r--tests/csgtestcore.cc8
-rw-r--r--tests/csgtexttest.cc8
-rw-r--r--tests/dumptest.cc18
-rw-r--r--tests/echotest.cc8
-rw-r--r--tests/modulecachetest.cc11
-rw-r--r--tests/regression/cgalpngtest/child-tests-expected.pngbin13034 -> 13394 bytes
-rw-r--r--tests/regression/cgalpngtest/localfiles-test-expected.pngbin8454 -> 11732 bytes
-rw-r--r--tests/regression/dumptest/child-tests-expected.txt12
-rw-r--r--tests/regression/dumptest/localfiles-test-expected.txt3
-rw-r--r--tests/regression/echotest/variable-scope-tests-expected.txt16
-rw-r--r--tests/regression/opencsgtest/child-tests-expected.pngbin13600 -> 14187 bytes
-rw-r--r--tests/regression/opencsgtest/localfiles-test-expected.pngbin8844 -> 12657 bytes
-rw-r--r--tests/regression/throwntogethertest/child-tests-expected.pngbin9234 -> 14187 bytes
-rw-r--r--tests/regression/throwntogethertest/localfiles-test-expected.pngbin8844 -> 12657 bytes
-rw-r--r--tests/tests-common.cc4
-rw-r--r--tests/tests-common.h2
22 files changed, 92 insertions, 51 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index de4bab7..51abd06 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -13,7 +13,11 @@ include(CMakeParseArguments.cmake)
# Detect Lion and force gcc
IF (APPLE)
EXECUTE_PROCESS(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MACOSX_VERSION)
- IF (NOT ${MACOSX_VERSION} VERSION_LESS "10.7.0")
+ IF (NOT ${MACOSX_VERSION} VERSION_LESS "10.8.0")
+ message("Detected Mountain Lion or later")
+ set(CMAKE_C_COMPILER "gcc")
+ set(CMAKE_CXX_COMPILER "g++")
+ ELSEIF (NOT ${MACOSX_VERSION} VERSION_LESS "10.7.0")
message("Detected Lion or later")
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
@@ -325,9 +329,8 @@ if (WIN32)
set(FLEX_UNISTD_FLAG "-DYY_NO_UNISTD_H")
endif()
FLEX_TARGET(OpenSCADlexer ../src/lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp COMPILE_FLAGS "-Plexer ${FLEX_UNISTD_FLAG}")
-BISON_TARGET(OpenSCADparser ../src/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser_yacc.c COMPILE_FLAGS "-p parser")
+BISON_TARGET(OpenSCADparser ../src/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp COMPILE_FLAGS "-p parser")
ADD_FLEX_BISON_DEPENDENCY(OpenSCADlexer OpenSCADparser)
-set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/parser_yacc.c PROPERTIES LANGUAGE "CXX")
# CGAL
@@ -402,6 +405,7 @@ set(CORE_SOURCES
../src/value.cc
../src/expr.cc
../src/func.cc
+ ../src/localscope.cc
../src/module.cc
../src/ModuleCache.cc
../src/node.cc
@@ -751,7 +755,8 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES}
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/vector-values.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/search-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/recursion-tests.scad
- ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/value-reassignment-tests.scad)
+ ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/value-reassignment-tests.scad
+ ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/variable-scope-tests.scad)
list(APPEND DUMPTEST_FILES ${MINIMAL_FILES} ${FEATURES_FILES} ${EXAMPLE_FILES})
list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad
diff --git a/tests/cgalcachetest.cc b/tests/cgalcachetest.cc
index b65a2c8..67d3313 100644
--- a/tests/cgalcachetest.cc
+++ b/tests/cgalcachetest.cc
@@ -129,10 +129,10 @@ int main(int argc, char **argv)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
+ FileModule *root_module;
ModuleInstantiation root_inst("group");
root_module = parsefile(filename);
@@ -145,7 +145,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- AbstractNode *absolute_root_node = root_module->evaluate(&root_ctx, &root_inst);
+ AbstractNode *absolute_root_node = root_module->instantiate(&top_ctx, &root_inst);
AbstractNode *root_node;
// Do we have an explicit root node (! modifier)?
if (!(root_node = find_root_tag(absolute_root_node))) root_node = absolute_root_node;
diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc
index afc3128..81fc6b4 100644
--- a/tests/cgalpngtest.cc
+++ b/tests/cgalpngtest.cc
@@ -102,10 +102,10 @@ int main(int argc, char **argv)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
+ FileModule *root_module;
ModuleInstantiation root_inst("group");
root_module = parsefile(filename);
@@ -118,7 +118,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- AbstractNode *absolute_root_node = root_module->evaluate(&root_ctx, &root_inst);
+ AbstractNode *absolute_root_node = root_module->instantiate(&top_ctx, &root_inst);
AbstractNode *root_node;
// Do we have an explicit root node (! modifier)?
if (!(root_node = find_root_tag(absolute_root_node))) root_node = absolute_root_node;
diff --git a/tests/cgalstlsanitytest.cc b/tests/cgalstlsanitytest.cc
index 49a3f8e..4be7767 100644
--- a/tests/cgalstlsanitytest.cc
+++ b/tests/cgalstlsanitytest.cc
@@ -84,10 +84,10 @@ int main(int argc, char **argv)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
+ FileModule *root_module;
ModuleInstantiation root_inst("group");
root_module = parsefile(filename);
@@ -100,7 +100,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- AbstractNode *absolute_root_node = root_module->evaluate(&root_ctx, &root_inst);
+ AbstractNode *absolute_root_node = root_module->instantiate(&top_ctx, &root_inst);
AbstractNode *root_node;
// Do we have an explicit root node (! modifier)?
if (!(root_node = find_root_tag(absolute_root_node))) root_node = absolute_root_node;
diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc
index b7ae669..d750da9 100644
--- a/tests/cgaltest.cc
+++ b/tests/cgaltest.cc
@@ -81,10 +81,10 @@ int main(int argc, char **argv)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
+ FileModule *root_module;
ModuleInstantiation root_inst("group");
root_module = parsefile(filename);
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- AbstractNode *absolute_root_node = root_module->evaluate(&root_ctx, &root_inst);
+ AbstractNode *absolute_root_node = root_module->instantiate(&top_ctx, &root_inst);
AbstractNode *root_node;
// Do we have an explicit root node (! modifier)?
if (!(root_node = find_root_tag(absolute_root_node))) root_node = absolute_root_node;
diff --git a/tests/csgtermtest.cc b/tests/csgtermtest.cc
index f4a88e0..1460bbd 100644
--- a/tests/csgtermtest.cc
+++ b/tests/csgtermtest.cc
@@ -76,10 +76,10 @@ int main(int argc, char **argv)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
+ FileModule *root_module;
ModuleInstantiation root_inst("group");
const AbstractNode *root_node;
@@ -93,7 +93,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- root_node = root_module->evaluate(&root_ctx, &root_inst);
+ root_node = root_module->instantiate(&top_ctx, &root_inst);
Tree tree(root_node);
diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc
index 6da6411..320b533 100644
--- a/tests/csgtestcore.cc
+++ b/tests/csgtestcore.cc
@@ -132,10 +132,10 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
+ FileModule *root_module;
ModuleInstantiation root_inst("group");
if (sysinfo_dump)
@@ -154,7 +154,7 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
}
AbstractNode::resetIndexCounter();
- AbstractNode *absolute_root_node = root_module->evaluate(&root_ctx, &root_inst);
+ AbstractNode *absolute_root_node = root_module->instantiate(&top_ctx, &root_inst);
AbstractNode *root_node;
// Do we have an explicit root node (! modifier)?
if (!(root_node = find_root_tag(absolute_root_node))) root_node = absolute_root_node;
diff --git a/tests/csgtexttest.cc b/tests/csgtexttest.cc
index 3e26814..97902f6 100644
--- a/tests/csgtexttest.cc
+++ b/tests/csgtexttest.cc
@@ -80,10 +80,10 @@ int main(int argc, char **argv)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
+ FileModule *root_module;
ModuleInstantiation root_inst("group");
AbstractNode *root_node;
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- root_node = root_module->evaluate(&root_ctx, &root_inst);
+ root_node = root_module->instantiate(&top_ctx, &root_inst);
Tree tree;
tree.setRoot(root_node);
diff --git a/tests/dumptest.cc b/tests/dumptest.cc
index e0d2776..e4876fa 100644
--- a/tests/dumptest.cc
+++ b/tests/dumptest.cc
@@ -74,7 +74,6 @@ int main(int argc, char **argv)
const char *filename = argv[1];
const char *outfilename = argv[2];
-
int rc = 0;
Builtins::instance()->initialize();
@@ -86,10 +85,10 @@ int main(int argc, char **argv)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
+ FileModule *root_module;
ModuleInstantiation root_inst("group");
AbstractNode *root_node;
@@ -103,7 +102,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- root_node = root_module->evaluate(&root_ctx, &root_inst);
+ root_node = root_module->instantiate(&top_ctx, &root_inst);
Tree tree;
tree.setRoot(root_node);
@@ -115,10 +114,17 @@ int main(int argc, char **argv)
exit(1);
}
+ fs::current_path(original_path);
std::ofstream outfile;
outfile.open(outfilename);
+ if (!outfile.is_open()) {
+ fprintf(stderr, "Error: Unable to open output file %s\n", outfilename);
+ exit(1);
+ }
+ std::cout << "Opened " << outfilename << "\n";
outfile << dumpstdstr << "\n";
outfile.close();
+ if (outfile.fail()) fprintf(stderr, "Failed to close file\n");
delete root_node;
delete root_module;
@@ -131,7 +137,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- root_node = root_module->evaluate(&root_ctx, &root_inst);
+ root_node = root_module->instantiate(&top_ctx, &root_inst);
tree.setRoot(root_node);
diff --git a/tests/echotest.cc b/tests/echotest.cc
index 9924d11..3051751 100644
--- a/tests/echotest.cc
+++ b/tests/echotest.cc
@@ -88,10 +88,10 @@ int main(int argc, char **argv)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
+ FileModule *root_module;
ModuleInstantiation root_inst("group");
AbstractNode *root_node;
@@ -105,7 +105,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- root_node = root_module->evaluate(&root_ctx, &root_inst);
+ root_node = root_module->instantiate(&top_ctx, &root_inst);
delete root_node;
delete root_module;
diff --git a/tests/modulecachetest.cc b/tests/modulecachetest.cc
index 62f9543..5531461 100644
--- a/tests/modulecachetest.cc
+++ b/tests/modulecachetest.cc
@@ -76,14 +76,13 @@ int main(int argc, char **argv)
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
- ModuleContext root_ctx;
- root_ctx.registerBuiltin();
+ ModuleContext top_ctx;
+ top_ctx.registerBuiltin();
- AbstractModule *root_module;
ModuleInstantiation root_inst("group");
AbstractNode *root_node;
- root_module = parsefile(filename);
+ FileModule *root_module = parsefile(filename);
if (!root_module) {
fprintf(stderr, "Error: Unable to parse input file\n");
exit(1);
@@ -94,7 +93,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- root_node = root_module->evaluate(&root_ctx, &root_inst);
+ root_node = root_module->instantiate(&top_ctx, &root_inst);
delete root_node;
delete root_module;
@@ -109,7 +108,7 @@ int main(int argc, char **argv)
}
AbstractNode::resetIndexCounter();
- root_node = root_module->evaluate(&root_ctx, &root_inst);
+ root_node = root_module->instantiate(&top_ctx, &root_inst);
delete root_node;
delete root_module;
diff --git a/tests/regression/cgalpngtest/child-tests-expected.png b/tests/regression/cgalpngtest/child-tests-expected.png
index ed6207c..eb34f18 100644
--- a/tests/regression/cgalpngtest/child-tests-expected.png
+++ b/tests/regression/cgalpngtest/child-tests-expected.png
Binary files differ
diff --git a/tests/regression/cgalpngtest/localfiles-test-expected.png b/tests/regression/cgalpngtest/localfiles-test-expected.png
index 3ad3d96..d0cfd50 100644
--- a/tests/regression/cgalpngtest/localfiles-test-expected.png
+++ b/tests/regression/cgalpngtest/localfiles-test-expected.png
Binary files differ
diff --git a/tests/regression/dumptest/child-tests-expected.txt b/tests/regression/dumptest/child-tests-expected.txt
index 9a886fe..e1a7557 100644
--- a/tests/regression/dumptest/child-tests-expected.txt
+++ b/tests/regression/dumptest/child-tests-expected.txt
@@ -37,4 +37,16 @@
multmatrix([[1, 0, 0, 5], [0, 1, 0, 3], [0, 0, 1, 0], [0, 0, 0, 1]]) {
group();
}
+ multmatrix([[1, 0, 0, 0], [0, 1, 0, 6], [0, 0, 1, 0], [0, 0, 0, 1]]) {
+ group() {
+ group() {
+ multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
+ sphere($fn = 16, $fa = 12, $fs = 2, r = 1);
+ }
+ multmatrix([[1, 0, 0, 2.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
+ cube(size = [1, 1, 1], center = true);
+ }
+ }
+ }
+ }
diff --git a/tests/regression/dumptest/localfiles-test-expected.txt b/tests/regression/dumptest/localfiles-test-expected.txt
index acdf7e7..7a84e88 100644
--- a/tests/regression/dumptest/localfiles-test-expected.txt
+++ b/tests/regression/dumptest/localfiles-test-expected.txt
@@ -13,5 +13,8 @@
surface(file = "localfiles_dir/localfile.dat", center = false);
}
}
+ multmatrix([[1, 0, 0, 0], [0, 1, 0, -200], [0, 0, 1, 0], [0, 0, 0, 1]]) {
+ sphere($fn = 0, $fa = 12, $fs = 2, r = 100);
+ }
}
diff --git a/tests/regression/echotest/variable-scope-tests-expected.txt b/tests/regression/echotest/variable-scope-tests-expected.txt
new file mode 100644
index 0000000..92db05d
--- /dev/null
+++ b/tests/regression/echotest/variable-scope-tests-expected.txt
@@ -0,0 +1,16 @@
+ECHO: "special variable inheritance"
+ECHO: 23, 5
+WARNING: Ignoring unknown variable 'a'.
+ECHO: undef
+ECHO: 23, 5
+ECHO: "inner variables shadows parameter"
+ECHO: 5, 24
+ECHO: "user-defined special variables as parameter"
+ECHO: 7
+ECHO: 7
+ECHO: "assign only visible in children's scope"
+WARNING: Ignoring unknown variable 'c'.
+ECHO: undef
+ECHO: 5
+ECHO: "undeclared variable can still be passed and used"
+ECHO: 6
diff --git a/tests/regression/opencsgtest/child-tests-expected.png b/tests/regression/opencsgtest/child-tests-expected.png
index e8ea39b..2ff902c 100644
--- a/tests/regression/opencsgtest/child-tests-expected.png
+++ b/tests/regression/opencsgtest/child-tests-expected.png
Binary files differ
diff --git a/tests/regression/opencsgtest/localfiles-test-expected.png b/tests/regression/opencsgtest/localfiles-test-expected.png
index 7bc7909..f280efd 100644
--- a/tests/regression/opencsgtest/localfiles-test-expected.png
+++ b/tests/regression/opencsgtest/localfiles-test-expected.png
Binary files differ
diff --git a/tests/regression/throwntogethertest/child-tests-expected.png b/tests/regression/throwntogethertest/child-tests-expected.png
index 561334e..2ff902c 100644
--- a/tests/regression/throwntogethertest/child-tests-expected.png
+++ b/tests/regression/throwntogethertest/child-tests-expected.png
Binary files differ
diff --git a/tests/regression/throwntogethertest/localfiles-test-expected.png b/tests/regression/throwntogethertest/localfiles-test-expected.png
index 7bc7909..f280efd 100644
--- a/tests/regression/throwntogethertest/localfiles-test-expected.png
+++ b/tests/regression/throwntogethertest/localfiles-test-expected.png
Binary files differ
diff --git a/tests/tests-common.cc b/tests/tests-common.cc
index 703e1c5..ac85e37 100644
--- a/tests/tests-common.cc
+++ b/tests/tests-common.cc
@@ -7,9 +7,9 @@
#include <sstream>
#include <fstream>
-Module *parsefile(const char *filename)
+FileModule *parsefile(const char *filename)
{
- Module *root_module = NULL;
+ FileModule *root_module = NULL;
handle_dep(filename);
std::ifstream ifs(filename);
diff --git a/tests/tests-common.h b/tests/tests-common.h
index 0047562..3393884 100644
--- a/tests/tests-common.h
+++ b/tests/tests-common.h
@@ -1,6 +1,6 @@
#ifndef TESTS_COMMON_H_
#define TESTS_COMMON_H_
-class Module *parsefile(const char *filename);
+class FileModule *parsefile(const char *filename);
#endif
contact: Jan Huwald // Impressum