feat: add object field mutation support with dot-assignment syntax and setter methods

Add parser support for direct field mutation via `obj.field = expr` syntax, enabling mutable object state after creation. Extend the OOP test suite with dedicated mutation tests (`oop_mutation_test.rc`) and advanced examples (`oop_advanced.rc`) covering BankAccount, Player, and Rectangle classes. Update `oop_working.rc` with mutation test cases and revise TUTORIAL.md documentation to describe field mutation, setter methods, and complete OOP examples with mutation. Add Makefile targets for running the new mutation and advanced tests.
This commit is contained in:
2025-11-23 22:23:17 +00:00
parent 0ea0f8e9eb
commit 8c5de5ee9d
6 changed files with 654 additions and 11 deletions
+17 -1
View File
@@ -53,7 +53,9 @@ TESTS = $(TEST_DIR)/feature_test.rc \
$(TEST_DIR)/oop_step1.rc \
$(TEST_DIR)/oop_fields.rc \
$(TEST_DIR)/oop_method.rc \
$(TEST_DIR)/oop_working.rc
$(TEST_DIR)/oop_working.rc \
$(TEST_DIR)/oop_mutation_test.rc \
$(TEST_DIR)/oop_advanced.rc
EXAMPLES = $(EXAMPLE_DIR)/http_simple.rc \
$(EXAMPLE_DIR)/http_persistent.rc \
@@ -160,6 +162,12 @@ test: $(TARGET)
@echo "Running OOP working tests..."
@$(TARGET) $(TEST_DIR)/oop_working.rc 2>&1 | grep -v "Error at token" || true
@echo ""
@echo "Running OOP mutation tests..."
@$(TARGET) $(TEST_DIR)/oop_mutation_test.rc 2>&1 | grep -v "Error at token" || true
@echo ""
@echo "Running OOP advanced tests..."
@$(TARGET) $(TEST_DIR)/oop_advanced.rc 2>&1 | grep -v "Error at token" || true
@echo ""
@echo "=== All Tests Completed ==="
run-feature-test: $(TARGET)
@@ -237,6 +245,12 @@ run-oop-method: $(TARGET)
run-oop-working: $(TARGET)
$(TARGET) $(TEST_DIR)/oop_working.rc
run-oop-mutation: $(TARGET)
$(TARGET) $(TEST_DIR)/oop_mutation_test.rc
run-oop-advanced: $(TARGET)
$(TARGET) $(TEST_DIR)/oop_advanced.rc
run-http-simple: $(TARGET)
$(TARGET) $(EXAMPLE_DIR)/http_simple.rc
@@ -283,6 +297,8 @@ help:
@echo " make run-oop-fields - Run oop_fields.rc (field initialization)"
@echo " make run-oop-method - Run oop_method.rc (method calls)"
@echo " make run-oop-working - Run oop_working.rc (full OOP test)"
@echo " make run-oop-mutation - Run oop_mutation_test.rc (field mutation)"
@echo " make run-oop-advanced - Run oop_advanced.rc (advanced OOP examples)"
@echo ""
@echo "Examples:"
@echo " make run-http-simple - Run http_simple.rc (single connection HTTP server)"