formatting

This commit is contained in:
pca006132 2020-12-28 16:00:02 +08:00 committed by pca006132
parent 75183c39fd
commit 0200ea1458

View File

@ -233,13 +233,7 @@ mod tests {
); );
assert_eq!( assert_eq!(
resolve_call( resolve_call(&ctx, None, "float", create_tuple(vec![]), &mut assumptions),
&ctx,
None,
"float",
create_tuple(vec![]),
&mut assumptions
),
Err("different parametric types".to_string()) Err("different parametric types".to_string())
); );
@ -493,14 +487,20 @@ mod tests {
let list = ctx.get_parametric_mut(LIST_TYPE); let list = ctx.get_parametric_mut(LIST_TYPE);
let t = Rc::new(TypeVariable(list.params[0])); let t = Rc::new(TypeVariable(list.params[0]));
list.base.methods.insert("head", FnDef { list.base.methods.insert(
args: create_tuple(vec![]), "head",
result: Some(t.clone()) FnDef {
}); args: create_tuple(vec![]),
list.base.methods.insert("append", FnDef { result: Some(t.clone()),
args: create_tuple(vec![t.clone()]), },
result: None );
}); list.base.methods.insert(
"append",
FnDef {
args: create_tuple(vec![t.clone()]),
result: None,
},
);
let v0 = Rc::new(TypeVariable(ctx.add_variable(VarDef { let v0 = Rc::new(TypeVariable(ctx.add_variable(VarDef {
name: "V0", name: "V0",
@ -541,7 +541,6 @@ mod tests {
), ),
Err("different variables".to_string()) Err("different variables".to_string())
); );
} }
#[test] #[test]
@ -553,46 +552,52 @@ mod tests {
base: TypeDef { base: TypeDef {
name: "Foo", name: "Foo",
methods: HashMap::new(), methods: HashMap::new(),
fields: HashMap::new() fields: HashMap::new(),
}, },
parents: vec![] parents: vec![],
}); });
let foo1 = ctx.add_class(ClassDef { let foo1 = ctx.add_class(ClassDef {
base: TypeDef { base: TypeDef {
name: "Foo1", name: "Foo1",
methods: HashMap::new(), methods: HashMap::new(),
fields: HashMap::new() fields: HashMap::new(),
}, },
parents: vec![foo] parents: vec![foo],
}); });
let foo2 = ctx.add_class(ClassDef { let foo2 = ctx.add_class(ClassDef {
base: TypeDef { base: TypeDef {
name: "Foo2", name: "Foo2",
methods: HashMap::new(), methods: HashMap::new(),
fields: HashMap::new() fields: HashMap::new(),
}, },
parents: vec![foo1] parents: vec![foo1],
}); });
let bar = ctx.add_class(ClassDef { let bar = ctx.add_class(ClassDef {
base: TypeDef { base: TypeDef {
name: "bar", name: "bar",
methods: HashMap::new(), methods: HashMap::new(),
fields: HashMap::new() fields: HashMap::new(),
}, },
parents: vec![] parents: vec![],
}); });
ctx.add_fn("foo", FnDef { ctx.add_fn(
args: create_tuple(vec![VirtualClassType(foo).into()]), "foo",
result: None FnDef {
}); args: create_tuple(vec![VirtualClassType(foo).into()]),
ctx.add_fn("foo1", FnDef { result: None,
args: create_tuple(vec![VirtualClassType(foo1).into()]), },
result: None );
}); ctx.add_fn(
"foo1",
FnDef {
args: create_tuple(vec![VirtualClassType(foo1).into()]),
result: None,
},
);
assert_eq!( assert_eq!(
resolve_call( resolve_call(