use crate::spec::{expect_failure, expect_parse_success};
mod vendor_annotations {
use super::*;
#[test]
fn mls_18_8_vendor_basic() {
expect_parse_success(
r#"
model Test
Real x;
equation
x = 1;
annotation(__Dymola_experimentSetupOutput);
end Test;
"#,
);
}
#[test]
fn mls_18_8_vendor_with_value() {
expect_parse_success(
r#"
model Test
Real x;
equation
x = 1;
annotation(__Dymola_Commands(file = "script.mos"));
end Test;
"#,
);
}
#[test]
fn mls_18_8_vendor_multiple() {
expect_parse_success(
r#"
model Test
Real x;
equation
x = 1;
annotation(
__Dymola_experimentSetupOutput,
__OpenModelica_commandLineOptions = "-d=newInst",
__Wolfram_mathLinkOptions(timeout = 30)
);
end Test;
"#,
);
}
#[test]
fn mls_18_8_vendor_complex() {
expect_parse_success(
r#"
model Test
Real x;
equation
x = 1;
annotation(
__Dymola_selections(
selection1(name = "Test", match = "*.x")
)
);
end Test;
"#,
);
}
#[test]
fn mls_18_8_vendor_preservation() {
expect_parse_success(
r#"
model Test
Real x annotation(__MyTool_special = true);
equation
x = 1;
end Test;
"#,
);
}
#[test]
fn mls_18_8_vendor_on_component() {
expect_parse_success(
r#"
model Test
Real x annotation(__Dymola_BoundaryCondition = true);
equation
x = 1;
end Test;
"#,
);
}
#[test]
fn mls_18_8_vendor_on_equation() {
expect_parse_success(
r#"
model Test
Real x;
equation
x = 1 annotation(__Dymola_label = "main equation");
end Test;
"#,
);
}
}
mod annotation_restrictions {
use super::*;
#[test]
#[ignore = "Annotation final restriction not yet enforced"]
fn mls_18_1_no_final_in_annotation() {
expect_failure(
r#"
model Test
Real x;
equation
x = 1;
annotation(final Documentation(info = "test"));
end Test;
"#,
"Test",
);
}
#[test]
#[ignore = "Annotation each restriction not yet enforced"]
fn mls_18_1_no_each_in_annotation() {
expect_failure(
r#"
model Test
Real x;
equation
x = 1;
annotation(each Placement(visible = true));
end Test;
"#,
"Test",
);
}
#[test]
fn mls_18_1_no_redeclare_in_annotation() {
expect_failure(
r#"
model Test
Real x;
equation
x = 1;
annotation(redeclare Icon(coordinateSystem(extent = {{-100,-100},{100,100}})));
end Test;
"#,
"Test",
);
}
#[test]
fn mls_18_1_valid_annotation() {
expect_parse_success(
r#"
model Test
Real x;
equation
x = 1;
annotation(
Documentation(info = "<html>Test model</html>"),
Icon(coordinateSystem(extent = {{-100,-100},{100,100}}))
);
end Test;
"#,
);
}
}
mod test_case_annotation {
use super::*;
#[test]
fn mls_18_7_test_case_basic() {
expect_parse_success(
r#"
model Test
Real x(start = 0, fixed = true);
equation
der(x) = 1;
annotation(__Dymola_TestCase(expect = "success"));
end Test;
"#,
);
}
#[test]
fn mls_18_7_test_case_expected() {
expect_parse_success(
r#"
model Test
Real x(start = 0, fixed = true);
equation
der(x) = 1;
annotation(
experiment(StopTime = 1),
__Dymola_TestCase(
expect = "success",
result = {x(finalValue = 1)}
)
);
end Test;
"#,
);
}
}