modules.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var requirejs = require('requirejs');
  2. requirejs.config({
  3. baseUrl: '../src',
  4. paths: {
  5. lib: '../lib'
  6. },
  7. nodeRequire: require
  8. });
  9. requirejs(["fs", "assert", "openscad-parser", "Globals", "openscad-parser-support", "lib/underscore"],
  10. function(fs, assert, parser, Globals, parser_support) {
  11. var filedir = "modules/";
  12. function parse(s) {
  13. return parser.parse(s);
  14. }
  15. function check(testFileName) {
  16. var test = fs.readFileSync(filedir+testFileName+".scad", "utf8");
  17. var expected = fs.readFileSync(filedir+testFileName+".jscad", "utf8").replace(/\n/g,'');
  18. var actual = parse(test).lines.join('').replace(/\n/g,'');
  19. assert.equal(actual, expected, console.log(testFileName));
  20. }
  21. exports["test modules"] = function() {
  22. check("modulesEx1");
  23. }
  24. exports["test modules child"] = function() {
  25. check("modulesChildEx1");
  26. }
  27. exports["test modules children"] = function() {
  28. check("modulesChildrenEx1");
  29. }
  30. exports["test modules parameters"] = function() {
  31. check("modulesParametersEx1");
  32. }
  33. if(module === require.main) require("test").run(exports);
  34. });