test: add inherit.er

This commit is contained in:
Shunsuke Shibayama 2023-03-07 21:48:52 +09:00
parent 8c2f5ec55f
commit 1dae378678
3 changed files with 22 additions and 2 deletions

View file

@ -1271,7 +1271,7 @@ impl Context {
let one = attr_name
.as_ref()
.map(|attr| {
ctxs.into_iter()
ctxs.iter()
.flat_map(|ctx| {
ctx.get_singular_ctxs_by_ident(attr, self)
.ok()
@ -1279,7 +1279,7 @@ impl Context {
})
.collect()
})
.unwrap_or(vec![]);
.unwrap_or(ctxs);
let two = obj
.qual_name()
.map(|name| {

View file

@ -0,0 +1,15 @@
@Inheritable
C = Class { .x = Int }
C.
const = 0
C.
new x: Int = C::__new__ { .x = x }
D = Inherit C
D.
@Override
new x: Int = D::__new__ { .x = x }
d: D = D.new(1)
print! d
assert D.const == 0

View file

@ -81,6 +81,11 @@ fn exec_import() -> Result<(), ()> {
expect_success("examples/import.er")
}
#[test]
fn exec_inherit() -> Result<(), ()> {
expect_success("tests/should_ok/inherit.er")
}
#[test]
fn exec_infer_class() -> Result<(), ()> {
expect_success("tests/should_ok/infer_class.er")