-
Notifications
You must be signed in to change notification settings - Fork 8
/
testharness.js
executable file
·63 lines (37 loc) · 1.2 KB
/
testharness.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var requirejs = require('requirejs');
requirejs.config({
baseUrl: 'js/app',
paths: {
lib: '../lib'
},
nodeRequire: require
});
requirejs(["fs", "openscad-parser", "Globals", "openscad-parser-support"],
function(fs, parser, Globals, parser_support) {
if (parser.yy === undefined){
parser.yy = {}
}
logMessage = function(msg){
console.log("\n"+msg+"\n");
}
var openSCADText = fs.readFileSync("test.scad", "UTF8");
openSCADText = Globals.preParse(openSCADText);
var lines = openSCADText.split("\n");
for (var i in lines){
var line = lines[i];
lines[i] = line.replace(/include <([^>]*)>;?/, function(match, p1, offset, string) {
var includedModuleText = fs.readFileSync(p1, "UTF8");
return includedModuleText;
});
lines[i] = line.replace(/use <([^>]*)>;?/, function(match, p1, offset, string) {
var usedModuleText = fs.readFileSync(p1, "UTF8");
var usedModuleResult = parser.parse(usedModuleText);
parser.yy.context = usedModuleResult.context;
return match;
});
}
var joinedLines = lines.join('\n');
console.log(joinedLines);
var openJSCADResult = parser.parse(joinedLines);
console.log(openJSCADResult.lines.join('\n'));
});