mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
Sorry copy tests
This commit is contained in:
parent
f4b7ea245c
commit
1b90f45c9d
1 changed files with 2 additions and 55 deletions
|
@ -637,14 +637,9 @@ fn deep_copy_type_vars<'a>(
|
||||||
mod test {
|
mod test {
|
||||||
use super::deep_copy_type_vars;
|
use super::deep_copy_type_vars;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_module::ident::TagName;
|
|
||||||
use roc_module::symbol::Symbol;
|
use roc_module::symbol::Symbol;
|
||||||
use roc_types::{
|
use roc_types::subs::{
|
||||||
subs::{
|
Content, Content::*, Descriptor, Mark, OptVariable, Rank, Subs, SubsIndex, Variable,
|
||||||
Content, Content::*, Descriptor, FlatType::*, Mark, OptVariable, Rank, RecordFields,
|
|
||||||
Subs, SubsIndex, UnionTags, Variable,
|
|
||||||
},
|
|
||||||
types::RecordField,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -748,52 +743,4 @@ mod test {
|
||||||
it => assert!(false, "{:?}", it),
|
it => assert!(false, "{:?}", it),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn copy_type_with_copied_reference() {
|
|
||||||
let mut subs = Subs::new();
|
|
||||||
let arena = Bump::new();
|
|
||||||
|
|
||||||
let flex_var = new_var(&mut subs, FlexVar(None));
|
|
||||||
|
|
||||||
let content = Structure(TagUnion(
|
|
||||||
UnionTags::insert_into_subs(&mut subs, [(TagName::Tag("A".into()), [flex_var])]),
|
|
||||||
Variable::EMPTY_TAG_UNION,
|
|
||||||
));
|
|
||||||
|
|
||||||
let tag_var = new_var(&mut subs, content);
|
|
||||||
|
|
||||||
let mut copies = deep_copy_type_vars(&arena, &mut subs, tag_var);
|
|
||||||
|
|
||||||
assert_eq!(copies.len(), 2);
|
|
||||||
let (original_flex, new_flex) = copies[0];
|
|
||||||
assert_ne!(original_flex, new_flex);
|
|
||||||
assert_eq!(original_flex, flex_var);
|
|
||||||
|
|
||||||
let (original_tag, new_tag) = copies[1];
|
|
||||||
assert_ne!(original_tag, new_tag);
|
|
||||||
assert_eq!(original_tag, tag_var);
|
|
||||||
|
|
||||||
match subs.get_content_without_compacting(new_tag) {
|
|
||||||
Structure(TagUnion(union_tags, Variable::EMPTY_TAG_UNION)) => {
|
|
||||||
let (tag_name, vars) = union_tags.iter_all().next().unwrap();
|
|
||||||
match &subs[tag_name] {
|
|
||||||
TagName::Tag(upper) => assert_eq!(upper.as_str(), "A"),
|
|
||||||
_ => assert!(false, "{:?}", tag_name),
|
|
||||||
}
|
|
||||||
|
|
||||||
let vars = subs[vars];
|
|
||||||
assert_eq!(vars.len(), 1);
|
|
||||||
|
|
||||||
let var = subs[vars.into_iter().next().unwrap()];
|
|
||||||
assert_eq!(var, new_flex);
|
|
||||||
}
|
|
||||||
it => assert!(false, "{:?}", it),
|
|
||||||
}
|
|
||||||
|
|
||||||
assert!(matches!(
|
|
||||||
subs.get_content_without_compacting(new_flex),
|
|
||||||
FlexVar(None)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue