diff --git a/tests/factory_objects.aer b/tests/factory_objects.aer new file mode 100644 index 0000000..c0a1c86 --- /dev/null +++ b/tests/factory_objects.aer @@ -0,0 +1,29 @@ +class Circle { + void draw() { + print("Circle\n"); + } +} + +class Square { + void draw() { + print("Square\n"); + } +} + +class Program { + + object ShapeFactoryMethod(string $shape) { + switch ($shape) { + case "Circle": + return new Circle(); + case "Square": + return new Square(); + } + } + + void main() { + $this->ShapeFactoryMethod("Circle")->draw(); + $this->ShapeFactoryMethod("Square")->draw(); + } + +} diff --git a/tests/factory_objects.exp b/tests/factory_objects.exp new file mode 100644 index 0000000..83a280e --- /dev/null +++ b/tests/factory_objects.exp @@ -0,0 +1,2 @@ +Circle +Square