-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDoWhileStandaloneTest.cpp
More file actions
57 lines (43 loc) · 1.51 KB
/
DoWhileStandaloneTest.cpp
File metadata and controls
57 lines (43 loc) · 1.51 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
#include <KAI/Core/Console.h>
#include <iostream>
KAI_BEGIN
int main() {
std::cout << "=== Do-While Loop Standalone Test ===" << std::endl;
// Create registry and console
Registry reg;
reg.AddClass<int>("int");
reg.AddClass<bool>("bool");
reg.AddClass<float>("float");
reg.AddClass<String>("String");
Console console(®);
console.SetLanguage(Language::Rho);
auto exec = console.GetExecutor();
exec->SetTraceLevel(5); // Maximum tracing for debugging
try {
std::cout << "Executing simple do-while loop..." << std::endl;
// Execute a very simple do-while loop
console.Execute(
"i = 0;\n"
"do {\n"
" i = i + 1;\n"
"} while (i < 3);\n");
// Print result
auto stack = exec->GetDataStack();
std::cout << "Stack size after execution: " << stack->Size()
<< std::endl;
// Verify result by checking the value of i
console.Execute("i");
std::cout << "Final value of i: " << exec->GetDataStack()->Top()
<< std::endl;
std::cout << "Do-while loop test completed successfully!" << std::endl;
return 0;
} catch (const Exception::Base& e) {
std::cerr << "KAI exception: " << e.ToString() << std::endl;
} catch (const std::exception& e) {
std::cerr << "Standard exception: " << e.what() << std::endl;
} catch (...) {
std::cerr << "Unknown exception" << std::endl;
}
return 1;
}
KAI_END