transformations.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 = "transformations/";
  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 scale"] = function() {
  22. check("scaleEx1");
  23. check("scaleEx2");
  24. }
  25. exports["test rotate"] = function() {
  26. check("rotateEx1");
  27. check("rotateEx2");
  28. }
  29. exports["test translate"] = function() {
  30. check("translateEx1");
  31. }
  32. exports["test mirror"] = function() {
  33. check("mirrorEx1");
  34. }
  35. exports["test multmatrix"] = function() {
  36. check("multmatrixEx1");
  37. check("multmatrixEx2");
  38. }
  39. exports["test color"] = function() {
  40. check("colorEx1");
  41. check("colorEx1");
  42. }
  43. exports["test minkowski"] = function() {
  44. // todo
  45. assert.ok(false);
  46. }
  47. exports["test hull"] = function() {
  48. // todo
  49. assert.ok(false);
  50. }
  51. if(module === require.main) require("test").run(exports);
  52. });