Browse Source

Another test of closure.

pull/50/head
Rafal Kupiec 2 years ago
parent
commit
ee7b1e56ae
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 25 additions and 0 deletions
  1. +24
    -0
      tests/extended_closure.aer
  2. +1
    -0
      tests/extended_closure.exp

+ 24
- 0
tests/extended_closure.aer View File

@ -0,0 +1,24 @@
class Dog {
public string $name;
public string $color;
public void __construct(string $name, string $color) {
$this->name = $name;
$this->color = $color;
}
public callback greet(string $greeting) {
return void() using ($greeting) {
print("$greeting, I am a {$this->color} dog named {$this->name}\n");
};
}
}
class Program {
void main() {
object $dog = new Dog('Alex', 'red');
callback $c = $dog->greet('Hello');
$c();
}
}

+ 1
- 0
tests/extended_closure.exp View File

@ -0,0 +1 @@
Hello, I am a red dog named Alex

Loading…
Cancel
Save