Enable source function type checks in the shared GUI runtime
Verify Tessera GUI / verify (push) Failing after 7m34s
Verify Tessera GUI / verify (push) Failing after 7m34s
This commit is contained in:
@@ -955,6 +955,94 @@ mod tests {
|
||||
const EXAMPLE: &str = include_str!("../examples/hello.endor");
|
||||
const PAGE: &str = include_str!("../examples/page.endor");
|
||||
|
||||
#[test]
|
||||
fn source_annotations_classify_functions_and_reject_before_body() {
|
||||
let (mut session, _) = ReplSession::load(
|
||||
include_str!("../examples/function-types.endor"),
|
||||
"app.main",
|
||||
1,
|
||||
180,
|
||||
)
|
||||
.unwrap();
|
||||
for expression in [
|
||||
"isInstance(identity,Function)",
|
||||
"isInstance(ui.rect,Function)",
|
||||
"isInstance(actions.read,Function)",
|
||||
] {
|
||||
assert_eq!(
|
||||
session.execute(expression, "app.main").unwrap().value,
|
||||
"true"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("isInstance(RectBlock,Function)", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"false"
|
||||
);
|
||||
session
|
||||
.execute(
|
||||
"function checked(value: Number): Number { state.increment() return value }",
|
||||
"app.main",
|
||||
)
|
||||
.unwrap();
|
||||
let error = session
|
||||
.execute("checked(\"wrong\")", "app.main")
|
||||
.err()
|
||||
.unwrap();
|
||||
assert!(
|
||||
error.to_string().contains("parameter value expects Number"),
|
||||
"{error:#}"
|
||||
);
|
||||
assert_eq!(
|
||||
session.execute("state.value", "app.main").unwrap().value,
|
||||
"0"
|
||||
);
|
||||
assert_eq!(
|
||||
session.execute("checked(7)", "app.main").unwrap().value,
|
||||
"7"
|
||||
);
|
||||
session
|
||||
.execute("function wrong(): Number { return \"wrong\" }", "app.main")
|
||||
.unwrap();
|
||||
let error = session.execute("wrong()", "app.main").err().unwrap();
|
||||
assert!(
|
||||
error.to_string().contains("return expects Number"),
|
||||
"{error:#}"
|
||||
);
|
||||
assert!(
|
||||
session
|
||||
.execute("callNumber(RectBlock)", "app.main")
|
||||
.is_err()
|
||||
);
|
||||
session
|
||||
.execute(
|
||||
"class Actions { function read(self: Actions): Number { return 9 } }",
|
||||
"app.main",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("callNumber(savedFunction)", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"1"
|
||||
);
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("isInstance(actions,Actions)", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"false"
|
||||
);
|
||||
session.execute("button.click()", "app.main").unwrap();
|
||||
assert_eq!(
|
||||
session.execute("state.value", "app.main").unwrap().value,
|
||||
"2"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stopped_window_teardown_detaches_mounts_without_running_source_hooks() {
|
||||
let source = r#"class WatchedPage: Page {
|
||||
|
||||
Reference in New Issue
Block a user