conditional_and_iterator_functions.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 = "conditional_and_iterator_functions/";
  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);
  20. }
  21. exports["test for loop"] = function() {
  22. check("forLoopEx1");
  23. check("forLoopEx2a");
  24. check("forLoopEx2b");
  25. check("forLoopEx3");
  26. check("forLoopEx4");
  27. }
  28. exports["test intersection_for loop"] = function() {
  29. check("intersectionForLoopEx1");
  30. check("intersectionForLoopEx2");
  31. }
  32. exports["test if statement"] = function() {
  33. check("ifStatementEx1");
  34. }
  35. exports["test assign statement"] = function() {
  36. assert.fail("todo ");
  37. }
  38. if(module === require.main) require("test").run(exports);
  39. });