From ed8dab7870ccd33b4fd5e20a9856fba9c0b18ec2 Mon Sep 17 00:00:00 2001 From: belliash Date: Tue, 5 Feb 2019 19:48:38 +0100 Subject: [PATCH] Add more tests. --- tests/callback_function.aer | 15 +++++++++++++++ tests/callback_function.exp | 4 ++++ tests/reference_test.aer | 13 +++++++++++++ tests/reference_test.exp | 1 + 4 files changed, 33 insertions(+) create mode 100644 tests/callback_function.aer create mode 100644 tests/callback_function.exp create mode 100644 tests/reference_test.aer create mode 100644 tests/reference_test.exp diff --git a/tests/callback_function.aer b/tests/callback_function.aer new file mode 100644 index 0000000..1cca0c3 --- /dev/null +++ b/tests/callback_function.aer @@ -0,0 +1,15 @@ +class Program { + + function main(string[] $args) { + callback $y = function() { + callback $a = 'printf'; + $a("I'm alive\n"); + var_dump($a); + }; + $y(); + var_dump($y); + string $a = 'printf'; + var_dump($a); + } + +} diff --git a/tests/callback_function.exp b/tests/callback_function.exp new file mode 100644 index 0000000..5a63841 --- /dev/null +++ b/tests/callback_function.exp @@ -0,0 +1,4 @@ +I'm alive +callback(6 'printf') +callback(11 '{closure_1}') +string(6 'printf') diff --git a/tests/reference_test.aer b/tests/reference_test.aer new file mode 100644 index 0000000..09073ac --- /dev/null +++ b/tests/reference_test.aer @@ -0,0 +1,13 @@ +class Program { + + function add_by_ref(int &$val) { + $val += 7; + } + + function main() { + int $num = 7; + $this->add_by_ref($num); + var_dump($num); + } + +} diff --git a/tests/reference_test.exp b/tests/reference_test.exp new file mode 100644 index 0000000..a7fce3e --- /dev/null +++ b/tests/reference_test.exp @@ -0,0 +1 @@ +int(14)