commit 208006549cf2bab30a11f5a2f5e65eaa07e93afb
parent ac70c2d2787d79cc1627dac63696c90dcb54248a
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date: Wed, 16 Mar 2022 10:44:34 +0100
expand import tests
Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
Diffstat:
M | tests/24-imports.ha | | | 86 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ |
1 file changed, 80 insertions(+), 6 deletions(-)
diff --git a/tests/24-imports.ha b/tests/24-imports.ha
@@ -1,10 +1,84 @@
use rt;
-use test = rt;
-use rt::{malloc, free_};
+
+fn accept() void = {
+ assert(rt::compile("
+ use rt;
+ export fn main() void = { &rt::free_; };
+ ") == 0);
+ assert(rt::compile("
+ use rt;
+ use test = rt;
+ export fn main() void = assert(&rt::free_ == &test::free_);
+ ") == 0);
+ assert(rt::compile("
+ use rt;
+ use rt::{free_, malloc};
+ export fn main() void = assert(
+ &rt::free_ == &free_ && &rt::malloc == &malloc
+ );
+ ") == 0);
+ assert(rt::compile("
+ use rt;
+ use rt::*;
+ export fn main() void = assert(
+ &rt::free_ == &free_ && &rt::malloc == &malloc
+ );
+ ") == 0);
+ assert(rt::compile("
+ use rt;
+ use rt::{test = free_, malloc};
+ export fn main() void = assert(
+ &rt::free_ == &test && &rt::malloc == &malloc
+ );
+ ") == 0);
+ assert(rt::compile("
+ use rt;
+ use test = rt::{test = free_, malloc};
+ export fn main() void = assert(
+ &rt::free_ == &test::test && &rt::malloc == &test::malloc
+ );
+ ") == 0);
+};
+
+fn reject() void = {
+ assert(rt::compile("
+ use wrong;
+ export fn main() void = &rt::free_;
+ ") != 0);
+ assert(rt::compile("
+ use rt::{free_};
+ export fn main() void = assert(
+ &rt::free_ != null
+ );
+ ") != 0);
+ assert(rt::compile("
+ use rt::{free_};
+ export fn main() void = assert(
+ &malloc != null
+ );
+ ") != 0);
+ assert(rt::compile("
+ use rt;
+ use test = rt::*;
+ export fn main() void = void;
+ ") != 0);
+ assert(rt::compile("
+ use rt;
+ use rt*;
+ export fn main() void = void;
+ ") != 0);
+ assert(rt::compile("
+ use rt::{test = free_, malloc};
+ export fn main() void = assert(&free_ != null);
+ ") != 0);
+ assert(rt::compile("
+ use test = rt::{test = free_, malloc};
+ export fn main() void = assert(&test != null);
+ ") != 0);
+};
+
export fn main() void = {
- assert(&rt::malloc == &test::malloc);
- assert(&rt::malloc == &malloc);
- assert(&rt::free_ == &test::free_);
- assert(&rt::free_ == &free_);
+ accept();
+ reject();
};