-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-test.js
More file actions
100 lines (88 loc) · 3.67 KB
/
debug-test.js
File metadata and controls
100 lines (88 loc) · 3.67 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env node
const { RuntimeController } = require('./dist');
async function debugTest() {
console.log('🔍 Debug Test for node-rc\n');
const rc = new RuntimeController();
try {
// Test 1: Basic initialization
console.log('1️⃣ Testing initialization...');
const nativeController = await rc.getNativeController();
console.log('✅ Native controller initialized\n');
// Test 2: Python (should work)
console.log('2️⃣ Testing Python execution...');
const python = rc.PythonInterpreter();
const pythonResult = await python.execute('x = 42; print(f"Python result: {x}")');
console.log('✅ Python:', pythonResult.success ? 'SUCCESS' : 'FAILED');
if (!pythonResult.success) {
console.log('❌ Error:', pythonResult.error?.message);
}
console.log();
// Test 3: JavaScript with Porffor (check if broken)
console.log('3️⃣ Testing JavaScript execution...');
const js = rc.JavaScriptInterpreter();
const jsResult = await js.execute('console.log("JavaScript works"); 42 + 8;');
console.log('🔍 JavaScript:', jsResult.success ? 'SUCCESS' : 'FAILED');
if (!jsResult.success) {
console.log('❌ JS Error:', jsResult.error?.message);
console.log('❌ JS Stderr:', jsResult.errorOutput);
} else {
console.log('✅ JS Output:', jsResult.output);
console.log('✅ JS Value:', jsResult.value);
}
console.log();
// Test 4: TypeScript with Porffor (check if broken)
console.log('4️⃣ Testing TypeScript execution...');
const ts = rc.TypeScriptInterpreter();
const tsResult = await ts.execute('const greet = (name: string) => `Hello ${name}`; console.log(greet("TypeScript"));');
console.log('🔍 TypeScript:', tsResult.success ? 'SUCCESS' : 'FAILED');
if (!tsResult.success) {
console.log('❌ TS Error:', tsResult.error?.message);
console.log('❌ TS Stderr:', tsResult.errorOutput);
} else {
console.log('✅ TS Output:', tsResult.output);
}
console.log();
// Test 5: C Runtime (check null property errors)
console.log('5️⃣ Testing C runtime...');
try {
const c = rc.CInterpreter();
const cResult = await c.execute('#include <stdio.h>\nint main() { printf("Hello C"); return 0; }');
console.log('🔍 C Runtime:', cResult.success ? 'SUCCESS' : 'FAILED');
if (!cResult.success) {
console.log('❌ C Error:', cResult.error?.message);
console.log('❌ C Stderr:', cResult.errorOutput);
}
} catch (error) {
console.log('❌ C Runtime Error:', error.message);
}
console.log();
// Test 6: Java Runtime (check null property errors)
console.log('6️⃣ Testing Java runtime...');
try {
const java = rc.JavaInterpreter();
const javaResult = await java.execute('System.out.println("Hello Java");');
console.log('🔍 Java Runtime:', javaResult.success ? 'SUCCESS' : 'FAILED');
if (!javaResult.success) {
console.log('❌ Java Error:', javaResult.error?.message);
console.log('❌ Java Stderr:', javaResult.errorOutput);
}
} catch (error) {
console.log('❌ Java Runtime Error:', error.message);
}
console.log();
// Test 7: RuntimePool stats
console.log('7️⃣ Testing RuntimePool stats...');
try {
const stats = await rc.getRuntimePoolStats();
console.log('✅ RuntimePool stats:', stats);
} catch (error) {
console.log('❌ RuntimePool Error:', error.message);
}
} catch (error) {
console.log('💥 Fatal Error:', error.message);
console.log(error.stack);
} finally {
await rc.shutdown();
}
}
debugTest().catch(console.error);