feat: construct native visual subclasses from Endor source
Verify Tessera GUI / verify (push) Successful in 9m53s
Verify Tessera GUI / verify (push) Successful in 9m53s
This commit is contained in:
@@ -795,6 +795,86 @@ mod tests {
|
||||
const EXAMPLE: &str = include_str!("../examples/hello.endor");
|
||||
const PAGE: &str = include_str!("../examples/page.endor");
|
||||
|
||||
#[test]
|
||||
fn source_native_subclasses_share_live_fields_and_release_replaced_storage() {
|
||||
let (mut session, initial) = ReplSession::load(
|
||||
include_str!("../examples/native-subclasses.endor"),
|
||||
"app.main",
|
||||
31,
|
||||
1,
|
||||
)
|
||||
.unwrap();
|
||||
initial.validate().unwrap();
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("isInstance(label, TextBlock)", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"true"
|
||||
);
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("isInstance(page, Page)", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"true"
|
||||
);
|
||||
session.execute("alias = label", "app.main").unwrap();
|
||||
let globals = session.candidate.globals.unwrap();
|
||||
let Value::Object(label) = session
|
||||
.candidate
|
||||
.vm
|
||||
.dict_get(globals, &Value::Text("label".into()))
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
else {
|
||||
panic!("Block expected")
|
||||
};
|
||||
let path = session
|
||||
.candidate
|
||||
.vm
|
||||
.object_store()
|
||||
.attribute_path(label)
|
||||
.unwrap();
|
||||
let previous = session
|
||||
.candidate
|
||||
.vm
|
||||
.downgrade(*path.last().unwrap())
|
||||
.unwrap();
|
||||
let updated = session
|
||||
.execute(
|
||||
r##"label = CustomStatus("replacement", 2, "#242422", "#237A45", "new field")"##,
|
||||
"app.main",
|
||||
)
|
||||
.unwrap()
|
||||
.document
|
||||
.unwrap();
|
||||
assert!(updated.frame.commands.iter().any(
|
||||
|command| matches!(command, RenderCommand::Text { value, .. } if value == "new field")
|
||||
));
|
||||
session
|
||||
.bridge
|
||||
.reclaim(&mut session.candidate.vm, &mut session.candidate.roots)
|
||||
.unwrap();
|
||||
assert!(session.candidate.vm.upgrade(previous).unwrap().is_none());
|
||||
assert_eq!(
|
||||
session.execute("alias.message", "app.main").unwrap().value,
|
||||
"\"new field\""
|
||||
);
|
||||
let updated = session
|
||||
.execute("button.click()", "app.main")
|
||||
.unwrap()
|
||||
.document
|
||||
.unwrap();
|
||||
assert_eq!(updated.frame.commands.iter().filter(|command| matches!(command, RenderCommand::Text { value, .. } if value == "new field")).count(), 3);
|
||||
let updated = session
|
||||
.execute("alias.message = \"changed field\"", "app.main")
|
||||
.unwrap()
|
||||
.document
|
||||
.unwrap();
|
||||
assert!(updated.frame.commands.iter().any(|command| matches!(command, RenderCommand::Text { value, .. } if value == "changed field")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loaded_program_console_and_native_events_share_unique_source_ids() {
|
||||
let (mut session, initial) = ReplSession::load(
|
||||
|
||||
Reference in New Issue
Block a user