primitive_solids.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 = "primitive_solids/";
  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 cube"] = function() {
  22. check("cubeEx1");
  23. check("cubeEx2");
  24. }
  25. exports["test sphere"] = function() {
  26. check("sphereEx1");
  27. check("sphereEx2");
  28. }
  29. exports["test cylinder"] = function() {
  30. check("cylinderEx1");
  31. check("cylinderEx2");
  32. check("cylinderEx3");
  33. check("cylinderEx5");
  34. }
  35. exports["test cylinder additional parameters"] = function() {
  36. check("cylinderEx4");
  37. }
  38. exports["test polyhedron"] = function() {
  39. check("polyhedronEx1");
  40. check("polyhedronEx2");
  41. }
  42. if(module === require.main) require("test").run(exports);
  43. });