mirror of
https://github.com/denoland/deno.git
synced 2025-01-10 16:11:13 -05:00
test(core): type aliases in OpState (#8653)
This commit adds a test case to core/gotham_state.rs that shows that type aliases can't be used reliably. Instead wrapper types should be used.
This commit is contained in:
parent
f15b3d84a5
commit
b1379b7de3
1 changed files with 13 additions and 0 deletions
|
@ -94,6 +94,9 @@ mod tests {
|
||||||
value: &'static str,
|
value: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Alias1 = String;
|
||||||
|
type Alias2 = String;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn put_borrow1() {
|
fn put_borrow1() {
|
||||||
let mut state = GothamState::default();
|
let mut state = GothamState::default();
|
||||||
|
@ -165,4 +168,14 @@ mod tests {
|
||||||
assert!(state.try_borrow_mut::<MyStruct>().is_none());
|
assert!(state.try_borrow_mut::<MyStruct>().is_none());
|
||||||
assert!(state.try_borrow::<MyStruct>().is_none());
|
assert!(state.try_borrow::<MyStruct>().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn type_alias() {
|
||||||
|
let mut state = GothamState::default();
|
||||||
|
state.put::<Alias1>("alias1".to_string());
|
||||||
|
state.put::<Alias2>("alias2".to_string());
|
||||||
|
assert_eq!(state.take::<Alias1>(), "alias2");
|
||||||
|
assert!(state.try_take::<Alias1>().is_none());
|
||||||
|
assert!(state.try_take::<Alias2>().is_none());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue