Browse Source

Add interface tests (OOP).

pull/50/head
Rafal Kupiec 1 year ago
parent
commit
bda8316e1b
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 46 additions and 0 deletions
  1. +42
    -0
      tests/interface_test.aer
  2. +4
    -0
      tests/interface_test.exp

+ 42
- 0
tests/interface_test.aer View File

@ -0,0 +1,42 @@
interface iVehicle {
public void drive();
public void stop();
}
class Car implements iVehicle {
public void drive() {
print("Driving...\n");
}
public void stop() {
print("Stopping...\n");
}
}
class MyCar extends Car {
public void drive() {
print("Driving my car...\n");
}
}
class Program {
public void driveCar(iVehicle $vehicle) {
$vehicle->drive();
$vehicle->stop();
}
public void main() {
object $car = new Car();
object $mycar = new MyCar();
$this->driveCar($car);
$this->driveCar($mycar);
}
}

+ 4
- 0
tests/interface_test.exp View File

@ -0,0 +1,4 @@
Driving...
Stopping...
Driving my car...
Stopping...

Loading…
Cancel
Save