examples.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. function parse(s) {
  12. return parser.parse(s);
  13. }
  14. function check(testFileName) {
  15. var test = fs.readFileSync("examples/"+testFileName+".scad", "utf8");
  16. var expected = fs.readFileSync("examples/"+testFileName+".jscad", "utf8").replace(/\n/g,'');
  17. var actual = parse(test).lines.join('').replace(/\n/g,'');
  18. //assert.equal(actual, expected, console.log("\nExpected:\n" + expected + "\n\nActual:\n" + actual + "\n"));
  19. assert.equal(actual, expected);
  20. }
  21. exports["test example001"] = function() { check("example001"); }
  22. exports["test example002"] = function() { check("example002"); }
  23. exports["test example003"] = function() { check("example003"); }
  24. exports["test example004"] = function() { check("example004"); }
  25. exports["test example005"] = function() { check("example005"); }
  26. exports["test example006"] = function() { check("example006"); }
  27. //exports["test example007"] = function() { check("example007"); }
  28. //exports["test example008"] = function() { check("example008"); }
  29. //exports["test example009"] = function() { check("example009"); }
  30. //exports["test example010"] = function() { check("example010"); }
  31. exports["test example011"] = function() { check("example011"); }
  32. //exports["test example012"] = function() { check("example012"); }
  33. //exports["test example013"] = function() { check("example013"); }
  34. exports["test example014"] = function() { check("example014"); }
  35. //exports["test example015"] = function() { check("example015"); }
  36. //exports["test example016"] = function() { check("example016"); }
  37. //exports["test example017"] = function() { check("example017"); }
  38. exports["test example018"] = function() { check("example018"); }
  39. exports["test example019"] = function() { check("example019"); }
  40. //exports["test example020"] = function() { check("example020"); }
  41. //exports["test example021"] = function() { check("example021"); }
  42. //exports["test example022"] = function() { check("example022"); }
  43. //exports["test example023"] = function() { check("example023"); }
  44. if(module === require.main) require("test").run(exports);
  45. });