-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
26 lines (19 loc) · 990 Bytes
/
main.js
File metadata and controls
26 lines (19 loc) · 990 Bytes
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
var code_test = require('./code_test');
code_test.sanitizer(function(code) {
return code.replace('say', 'said');
});
/*code_test.load(function() {
code_test.run('hello', 'for(int i = 0; i < 5; i++) { cout << "I say " << i << endl; } int* test = NULL; cout << *test << endl;', process.stdout);
});*/
/*code_test.load(function() {
code_test.run('hello', 'cout << "everything is working" << endl; cout << "get ready for a segfault" << endl; int * q = NULL; cout << *q << endl;', process.stdout, process.stderr);
});*/
var runningProgram = new code_test.RunningProgram();
runningProgram.on('err', function(type, info) {
console.log('Our program had an error! Type: %s', type);
});
runningProgram.stdout = process.stdout;
runningProgram.stderr = process.stderr;
code_test.load(function() {
code_test.run2('hello', 'cout << "what a wonderful piece of code!" << endl; cout << "here is a segfault" << endl; int* test = NULL; cout << *test << endl;', runningProgram);
});