Bind managed Block properties with read-only dependency tracking
Verify Tessera GUI / verify (push) Failing after 7m31s
Verify Tessera GUI / verify (push) Failing after 7m31s
This commit is contained in:
@@ -57,6 +57,7 @@ pub fn compile(source: &str, namespace: &str, submission: u64) -> Result<RenderD
|
||||
.map_err(|error| runtime_error(&candidate.vm, error))?;
|
||||
candidate.vm.release_value(value)?;
|
||||
}
|
||||
bridge.refresh_bindings(&mut candidate.vm)?;
|
||||
let ui_root = match &plan {
|
||||
SourcePlan::Script(_) => bridge
|
||||
.rendered(&candidate.vm)?
|
||||
@@ -75,6 +76,7 @@ pub fn compile(source: &str, namespace: &str, submission: u64) -> Result<RenderD
|
||||
.vm
|
||||
.call_with_limits(entry, &[], LIMITS)
|
||||
.map_err(|error| runtime_error(&candidate.vm, error))?;
|
||||
bridge.refresh_bindings(&mut candidate.vm)?;
|
||||
let snapshot = bridge
|
||||
.rendered(&candidate.vm)
|
||||
.and_then(|rendered| match rendered {
|
||||
@@ -475,6 +477,10 @@ impl ReplSession {
|
||||
let mut mutated_mounts = false;
|
||||
let result = (|| {
|
||||
loop {
|
||||
if let Err(error) = self.bridge.refresh_bindings(&mut self.candidate.vm) {
|
||||
self.faulted = true;
|
||||
return Err(error);
|
||||
}
|
||||
let mut pass_changed = false;
|
||||
for id in self.bridge.window_ids()? {
|
||||
self.bridge.select_window(id)?;
|
||||
@@ -2556,6 +2562,167 @@ mod tests {
|
||||
assert!(!session.is_faulted());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn managed_property_bindings_update_hidden_objects_and_shared_window_geometry() {
|
||||
let mut session = ReplSession::new(220).unwrap();
|
||||
session
|
||||
.execute(
|
||||
r##"
|
||||
class Model {
|
||||
width: Number
|
||||
function read(self: Model): Number { return self.width }
|
||||
}
|
||||
model = Model(80)
|
||||
rect = RectBlock(1,20,0,"#DDEEFF")
|
||||
token = rect.bind("width",model.read)
|
||||
"##,
|
||||
"app.main",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
session.execute("rect.width", "app.main").unwrap().value,
|
||||
"80"
|
||||
);
|
||||
session.execute("model.width = 140", "app.main").unwrap();
|
||||
assert_eq!(
|
||||
session.execute("rect.width", "app.main").unwrap().value,
|
||||
"140"
|
||||
);
|
||||
session.execute("first = Page()\nfirst.render(rect)\nother = Window()\nsecond = Page()\nsecond.open(other)\nsecond.render(rect)", "app.main").unwrap();
|
||||
let updated = session
|
||||
.execute("model.width = 260", "app.main")
|
||||
.unwrap()
|
||||
.document
|
||||
.unwrap();
|
||||
for frame in std::iter::once(&updated.frame)
|
||||
.chain(updated.windows.values().map(|document| &document.frame))
|
||||
{
|
||||
assert!(frame.mounts.iter().any(|mount| mount.width == 260.0));
|
||||
}
|
||||
session
|
||||
.execute("token.disconnect()\nmodel.width = 360", "app.main")
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
session.execute("rect.width", "app.main").unwrap().value,
|
||||
"260"
|
||||
);
|
||||
let direct = session
|
||||
.execute("rect.width = 180", "app.main")
|
||||
.unwrap()
|
||||
.document
|
||||
.unwrap();
|
||||
assert!(direct.frame.mounts.iter().any(|mount| mount.width == 180.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiple_object_outputs_on_one_target_do_not_invalidate_each_other() {
|
||||
let mut session = ReplSession::new(222).unwrap();
|
||||
session
|
||||
.execute(
|
||||
r##"
|
||||
class Record { value: Number }
|
||||
function makeRecord(): Object { return Record(7) }
|
||||
rect = RectBlock(1,20)
|
||||
rect.first = Record(0)
|
||||
rect.second = Record(0)
|
||||
first = rect.bind("first",makeRecord)
|
||||
second = rect.bind("second",makeRecord)
|
||||
"##,
|
||||
"app.main",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("rect.first.value", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"7"
|
||||
);
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("rect.second.value", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"7"
|
||||
);
|
||||
assert!(!session.is_faulted());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binding_tokens_do_not_retain_hidden_targets_and_compute_is_read_only() {
|
||||
let mut session = ReplSession::new(221).unwrap();
|
||||
session
|
||||
.execute(
|
||||
r##"
|
||||
class Model {
|
||||
width: Number
|
||||
function read(self: Model): Number { return self.width }
|
||||
function bad(self: Model): Number {
|
||||
self.width = 999
|
||||
return self.width
|
||||
}
|
||||
}
|
||||
model = Model(80)
|
||||
rect = RectBlock(1,20,0,"#DDEEFF")
|
||||
token = rect.bind("width",model.read)
|
||||
"##,
|
||||
"app.main",
|
||||
)
|
||||
.unwrap();
|
||||
let globals = session.candidate.globals.unwrap();
|
||||
let Value::Object(target) = session
|
||||
.candidate
|
||||
.vm
|
||||
.dict_get(globals, &Value::Text("rect".into()))
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
else {
|
||||
panic!("expected Block");
|
||||
};
|
||||
let weak = session
|
||||
.candidate
|
||||
.vm
|
||||
.object_store()
|
||||
.downgrade(target)
|
||||
.unwrap();
|
||||
session
|
||||
.candidate
|
||||
.vm
|
||||
.dict_delete(globals, &Value::Text("rect".into()))
|
||||
.unwrap();
|
||||
session.candidate.vm.collect_cycles();
|
||||
assert!(session.candidate.vm.upgrade(weak).unwrap().is_none());
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("token.isConnected()", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"false"
|
||||
);
|
||||
assert!(
|
||||
session
|
||||
.execute(
|
||||
"other = RectBlock(1,20)\nbadToken = other.bind(\"width\",model.bad)",
|
||||
"app.main"
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(session.is_faulted());
|
||||
let Value::Object(model) = session
|
||||
.candidate
|
||||
.vm
|
||||
.dict_get(globals, &Value::Text("model".into()))
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
else {
|
||||
panic!("expected model");
|
||||
};
|
||||
assert_eq!(
|
||||
session.candidate.vm.get_attr(model, "width").unwrap(),
|
||||
Value::Number(80.into())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_method_callbacks_update_two_explicit_bindings() {
|
||||
let mut session = ReplSession::new(21).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user