// Simple SAL Rhai Integration Test // Tests that all major SAL modules are working print("๐Ÿงช SAL Rhai Integration - Simple Test"); print("====================================="); let tests_passed = 0; let total_tests = 0; // Test 1: OS Module total_tests += 1; print("Test 1: OS Module - File existence check"); try { let result = exist("Cargo.toml"); if result { print(" โœ“ PASSED - Cargo.toml exists"); tests_passed += 1; } else { print(" โœ— FAILED - Cargo.toml should exist"); } } catch (error) { print(` โœ— FAILED - Error: ${error}`); } // Test 2: Process Module total_tests += 1; print("Test 2: Process Module - Command detection"); try { let result = which("echo"); if result != () { print(" โœ“ PASSED - echo command found"); tests_passed += 1; } else { print(" โœ— FAILED - echo command not found"); } } catch (error) { print(` โœ— FAILED - Error: ${error}`); } // Test 3: Text Module total_tests += 1; print("Test 3: Text Module - Text processing"); try { let result = dedent(" Hello World"); if result == "Hello World" { print(" โœ“ PASSED - Text dedenting works"); tests_passed += 1; } else { print(` โœ— FAILED - Expected 'Hello World', got '${result}'`); } } catch (error) { print(` โœ— FAILED - Error: ${error}`); } // Test 4: Net Module total_tests += 1; print("Test 4: Net Module - TCP check"); try { let result = tcp_check("127.0.0.1", 65534); if type_of(result) == "bool" { print(" โœ“ PASSED - TCP check returns boolean"); tests_passed += 1; } else { print(` โœ— FAILED - Expected boolean, got ${type_of(result)}`); } } catch (error) { print(` โœ— FAILED - Error: ${error}`); } // Test 5: Core Module total_tests += 1; print("Test 5: Core Module - Exec function"); try { let result = exec("21 * 2"); if result == 42 { print(" โœ“ PASSED - Exec function works"); tests_passed += 1; } else { print(` โœ— FAILED - Expected 42, got ${result}`); } } catch (error) { print(` โœ— FAILED - Error: ${error}`); } // Test 6: Process execution total_tests += 1; print("Test 6: Process Module - Command execution"); try { let result = run_command("echo 'Integration Test'"); if result.success && result.stdout.contains("Integration Test") { print(" โœ“ PASSED - Command execution works"); tests_passed += 1; } else { print(" โœ— FAILED - Command execution failed"); } } catch (error) { print(` โœ— FAILED - Error: ${error}`); } // Test 7: Cross-module integration total_tests += 1; print("Test 7: Cross-module integration"); try { // Use text module to process content, then process module to execute let raw_text = " echo 'cross-module-test' "; let processed = dedent(raw_text); let final_command = processed.trim(); // If dedent removed too much, use a fallback command if final_command.len() == 0 { final_command = "echo 'cross-module-test'"; } let result = run_command(final_command); if result.success && result.stdout.contains("cross-module-test") { print(" โœ“ PASSED - Cross-module integration works"); tests_passed += 1; } else { print(" โœ— FAILED - Cross-module integration failed"); } } catch (error) { print(` โœ— FAILED - Error: ${error}`); } // Summary print(""); print("====================================="); print(`Results: ${tests_passed}/${total_tests} tests passed`); if tests_passed == total_tests { print("๐ŸŽ‰ All tests passed! SAL Rhai integration is working!"); true } else { print(`โš ๏ธ ${total_tests - tests_passed} test(s) failed`); false }