mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-03 10:38:11 +08:00
Parse primitive defaults through record wire types
This commit is contained in:
@@ -723,7 +723,8 @@ impl TaggedValue {
|
|||||||
|
|
||||||
match ty {
|
match ty {
|
||||||
Type::Generic(_) => None,
|
Type::Generic(_) => None,
|
||||||
Type::Record(_) => None,
|
// A leveled wire's default is its element's default, as in `from_type`.
|
||||||
|
Type::Record(inner) => TaggedValue::from_primitive_string(string, inner),
|
||||||
Type::Concrete(concrete_type) => {
|
Type::Concrete(concrete_type) => {
|
||||||
let ty = concrete_type.id?;
|
let ty = concrete_type.id?;
|
||||||
use std::any::TypeId;
|
use std::any::TypeId;
|
||||||
@@ -974,3 +975,19 @@ mod leveled_edges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod record_defaults {
|
||||||
|
use super::*;
|
||||||
|
use core_types::registry::record_edge_type;
|
||||||
|
|
||||||
|
// The registry can present a record row first (wasm registration order),
|
||||||
|
// so primitive defaults must parse through the record wrapping.
|
||||||
|
#[test]
|
||||||
|
fn primitive_defaults_parse_through_record_wires() {
|
||||||
|
let leveled = core_types::registry::record_type::<f64>();
|
||||||
|
assert_eq!(TaggedValue::from_primitive_string("2.", &leveled), Some(TaggedValue::F64(2.)));
|
||||||
|
assert_eq!(TaggedValue::from_primitive_string("5", &record_edge_type::<u32>()), Some(TaggedValue::U32(5)));
|
||||||
|
assert_eq!(TaggedValue::from_primitive_string("true", &record_edge_type::<bool>()), Some(TaggedValue::Bool(true)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user