Ticket #3424: AddDeleteComponent.mos

File AddDeleteComponent.mos, 1.1 KB (added by Adeel Asghar, 9 years ago)
Line 
1echo(false);
2s1 := "model M1
3 annotation(Icon(coordinateSystem(
4 preserveAspectRatio=false,
5 extent={{-100,-100},{100,100}}), graphics={
6 Line(points={{-60,50},{60,50}}, color={0,0,255}),
7 Line(points={{-40,30},{40,30}}, color={0,0,255}),
8 Line(points={{-20,10},{20,10}}, color={0,0,255}),
9 Line(points={{0,90},{0,50}}, color={0,0,255})}));
10end M1;";
11loadString(s1, "M1.mo");
12getErrorString();
13addComponent(m1, Real, M1, annotate=Placement(visible=true, transformation=transformation(origin={-24,-54}, extent={{-10,-10},{10,10}}, rotation=0)));
14getErrorString();
15s2 := listFile(M1);
16getErrorString();
17contents := diffModelicaFileListings(s1, s2, OpenModelica.Scripting.DiffFormat.plain);
18getErrorString();
19deleteComponent(m1, M1);
20getErrorString();
21s2 := listFile(M1);
22if s1<>diffModelicaFileListings(contents, s2, OpenModelica.Scripting.DiffFormat.plain) then
23 print("\nFailed \n");
24 print("\nStart model:\n\n" + contents + "\n");
25 print("\ndeleteComponent+listFile:\n\n" + s2 + "\n");
26 print("\nDiff:\n\n" + diffModelicaFileListings(contents, s2) + "\n");
27 print(getErrorString());
28end if;