summaryrefslogtreecommitdiff
path: root/tests/csgtexttest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/csgtexttest.cc')
-rw-r--r--tests/csgtexttest.cc52
1 files changed, 11 insertions, 41 deletions
diff --git a/tests/csgtexttest.cc b/tests/csgtexttest.cc
index 21ebf6a..76f6eb1 100644
--- a/tests/csgtexttest.cc
+++ b/tests/csgtexttest.cc
@@ -1,6 +1,7 @@
/*
- * OpenSCAD (www.openscad.at)
- * Copyright (C) 2009 Clifford Wolf <clifford@clifford.at>
+ * OpenSCAD (www.openscad.org)
+ * Copyright (C) 2009-2011 Clifford Wolf <clifford@clifford.at> and
+ * Marius Kintel <marius@kintel.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,10 +24,10 @@
*
*/
+#include "tests-common.h"
#include "CSGTextRenderer.h"
#include "CSGTextCache.h"
#include "openscad.h"
-#include "handle_dep.h"
#include "node.h"
#include "module.h"
#include "context.h"
@@ -71,8 +72,7 @@ int main(int argc, char **argv)
int rc = 0;
- initialize_builtin_functions();
- initialize_builtin_modules();
+ Builtins::instance()->initialize();
QApplication app(argc, argv, false);
QDir original_path = QDir::current();
@@ -99,48 +99,18 @@ int main(int argc, char **argv)
}
Context root_ctx;
- root_ctx.functions_p = &builtin_functions;
- root_ctx.modules_p = &builtin_modules;
- root_ctx.set_variable("$fn", Value(0.0));
- root_ctx.set_variable("$fs", Value(1.0));
- root_ctx.set_variable("$fa", Value(12.0));
- root_ctx.set_variable("$t", Value(0.0));
-
- Value zero3;
- zero3.type = Value::VECTOR;
- zero3.append(new Value(0.0));
- zero3.append(new Value(0.0));
- zero3.append(new Value(0.0));
- root_ctx.set_variable("$vpt", zero3);
- root_ctx.set_variable("$vpr", zero3);
-
+ register_builtin(root_ctx);
AbstractModule *root_module;
ModuleInstantiation root_inst;
AbstractNode *root_node;
- QFileInfo fileInfo(filename);
- handle_dep(filename);
- FILE *fp = fopen(filename, "rt");
- if (!fp) {
- fprintf(stderr, "Can't open input file `%s'!\n", filename);
+ root_module = parsefile(filename);
+ if (!root_module) {
exit(1);
- } else {
- std::stringstream text;
- char buffer[513];
- int ret;
- while ((ret = fread(buffer, 1, 512, fp)) > 0) {
- buffer[ret] = 0;
- text << buffer;
- }
- fclose(fp);
- text << commandline_commands;
- root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false);
- if (!root_module) {
- exit(1);
- }
}
+ QFileInfo fileInfo(filename);
QDir::setCurrent(fileInfo.absolutePath());
AbstractNode::resetIndexCounter();
@@ -153,13 +123,13 @@ int main(int argc, char **argv)
csgTree(csgcache, *root_node);
// std::cout << tree.getString(*root_node) << "\n";
+ QDir::setCurrent(original_path.absolutePath());
std::ofstream outfile;
outfile.open(outfilename);
outfile << csgcache[*root_node] << "\n";
outfile.close();
- destroy_builtin_functions();
- destroy_builtin_modules();
+ Builtins::instance(true);
return rc;
}
contact: Jan Huwald // Impressum