Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"Bash(rustc:*)",
"Bash(gh release view:*)",
"Bash(git rev-parse:*)",
"Bash(cargo run:*)"
"Bash(cargo run:*)",
"Bash(./target/release/wfl.exe:*)"
],
"deny": [],
"ask": []
Expand Down
129 changes: 79 additions & 50 deletions Nexus/nexus.wfl
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ store count2 as 0
store total_odds as 0
repeat while count2 is less than 5:
change count2 to count2 plus 1
// Skip even numbers
check if ((count2 divided by 2) times 2) is equal to count2:
// Skip even numbers (using modulo operator)
check if (count2 % 2) is equal to 0:
skip // (continue to next iteration)
end check
change total_odds to total_odds plus count2
Expand Down Expand Up @@ -252,16 +252,16 @@ repeat while outer_j is less than or equal to 3:
store inner_j as 1
repeat while inner_j is less than or equal to 3:
check if inner_j is equal to 2:
exit loop // exit the outer loop entirely
exit loop // exit ALL enclosing loops (both inner and outer)
end check
change inner_j to inner_j plus 1
end repeat
// Only increment outer counter if loop wasn't exited
// This code should NOT be reached because 'exit loop' exits all loops
change exit_outer_counter to exit_outer_counter plus 1
change outer_j to outer_j plus 1
end repeat
// 'exit loop' should break out of the outer loop on the first iteration when inner_j == 2
check if exit_outer_counter is equal to 1:
// 'exit loop' breaks out of ALL loops, so exit_outer_counter should remain 0
check if exit_outer_counter is equal to 0:
log_message with "Nested loop 'exit' test: PASS"
otherwise:
log_message with "Nested loop 'exit' test: FAIL (outer iterations = " with exit_outer_counter with ")"
Expand Down Expand Up @@ -305,10 +305,8 @@ end action
// 5.5 Action that triggers an error (for error handling test)
define action called faulty:
// This action will cause a division by zero error
store u as 1
store v as 0
store w as u divided by v // runtime error (division by zero)
give back w
// Directly perform division by zero to trigger error
give back 1 divided by 0
end action

// Call actions and verify results
Expand Down Expand Up @@ -355,44 +353,74 @@ end try
log_message with "Action/Function Tests completed."

///////////////////////////////////////////////////////////////////////////
// 6. Pattern Matching Tests (COMMENTED OUT - NOT YET IMPLEMENTED)
///////////////////////////////////////////////////////////////////////////
// TODO: Pattern matching with natural language syntax is not yet implemented.
// The syntax `pattern "3 digits"` needs to be implemented, or this section
// should be rewritten using the working `create pattern` syntax from
// patterns_working_comprehensive.wfl
//
// Working syntax example:
// create pattern pat:
// exactly 3 digit
// end pattern
// check if text matches pat:
// ...
// end check
// 6. Pattern Matching Tests
///////////////////////////////////////////////////////////////////////////
log_message with "Starting Pattern Matching Tests..."

// Create a pattern to match exactly three digits
create pattern three_digits:
exactly 3 digit
end pattern

// Test a string that contains three digits in a row
store text1 as "abc123xyz"
check if text1 matches three_digits:
log_message with "Pattern test (\"abc123xyz\" matches 3 digits): PASS"
otherwise:
log_message with "Pattern test (\"abc123xyz\" should match 3 digits): FAIL"
end check

// Test a string that does not contain three consecutive digits
store text2 as "abc45xyz"
check if text2 matches three_digits:
log_message with "Pattern test (\"abc45xyz\" should NOT match 3 digits): FAIL"
otherwise:
log_message with "Pattern test (\"abc45xyz\" no 3-digit match): PASS"
end check

// Create a pattern for simple word matching
create pattern word_pattern:
one or more letter
end pattern

// Test valid word
store word1 as "hello"
check if word1 matches word_pattern:
log_message with "Pattern test (word matching): PASS"
otherwise:
log_message with "Pattern test (word matching): FAIL"
end check

// Test non-word (should fail)
store word2 as "123"
check if word2 matches word_pattern:
log_message with "Pattern test (non-word should fail): FAIL"
otherwise:
log_message with "Pattern test (non-word correctly rejected): PASS"
end check

// Create a pattern with quantifiers
create pattern between_pattern:
2 to 5 digit
end pattern

// Test number with 3 digits (should pass)
store num1 as "123"
check if num1 matches between_pattern:
log_message with "Pattern test (2-5 digits, testing 3): PASS"
otherwise:
log_message with "Pattern test (2-5 digits, testing 3): FAIL"
end check

// Test number with 1 digit (should fail)
store num2 as "1"
check if num2 matches between_pattern:
log_message with "Pattern test (1 digit should fail 2-5 range): FAIL"
otherwise:
log_message with "Pattern test (1 digit correctly rejected): PASS"
end check

// log_message with "Starting Pattern Matching Tests..."
//
// // Create a pattern to match three digits
// store pat as pattern "3 digits"
//
// // Test a string that contains three digits in a row
// store text1 as "abc123xyz"
// check if text1 contains pat:
// log_message with "Pattern test (\"abc123xyz\" contains 3 digits): PASS"
// otherwise:
// log_message with "Pattern test (\"abc123xyz\" should contain 3 digits): FAIL"
// end check
//
// // Test a string that does not contain three consecutive digits
// store text2 as "abc45xyz"
// check if text2 contains pat:
// log_message with "Pattern test (\"abc45xyz\" should NOT contain 3 digits): FAIL"
// otherwise:
// log_message with "Pattern test (\"abc45xyz\" no 3-digit sequence): PASS"
// end check
//
// log_message with "Pattern Matching Tests completed."
log_message with "Pattern Matching Tests completed."

///////////////////////////////////////////////////////////////////////////
// 6. Asynchronous I/O and Concurrency Tests (formerly section 7)
Expand Down Expand Up @@ -425,7 +453,7 @@ count from 1 to 100:
end count

// Verify that both file contents were read correctly
check if content1 is equal to "FileOneContent" and content2 is equal to "FileTwoContent":
check if (content1 is equal to "FileOneContent") and (content2 is equal to "FileTwoContent"):
log_message with "Concurrent file read test: PASS (content1 & content2 OK)"
otherwise:
log_message with "Concurrent file read test: FAIL (content1=" with content1 with ", content2=" with content2 with ")"
Expand All @@ -437,12 +465,13 @@ log_message with "Async I/O and Concurrency Tests completed."
// End of tests: Finalize
///////////////////////////////////////////////////////////////////////////

// TODO: Clean up temporary files (file deletion not yet implemented)
// delete file at "temp1.txt"
// delete file at "temp2.txt"
// Clean up temporary files created during async I/O tests
delete file at "temp1.txt"
delete file at "temp2.txt"

// Final log message before closing
log_message with "All tests completed."
log_message with "Temporary files cleaned up."

// Close the log file
close file logHandle
Expand Down
41 changes: 36 additions & 5 deletions scripts/run_integration_tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ Write-Host "[SUCCESS] All integration tests passed" -ForegroundColor Green
# Run WFL test programs
Write-Host "[INFO] Running WFL test programs..." -ForegroundColor Blue

# Tests that require special handling (web servers, interactive tests)
# These are tested separately with dedicated scripts
$SkipTests = @(
"simple_web_test.wfl", # Web server - needs HTTP client
"web_server_test.wfl", # Web server - needs HTTP client
"websocket_test.wfl" # WebSocket - needs WS client
)

# Timeout for each test (seconds)
$TestTimeout = 30

if (-not (Test-Path "TestPrograms")) {
Write-Host "[WARNING] TestPrograms directory not found, skipping WFL program tests" -ForegroundColor Yellow
} else {
Expand All @@ -111,19 +122,39 @@ if (-not (Test-Path "TestPrograms")) {
Write-Host "[WARNING] No WFL test programs found in TestPrograms/" -ForegroundColor Yellow
} else {
Write-Host "[INFO] Found $($wflFiles.Count) WFL test programs" -ForegroundColor Blue

$failedPrograms = 0
$skippedPrograms = 0
foreach ($wflFile in $wflFiles) {
# Check if this test should be skipped
if ($SkipTests -contains $wflFile.Name) {
Write-Host "[SKIP] $($wflFile.Name) (requires special handling)" -ForegroundColor Yellow
$skippedPrograms++
continue
}

Write-Host "[INFO] Testing: $($wflFile.Name)" -ForegroundColor Blue
$null = & ".\$BinaryPath" $wflFile.FullName 2>&1
if ($LASTEXITCODE -eq 0) {

# Run with timeout to prevent hangs
$process = Start-Process -FilePath ".\$BinaryPath" -ArgumentList $wflFile.FullName -NoNewWindow -PassThru -RedirectStandardOutput "NUL" -RedirectStandardError "NUL"
$completed = $process.WaitForExit($TestTimeout * 1000)

if (-not $completed) {
# Test timed out
$process.Kill()
Write-Host "[ERROR] TIMEOUT $($wflFile.Name) (exceeded ${TestTimeout}s)" -ForegroundColor Red
$failedPrograms++
} elseif ($process.ExitCode -eq 0) {
Write-Host "[SUCCESS] PASS $($wflFile.Name)" -ForegroundColor Green
} else {
Write-Host "[ERROR] FAIL $($wflFile.Name)" -ForegroundColor Red
Write-Host "[ERROR] FAIL $($wflFile.Name) (exit code: $($process.ExitCode))" -ForegroundColor Red
$failedPrograms++
}
}


Write-Host ""
Write-Host "[INFO] Results: $($wflFiles.Count - $skippedPrograms - $failedPrograms) passed, $failedPrograms failed, $skippedPrograms skipped" -ForegroundColor Blue

if ($failedPrograms -eq 0) {
Write-Host "[SUCCESS] All WFL test programs passed" -ForegroundColor Green
} else {
Expand Down
67 changes: 56 additions & 11 deletions scripts/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,46 +77,91 @@ run_integration_tests() {
return 0
}

# Tests that require special handling (web servers, interactive tests)
# These are tested separately with dedicated scripts
SKIP_TESTS=(
"simple_web_test.wfl" # Web server - needs HTTP client
"web_server_test.wfl" # Web server - needs HTTP client
"websocket_test.wfl" # WebSocket - needs WS client
)

# Timeout for each test (seconds)
TEST_TIMEOUT=30

# Function to check if a test should be skipped
should_skip() {
local test_name="$1"
for skip in "${SKIP_TESTS[@]}"; do
if [ "$test_name" == "$skip" ]; then
return 0
fi
done
return 1
}

# Function to run TestPrograms
run_test_programs() {
print_status "Running WFL test programs..."

# Determine binary path based on OS
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
WFL_BINARY="target/release/wfl.exe"
else
WFL_BINARY="target/release/wfl"
fi

# Check if TestPrograms directory exists
if [ ! -d "TestPrograms" ]; then
print_warning "TestPrograms directory not found, skipping WFL program tests"
return 0
fi

# Count WFL files
wfl_files=$(find TestPrograms -name "*.wfl" 2>/dev/null | wc -l)
wfl_files=$(find TestPrograms -maxdepth 1 -name "*.wfl" 2>/dev/null | wc -l)
if [ "$wfl_files" -eq 0 ]; then
print_warning "No WFL test programs found in TestPrograms/"
return 0
fi

print_status "Found $wfl_files WFL test programs"

# Run each WFL program
failed_programs=0
skipped_programs=0
passed_programs=0

for wfl_file in TestPrograms/*.wfl; do
if [ -f "$wfl_file" ]; then
print_status "Testing: $wfl_file"
if "./$WFL_BINARY" "$wfl_file" > /dev/null 2>&1; then
print_success "✓ $wfl_file"
test_name=$(basename "$wfl_file")

# Check if this test should be skipped
if should_skip "$test_name"; then
print_warning "[SKIP] $test_name (requires special handling)"
((skipped_programs++))
continue
fi

print_status "Testing: $test_name"

# Run with timeout to prevent hangs
if timeout "${TEST_TIMEOUT}s" "./$WFL_BINARY" "$wfl_file" > /dev/null 2>&1; then
print_success "PASS $test_name"
((passed_programs++))
else
print_error "✗ $wfl_file"
exit_code=$?
if [ $exit_code -eq 124 ]; then
print_error "TIMEOUT $test_name (exceeded ${TEST_TIMEOUT}s)"
else
print_error "FAIL $test_name (exit code: $exit_code)"
fi
((failed_programs++))
fi
Comment on lines +146 to 158

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Exit code capture is incorrectly placed.

The exit_code=$? on line 151 captures the exit status of the if condition evaluation, not the timeout command. Move the capture to preserve the actual exit code.

Apply this diff to fix the exit code capture:

             # Run with timeout to prevent hangs
-            if timeout "${TEST_TIMEOUT}s" "./$WFL_BINARY" "$wfl_file" > /dev/null 2>&1; then
+            timeout "${TEST_TIMEOUT}s" "./$WFL_BINARY" "$wfl_file" > /dev/null 2>&1
+            exit_code=$?
+            if [ $exit_code -eq 0 ]; then
                 print_success "PASS $test_name"
                 ((passed_programs++))
             else
-                exit_code=$?
                 if [ $exit_code -eq 124 ]; then
                     print_error "TIMEOUT $test_name (exceeded ${TEST_TIMEOUT}s)"
                 else
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Run with timeout to prevent hangs
if timeout "${TEST_TIMEOUT}s" "./$WFL_BINARY" "$wfl_file" > /dev/null 2>&1; then
print_success "PASS $test_name"
((passed_programs++))
else
print_error "$wfl_file"
exit_code=$?
if [ $exit_code -eq 124 ]; then
print_error "TIMEOUT $test_name (exceeded ${TEST_TIMEOUT}s)"
else
print_error "FAIL $test_name (exit code: $exit_code)"
fi
((failed_programs++))
fi
# Run with timeout to prevent hangs
timeout "${TEST_TIMEOUT}s" "./$WFL_BINARY" "$wfl_file" > /dev/null 2>&1
exit_code=$?
if [ $exit_code -eq 0 ]; then
print_success "PASS $test_name"
((passed_programs++))
else
if [ $exit_code -eq 124 ]; then
print_error "TIMEOUT $test_name (exceeded ${TEST_TIMEOUT}s)"
else
print_error "FAIL $test_name (exit code: $exit_code)"
fi
((failed_programs++))
fi
🤖 Prompt for AI Agents
In scripts/run_integration_tests.sh around lines 146 to 158, the exit_code=$? is
placed after the if which captures the status of the shell's conditional
evaluation rather than the timeout command; move the exit_code=$? to immediately
after the timeout "./$WFL_BINARY" "$wfl_file" invocation (before the if) so you
preserve the actual exit status from timeout, then adjust the if to test that
saved exit_code (e.g., check if exit_code == 0) to decide PASS vs
failure/timeouts and keep the existing timeout-vs-other-exit handling.

fi
done


echo ""
print_status "Results: $passed_programs passed, $failed_programs failed, $skipped_programs skipped"

if [ "$failed_programs" -eq 0 ]; then
print_success "All WFL test programs passed"
return 0
Expand Down
Loading