-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Add a test of instantiating an extension set #939
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -635,4 +635,34 @@ mod test { | |
); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn instantiate_extension_delta() -> Result<(), Box<dyn std::error::Error>> { | ||
use crate::extension::prelude::{BOOL_T, PRELUDE_REGISTRY}; | ||
|
||
let mut e = Extension::new(EXT_ID); | ||
let ext_id = e.name().clone(); | ||
|
||
let es = ExtensionSet::singleton(&ext_id); | ||
let params: Vec<TypeParam> = vec![TypeParam::Extensions]; | ||
let args = [TypeArg::Extensions { es: es.clone() }]; | ||
let mut db_set = ExtensionSet::new(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you use |
||
db_set.insert_type_var(0); | ||
let fun_ty = FunctionType::new_endo(vec![BOOL_T]).with_extension_delta(db_set); | ||
|
||
let exp_fun_ty = FunctionType::new_endo(vec![BOOL_T]).with_extension_delta(es); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional/super-nit: I think I'd finish making |
||
|
||
let def = e.add_op( | ||
"SimpleOp".into(), | ||
"".into(), | ||
PolyFuncType::new(params.clone(), fun_ty), | ||
)?; | ||
def.validate_args(&args, &PRELUDE_REGISTRY, ¶ms) | ||
.unwrap(); | ||
assert_eq!( | ||
def.compute_signature(&args, &PRELUDE_REGISTRY), | ||
Ok(exp_fun_ty) | ||
); | ||
Ok(()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can't you just use
EXT_ID
rather thanext_id
and avoid this?