feat: add return_flag and params_start for proper function return handling and parameter scanning
Implement a dedicated return_flag variable to replace the magic number -999 for return statements, enabling correct early exit from nested blocks. Add params_start field to Func struct to track parameter declaration positions, allowing the interpreter to properly map function arguments to local variables during function calls. Extend the test suite with new test files for arrays, comparison operators, logical operators, pointers, functions, trigonometry, and file seek operations, along with corresponding Makefile targets to execute them.
This commit is contained in:
@@ -29,7 +29,14 @@ TESTS = $(TEST_DIR)/feature_test.rc \
|
||||
$(TEST_DIR)/file_io_test.rc \
|
||||
$(TEST_DIR)/double_test.rc \
|
||||
$(TEST_DIR)/break_continue_test.rc \
|
||||
$(TEST_DIR)/async_io_test.rc
|
||||
$(TEST_DIR)/async_io_test.rc \
|
||||
$(TEST_DIR)/array_test.rc \
|
||||
$(TEST_DIR)/pointer_test.rc \
|
||||
$(TEST_DIR)/logical_test.rc \
|
||||
$(TEST_DIR)/comparison_test.rc \
|
||||
$(TEST_DIR)/functions_test.rc \
|
||||
$(TEST_DIR)/trig_test.rc \
|
||||
$(TEST_DIR)/file_seek_test.rc
|
||||
|
||||
EXAMPLES = $(EXAMPLE_DIR)/http_simple.rc \
|
||||
$(EXAMPLE_DIR)/http_persistent.rc \
|
||||
@@ -73,6 +80,39 @@ test: $(TARGET)
|
||||
@echo "Running increment decrement tests..."
|
||||
@$(TARGET) $(TEST_DIR)/increment_decrement_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running file I/O tests..."
|
||||
@$(TARGET) $(TEST_DIR)/file_io_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running double tests..."
|
||||
@$(TARGET) $(TEST_DIR)/double_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running break/continue tests..."
|
||||
@$(TARGET) $(TEST_DIR)/break_continue_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running async I/O tests..."
|
||||
@$(TARGET) $(TEST_DIR)/async_io_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running array tests..."
|
||||
@$(TARGET) $(TEST_DIR)/array_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running pointer tests..."
|
||||
@$(TARGET) $(TEST_DIR)/pointer_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running logical operators tests..."
|
||||
@$(TARGET) $(TEST_DIR)/logical_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running comparison operators tests..."
|
||||
@$(TARGET) $(TEST_DIR)/comparison_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running functions tests..."
|
||||
@$(TARGET) $(TEST_DIR)/functions_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running trigonometry tests..."
|
||||
@$(TARGET) $(TEST_DIR)/trig_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "Running file seek tests..."
|
||||
@$(TARGET) $(TEST_DIR)/file_seek_test.rc 2>&1 | grep -v "Error at token" || true
|
||||
@echo ""
|
||||
@echo "=== All Tests Completed ==="
|
||||
|
||||
run-feature-test: $(TARGET)
|
||||
@@ -105,6 +145,27 @@ run-break-continue-test: $(TARGET)
|
||||
run-async-io-test: $(TARGET)
|
||||
$(TARGET) $(TEST_DIR)/async_io_test.rc
|
||||
|
||||
run-array-test: $(TARGET)
|
||||
$(TARGET) $(TEST_DIR)/array_test.rc
|
||||
|
||||
run-pointer-test: $(TARGET)
|
||||
$(TARGET) $(TEST_DIR)/pointer_test.rc
|
||||
|
||||
run-logical-test: $(TARGET)
|
||||
$(TARGET) $(TEST_DIR)/logical_test.rc
|
||||
|
||||
run-comparison-test: $(TARGET)
|
||||
$(TARGET) $(TEST_DIR)/comparison_test.rc
|
||||
|
||||
run-functions-test: $(TARGET)
|
||||
$(TARGET) $(TEST_DIR)/functions_test.rc
|
||||
|
||||
run-trig-test: $(TARGET)
|
||||
$(TARGET) $(TEST_DIR)/trig_test.rc
|
||||
|
||||
run-file-seek-test: $(TARGET)
|
||||
$(TARGET) $(TEST_DIR)/file_seek_test.rc
|
||||
|
||||
run-http-simple: $(TARGET)
|
||||
$(TARGET) $(EXAMPLE_DIR)/http_simple.rc
|
||||
|
||||
@@ -131,10 +192,18 @@ help:
|
||||
@echo " make run-math-test - Run math_test.rc (math functions)"
|
||||
@echo " make run-string-test - Run string_test.rc (string concatenation)"
|
||||
@echo " make run-string-manip - Run string_manip_test.rc (string manipulation & slicing)"
|
||||
@echo " make run-increment-decrement-test - Run increment_decrement_test.rc (++/--)"
|
||||
@echo " make run-file-io-test - Run file_io_test.rc (file I/O operations)"
|
||||
@echo " make run-double-test - Run double_test.rc (double data type)"
|
||||
@echo " make run-break-continue-test - Run break_continue_test.rc (break/continue)"
|
||||
@echo " make run-async-io-test - Run async_io_test.rc (async I/O)"
|
||||
@echo " make run-array-test - Run array_test.rc (arrays)"
|
||||
@echo " make run-pointer-test - Run pointer_test.rc (pointers & dereference)"
|
||||
@echo " make run-logical-test - Run logical_test.rc (&&, ||)"
|
||||
@echo " make run-comparison-test - Run comparison_test.rc (<, >, <=, >=)"
|
||||
@echo " make run-functions-test - Run functions_test.rc (function calls & recursion)"
|
||||
@echo " make run-trig-test - Run trig_test.rc (sin, cos, tan)"
|
||||
@echo " make run-file-seek-test - Run file_seek_test.rc (fseek, ftell)"
|
||||
@echo ""
|
||||
@echo "Examples:"
|
||||
@echo " make run-http-simple - Run http_simple.rc (single connection HTTP server)"
|
||||
|
||||
Reference in New Issue
Block a user