-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-java-wrapper.js
More file actions
34 lines (29 loc) · 1.18 KB
/
test-java-wrapper.js
File metadata and controls
34 lines (29 loc) · 1.18 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
// Test to show the new Gson-free Java wrapper
const metadata = {
functionName: "isValid",
parameters: [{ name: "s", type: "string" }],
returnType: "boolean"
};
const userCode = `class Solution {
public boolean isValid(String s) {
Stack<Character> stack = new Stack<>();
for (char c : s.toCharArray()) {
if (c == '(') stack.push(')');
else if (c == '{') stack.push('}');
else if (c == '[') stack.push(']');
else if (stack.isEmpty() || stack.pop() != c) return false;
}
return stack.isEmpty();
}
}`;
// Import the dynamic wrapper service
import { generateDynamicWrapper } from './code-service/src/services/dynamic-wrapper.service.js';
const wrappedCode = generateDynamicWrapper(userCode, 62, metadata); // 62 = Java
console.log("=== Generated Java Wrapper (NO GSON!) ===\n");
console.log(wrappedCode);
console.log("\n=== Key Changes ===");
console.log("✅ No import com.google.gson.*");
console.log("✅ Manual JSON parsing using String methods");
console.log("✅ Only uses java.util.* (available in Judge0)");
console.log("✅ Parses input like: {\"s\":\"()\"}");
console.log("✅ Outputs boolean directly");